Rosa's TurbineBenchmark

Percentage Accurate: 84.5% → 99.8%
Time: 11.4s
Alternatives: 9
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \end{array} \]
(FPCore (v w r)
 :precision binary64
 (-
  (-
   (+ 3.0 (/ 2.0 (* r r)))
   (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
  4.5))
double code(double v, double w, double r) {
	return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
	return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r):
	return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r)
	return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5)
end
function tmp = code(v, w, r)
	tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 84.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \end{array} \]
(FPCore (v w r)
 :precision binary64
 (-
  (-
   (+ 3.0 (/ 2.0 (* r r)))
   (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
  4.5))
double code(double v, double w, double r) {
	return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
	return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r):
	return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r)
	return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5)
end
function tmp = code(v, w, r)
	tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
\end{array}

Alternative 1: 99.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + -0.25 \cdot v}{\frac{\frac{v + -1}{r \cdot w}}{r \cdot w}}\right) \end{array} \]
(FPCore (v w r)
 :precision binary64
 (+
  (/ 2.0 (* r r))
  (+ -1.5 (/ (+ 0.375 (* -0.25 v)) (/ (/ (+ v -1.0) (* r w)) (* r w))))))
double code(double v, double w, double r) {
	return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / (((v + -1.0) / (r * w)) / (r * w))));
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    code = (2.0d0 / (r * r)) + ((-1.5d0) + ((0.375d0 + ((-0.25d0) * v)) / (((v + (-1.0d0)) / (r * w)) / (r * w))))
end function
public static double code(double v, double w, double r) {
	return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / (((v + -1.0) / (r * w)) / (r * w))));
}
def code(v, w, r):
	return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / (((v + -1.0) / (r * w)) / (r * w))))
function code(v, w, r)
	return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(Float64(0.375 + Float64(-0.25 * v)) / Float64(Float64(Float64(v + -1.0) / Float64(r * w)) / Float64(r * w)))))
end
function tmp = code(v, w, r)
	tmp = (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / (((v + -1.0) / (r * w)) / (r * w))));
end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(N[(0.375 + N[(-0.25 * v), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(v + -1.0), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + -0.25 \cdot v}{\frac{\frac{v + -1}{r \cdot w}}{r \cdot w}}\right)
\end{array}
Derivation
  1. Initial program 84.9%

    \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
  2. Simplified89.3%

    \[\leadsto \color{blue}{\frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{1 - v}\right)\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. associate-*r/90.1%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \left(r \cdot \color{blue}{\frac{\left(w \cdot w\right) \cdot r}{1 - v}}\right)\right) \]
    2. *-commutative90.1%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \left(r \cdot \frac{\color{blue}{r \cdot \left(w \cdot w\right)}}{1 - v}\right)\right) \]
    3. associate-/l*90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \color{blue}{\frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{1 - v}}\right) \]
    4. clear-num90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \color{blue}{\frac{1}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}\right) \]
    5. un-div-inv90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\frac{0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}\right) \]
    6. fma-undefine90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{0.125 \cdot \color{blue}{\left(v \cdot -2 + 3\right)}}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    7. *-commutative90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{0.125 \cdot \left(\color{blue}{-2 \cdot v} + 3\right)}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    8. distribute-lft-in90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{\color{blue}{0.125 \cdot \left(-2 \cdot v\right) + 0.125 \cdot 3}}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    9. metadata-eval90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{0.125 \cdot \left(-2 \cdot v\right) + \color{blue}{0.375}}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    10. associate-*r*90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{\color{blue}{\left(0.125 \cdot -2\right) \cdot v} + 0.375}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    11. metadata-eval90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{\color{blue}{-0.25} \cdot v + 0.375}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    12. associate-*r*83.7%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}\right) \]
    13. pow283.7%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{{r}^{2}} \cdot \left(w \cdot w\right)}}\right) \]
    14. pow283.7%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{{r}^{2} \cdot \color{blue}{{w}^{2}}}}\right) \]
    15. pow-prod-down99.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{{\left(r \cdot w\right)}^{2}}}}\right) \]
  5. Applied egg-rr99.8%

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{{\left(r \cdot w\right)}^{2}}}}\right) \]
  6. Step-by-step derivation
    1. unpow299.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}}\right) \]
  7. Applied egg-rr99.8%

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}}\right) \]
  8. Step-by-step derivation
    1. *-un-lft-identity99.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{\color{blue}{1 \cdot \left(1 - v\right)}}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right) \]
    2. times-frac99.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\color{blue}{\frac{1}{r \cdot w} \cdot \frac{1 - v}{r \cdot w}}}\right) \]
  9. Applied egg-rr99.8%

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\color{blue}{\frac{1}{r \cdot w} \cdot \frac{1 - v}{r \cdot w}}}\right) \]
  10. Step-by-step derivation
    1. associate-*l/99.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\color{blue}{\frac{1 \cdot \frac{1 - v}{r \cdot w}}{r \cdot w}}}\right) \]
    2. *-un-lft-identity99.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{\color{blue}{\frac{1 - v}{r \cdot w}}}{r \cdot w}}\right) \]
  11. Applied egg-rr99.8%

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\color{blue}{\frac{\frac{1 - v}{r \cdot w}}{r \cdot w}}}\right) \]
  12. Final simplification99.8%

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + -0.25 \cdot v}{\frac{\frac{v + -1}{r \cdot w}}{r \cdot w}}\right) \]
  13. Add Preprocessing

Alternative 2: 93.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{r \cdot r}\\ \mathbf{if}\;v \leq -175 \lor \neg \left(v \leq 1.5\right):\\ \;\;\;\;t\_0 + \left(-1.5 + \left(-0.25 \cdot v\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right)\right)\\ \end{array} \end{array} \]
(FPCore (v w r)
 :precision binary64
 (let* ((t_0 (/ 2.0 (* r r))))
   (if (or (<= v -175.0) (not (<= v 1.5)))
     (+ t_0 (+ -1.5 (* (* -0.25 v) (/ (* r (* r (* w w))) (+ v -1.0)))))
     (+ t_0 (- -1.5 (* 0.375 (* (* r w) (/ (* r w) (- 1.0 v)))))))))
double code(double v, double w, double r) {
	double t_0 = 2.0 / (r * r);
	double tmp;
	if ((v <= -175.0) || !(v <= 1.5)) {
		tmp = t_0 + (-1.5 + ((-0.25 * v) * ((r * (r * (w * w))) / (v + -1.0))));
	} else {
		tmp = t_0 + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))));
	}
	return tmp;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 2.0d0 / (r * r)
    if ((v <= (-175.0d0)) .or. (.not. (v <= 1.5d0))) then
        tmp = t_0 + ((-1.5d0) + (((-0.25d0) * v) * ((r * (r * (w * w))) / (v + (-1.0d0)))))
    else
        tmp = t_0 + ((-1.5d0) - (0.375d0 * ((r * w) * ((r * w) / (1.0d0 - v)))))
    end if
    code = tmp
end function
public static double code(double v, double w, double r) {
	double t_0 = 2.0 / (r * r);
	double tmp;
	if ((v <= -175.0) || !(v <= 1.5)) {
		tmp = t_0 + (-1.5 + ((-0.25 * v) * ((r * (r * (w * w))) / (v + -1.0))));
	} else {
		tmp = t_0 + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))));
	}
	return tmp;
}
def code(v, w, r):
	t_0 = 2.0 / (r * r)
	tmp = 0
	if (v <= -175.0) or not (v <= 1.5):
		tmp = t_0 + (-1.5 + ((-0.25 * v) * ((r * (r * (w * w))) / (v + -1.0))))
	else:
		tmp = t_0 + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))))
	return tmp
function code(v, w, r)
	t_0 = Float64(2.0 / Float64(r * r))
	tmp = 0.0
	if ((v <= -175.0) || !(v <= 1.5))
		tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(-0.25 * v) * Float64(Float64(r * Float64(r * Float64(w * w))) / Float64(v + -1.0)))));
	else
		tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(1.0 - v))))));
	end
	return tmp
end
function tmp_2 = code(v, w, r)
	t_0 = 2.0 / (r * r);
	tmp = 0.0;
	if ((v <= -175.0) || ~((v <= 1.5)))
		tmp = t_0 + (-1.5 + ((-0.25 * v) * ((r * (r * (w * w))) / (v + -1.0))));
	else
		tmp = t_0 + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))));
	end
	tmp_2 = tmp;
end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -175.0], N[Not[LessEqual[v, 1.5]], $MachinePrecision]], N[(t$95$0 + N[(-1.5 + N[(N[(-0.25 * v), $MachinePrecision] * N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -175 \lor \neg \left(v \leq 1.5\right):\\
\;\;\;\;t\_0 + \left(-1.5 + \left(-0.25 \cdot v\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if v < -175 or 1.5 < v

    1. Initial program 79.9%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Simplified90.4%

      \[\leadsto \color{blue}{\frac{2}{r \cdot r} + \left(\left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in v around inf 89.9%

      \[\leadsto \frac{2}{r \cdot r} + \left(\color{blue}{\left(-0.25 \cdot v\right)} \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right) \]
    5. Step-by-step derivation
      1. *-commutative89.9%

        \[\leadsto \frac{2}{r \cdot r} + \left(\color{blue}{\left(v \cdot -0.25\right)} \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right) \]
    6. Simplified89.9%

      \[\leadsto \frac{2}{r \cdot r} + \left(\color{blue}{\left(v \cdot -0.25\right)} \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right) \]

    if -175 < v < 1.5

    1. Initial program 90.2%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Simplified90.3%

      \[\leadsto \color{blue}{\frac{2}{r \cdot r} + \left(\left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in v around 0 90.0%

      \[\leadsto \frac{2}{r \cdot r} + \left(\color{blue}{0.375} \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right) \]
    5. Step-by-step derivation
      1. add-sqr-sqrt90.0%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \frac{\color{blue}{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}{v + -1} + -1.5\right) \]
      2. *-un-lft-identity90.0%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{\color{blue}{1 \cdot \left(v + -1\right)}} + -1.5\right) \]
      3. times-frac90.0%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \color{blue}{\left(\frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right)} + -1.5\right) \]
      4. associate-*r*85.1%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      5. sqrt-prod85.1%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      6. sqrt-prod48.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      7. add-sqr-sqrt79.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      8. sqrt-prod46.4%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      9. add-sqr-sqrt79.4%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot \color{blue}{w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      10. associate-*r*71.3%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{v + -1}\right) + -1.5\right) \]
      11. sqrt-prod71.3%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{v + -1}\right) + -1.5\right) \]
      12. sqrt-prod42.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{v + -1}\right) + -1.5\right) \]
      13. add-sqr-sqrt78.3%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{v + -1}\right) + -1.5\right) \]
      14. sqrt-prod55.8%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{v + -1}\right) + -1.5\right) \]
      15. add-sqr-sqrt99.6%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{w}}{v + -1}\right) + -1.5\right) \]
    6. Applied egg-rr99.6%

      \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \color{blue}{\left(\frac{r \cdot w}{1} \cdot \frac{r \cdot w}{v + -1}\right)} + -1.5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification94.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq -175 \lor \neg \left(v \leq 1.5\right):\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + \left(-0.25 \cdot v\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 89.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;r \leq 3400:\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v + -1}\right) - 4.5\right)\\ \end{array} \end{array} \]
(FPCore (v w r)
 :precision binary64
 (if (<= r 3400.0)
   (+ (/ 2.0 (* r r)) (- -1.5 (* 0.375 (* (* r w) (/ (* r w) (- 1.0 v))))))
   (+
    3.0
    (-
     (* (* 0.125 (+ 3.0 (* v -2.0))) (* (* r w) (/ (* r w) (+ v -1.0))))
     4.5))))
double code(double v, double w, double r) {
	double tmp;
	if (r <= 3400.0) {
		tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))));
	} else {
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / (v + -1.0)))) - 4.5);
	}
	return tmp;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    real(8) :: tmp
    if (r <= 3400.0d0) then
        tmp = (2.0d0 / (r * r)) + ((-1.5d0) - (0.375d0 * ((r * w) * ((r * w) / (1.0d0 - v)))))
    else
        tmp = 3.0d0 + (((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * w) * ((r * w) / (v + (-1.0d0))))) - 4.5d0)
    end if
    code = tmp
end function
public static double code(double v, double w, double r) {
	double tmp;
	if (r <= 3400.0) {
		tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))));
	} else {
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / (v + -1.0)))) - 4.5);
	}
	return tmp;
}
def code(v, w, r):
	tmp = 0
	if r <= 3400.0:
		tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))))
	else:
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / (v + -1.0)))) - 4.5)
	return tmp
function code(v, w, r)
	tmp = 0.0
	if (r <= 3400.0)
		tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(1.0 - v))))));
	else
		tmp = Float64(3.0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(v + -1.0)))) - 4.5));
	end
	return tmp
end
function tmp_2 = code(v, w, r)
	tmp = 0.0;
	if (r <= 3400.0)
		tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))));
	else
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / (v + -1.0)))) - 4.5);
	end
	tmp_2 = tmp;
end
code[v_, w_, r_] := If[LessEqual[r, 3400.0], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(0.375 * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 + N[(N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;r \leq 3400:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v + -1}\right) - 4.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if r < 3400

    1. Initial program 84.0%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Simplified89.3%

      \[\leadsto \color{blue}{\frac{2}{r \cdot r} + \left(\left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in v around 0 77.7%

      \[\leadsto \frac{2}{r \cdot r} + \left(\color{blue}{0.375} \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right) \]
    5. Step-by-step derivation
      1. add-sqr-sqrt77.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \frac{\color{blue}{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}{v + -1} + -1.5\right) \]
      2. *-un-lft-identity77.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{\color{blue}{1 \cdot \left(v + -1\right)}} + -1.5\right) \]
      3. times-frac77.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \color{blue}{\left(\frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right)} + -1.5\right) \]
      4. associate-*r*75.1%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      5. sqrt-prod75.1%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      6. sqrt-prod32.8%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      7. add-sqr-sqrt71.2%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      8. sqrt-prod43.2%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      9. add-sqr-sqrt76.2%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot \color{blue}{w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      10. associate-*r*71.0%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{v + -1}\right) + -1.5\right) \]
      11. sqrt-prod69.5%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{v + -1}\right) + -1.5\right) \]
      12. sqrt-prod33.3%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{v + -1}\right) + -1.5\right) \]
      13. add-sqr-sqrt73.6%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{v + -1}\right) + -1.5\right) \]
      14. sqrt-prod48.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{v + -1}\right) + -1.5\right) \]
      15. add-sqr-sqrt85.3%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{w}}{v + -1}\right) + -1.5\right) \]
    6. Applied egg-rr85.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \color{blue}{\left(\frac{r \cdot w}{1} \cdot \frac{r \cdot w}{v + -1}\right)} + -1.5\right) \]

    if 3400 < r

    1. Initial program 87.6%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Step-by-step derivation
      1. associate--l-87.6%

        \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} + 4.5\right)} \]
      2. associate-*l*71.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \color{blue}{\left(\left(w \cdot w\right) \cdot \left(r \cdot r\right)\right)}}{1 - v} + 4.5\right) \]
      3. sqr-neg71.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{\left(\left(-r\right) \cdot \left(-r\right)\right)}\right)}{1 - v} + 4.5\right) \]
      4. associate-*l*87.6%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \color{blue}{\left(\left(\left(w \cdot w\right) \cdot \left(-r\right)\right) \cdot \left(-r\right)\right)}}{1 - v} + 4.5\right) \]
      5. associate-/l*93.7%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\color{blue}{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \frac{\left(\left(w \cdot w\right) \cdot \left(-r\right)\right) \cdot \left(-r\right)}{1 - v}} + 4.5\right) \]
      6. fma-define93.7%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{\mathsf{fma}\left(0.125 \cdot \left(3 - 2 \cdot v\right), \frac{\left(\left(w \cdot w\right) \cdot \left(-r\right)\right) \cdot \left(-r\right)}{1 - v}, 4.5\right)} \]
    3. Simplified93.7%

      \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{1 - v} + 4.5\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt93.7%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{\color{blue}{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}{1 - v} + 4.5\right) \]
      2. *-un-lft-identity93.7%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{\color{blue}{1 \cdot \left(1 - v\right)}} + 4.5\right) \]
      3. times-frac93.6%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \color{blue}{\left(\frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right)} + 4.5\right) \]
      4. associate-*r*77.2%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      5. sqrt-prod77.2%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      6. sqrt-prod93.6%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      7. add-sqr-sqrt93.7%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      8. sqrt-prod50.9%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      9. add-sqr-sqrt65.2%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot \color{blue}{w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      10. associate-*r*50.2%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{1 - v}\right) + 4.5\right) \]
      11. sqrt-prod50.2%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{1 - v}\right) + 4.5\right) \]
      12. sqrt-prod65.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{1 - v}\right) + 4.5\right) \]
      13. add-sqr-sqrt65.2%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{1 - v}\right) + 4.5\right) \]
      14. sqrt-prod53.9%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{1 - v}\right) + 4.5\right) \]
      15. add-sqr-sqrt99.7%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{w}}{1 - v}\right) + 4.5\right) \]
    6. Applied egg-rr99.7%

      \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \color{blue}{\left(\frac{r \cdot w}{1} \cdot \frac{r \cdot w}{1 - v}\right)} + 4.5\right) \]
    7. Taylor expanded in r around inf 99.7%

      \[\leadsto \color{blue}{3} - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
    8. Step-by-step derivation
      1. /-rgt-identity99.7%

        \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\color{blue}{\left(r \cdot w\right)} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
      2. *-commutative99.7%

        \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\color{blue}{\left(w \cdot r\right)} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
    9. Applied egg-rr99.7%

      \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\color{blue}{\left(w \cdot r\right)} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;r \leq 3400:\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v + -1}\right) - 4.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 83.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq 1.82 \cdot 10^{+21}:\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v}\right) - 4.5\right)\\ \end{array} \end{array} \]
(FPCore (v w r)
 :precision binary64
 (if (<= v 1.82e+21)
   (+ (/ 2.0 (* r r)) (- -1.5 (* 0.375 (* (* r w) (/ (* r w) (- 1.0 v))))))
   (+ 3.0 (- (* (* 0.125 (+ 3.0 (* v -2.0))) (* (* r w) (/ (* r w) v))) 4.5))))
double code(double v, double w, double r) {
	double tmp;
	if (v <= 1.82e+21) {
		tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))));
	} else {
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / v))) - 4.5);
	}
	return tmp;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    real(8) :: tmp
    if (v <= 1.82d+21) then
        tmp = (2.0d0 / (r * r)) + ((-1.5d0) - (0.375d0 * ((r * w) * ((r * w) / (1.0d0 - v)))))
    else
        tmp = 3.0d0 + (((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * w) * ((r * w) / v))) - 4.5d0)
    end if
    code = tmp
end function
public static double code(double v, double w, double r) {
	double tmp;
	if (v <= 1.82e+21) {
		tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))));
	} else {
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / v))) - 4.5);
	}
	return tmp;
}
def code(v, w, r):
	tmp = 0
	if v <= 1.82e+21:
		tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))))
	else:
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / v))) - 4.5)
	return tmp
function code(v, w, r)
	tmp = 0.0
	if (v <= 1.82e+21)
		tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(1.0 - v))))));
	else
		tmp = Float64(3.0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(Float64(r * w) * Float64(Float64(r * w) / v))) - 4.5));
	end
	return tmp
end
function tmp_2 = code(v, w, r)
	tmp = 0.0;
	if (v <= 1.82e+21)
		tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * ((r * w) / (1.0 - v)))));
	else
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / v))) - 4.5);
	end
	tmp_2 = tmp;
end
code[v_, w_, r_] := If[LessEqual[v, 1.82e+21], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(0.375 * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 + N[(N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;v \leq 1.82 \cdot 10^{+21}:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v}\right) - 4.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if v < 1.82e21

    1. Initial program 87.5%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Simplified91.3%

      \[\leadsto \color{blue}{\frac{2}{r \cdot r} + \left(\left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in v around 0 85.4%

      \[\leadsto \frac{2}{r \cdot r} + \left(\color{blue}{0.375} \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right) \]
    5. Step-by-step derivation
      1. add-sqr-sqrt85.4%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \frac{\color{blue}{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}{v + -1} + -1.5\right) \]
      2. *-un-lft-identity85.4%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{\color{blue}{1 \cdot \left(v + -1\right)}} + -1.5\right) \]
      3. times-frac85.4%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \color{blue}{\left(\frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right)} + -1.5\right) \]
      4. associate-*r*80.8%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      5. sqrt-prod80.8%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      6. sqrt-prod45.0%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      7. add-sqr-sqrt74.8%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      8. sqrt-prod42.0%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      9. add-sqr-sqrt75.0%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot \color{blue}{w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{v + -1}\right) + -1.5\right) \]
      10. associate-*r*67.3%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{v + -1}\right) + -1.5\right) \]
      11. sqrt-prod67.3%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{v + -1}\right) + -1.5\right) \]
      12. sqrt-prod38.6%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{v + -1}\right) + -1.5\right) \]
      13. add-sqr-sqrt73.5%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{v + -1}\right) + -1.5\right) \]
      14. sqrt-prod50.1%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{v + -1}\right) + -1.5\right) \]
      15. add-sqr-sqrt91.5%

        \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{w}}{v + -1}\right) + -1.5\right) \]
    6. Applied egg-rr91.5%

      \[\leadsto \frac{2}{r \cdot r} + \left(0.375 \cdot \color{blue}{\left(\frac{r \cdot w}{1} \cdot \frac{r \cdot w}{v + -1}\right)} + -1.5\right) \]

    if 1.82e21 < v

    1. Initial program 76.2%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Step-by-step derivation
      1. associate--l-76.2%

        \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} + 4.5\right)} \]
      2. associate-*l*69.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \color{blue}{\left(\left(w \cdot w\right) \cdot \left(r \cdot r\right)\right)}}{1 - v} + 4.5\right) \]
      3. sqr-neg69.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{\left(\left(-r\right) \cdot \left(-r\right)\right)}\right)}{1 - v} + 4.5\right) \]
      4. associate-*l*76.2%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \color{blue}{\left(\left(\left(w \cdot w\right) \cdot \left(-r\right)\right) \cdot \left(-r\right)\right)}}{1 - v} + 4.5\right) \]
      5. associate-/l*87.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\color{blue}{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \frac{\left(\left(w \cdot w\right) \cdot \left(-r\right)\right) \cdot \left(-r\right)}{1 - v}} + 4.5\right) \]
      6. fma-define87.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{\mathsf{fma}\left(0.125 \cdot \left(3 - 2 \cdot v\right), \frac{\left(\left(w \cdot w\right) \cdot \left(-r\right)\right) \cdot \left(-r\right)}{1 - v}, 4.5\right)} \]
    3. Simplified87.1%

      \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{1 - v} + 4.5\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt87.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{\color{blue}{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}{1 - v} + 4.5\right) \]
      2. *-un-lft-identity87.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{\color{blue}{1 \cdot \left(1 - v\right)}} + 4.5\right) \]
      3. times-frac87.0%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \color{blue}{\left(\frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right)} + 4.5\right) \]
      4. associate-*r*78.4%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      5. sqrt-prod78.5%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      6. sqrt-prod48.6%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      7. add-sqr-sqrt62.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      8. sqrt-prod41.8%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      9. add-sqr-sqrt67.3%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot \color{blue}{w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      10. associate-*r*58.5%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{1 - v}\right) + 4.5\right) \]
      11. sqrt-prod58.5%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{1 - v}\right) + 4.5\right) \]
      12. sqrt-prod42.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{1 - v}\right) + 4.5\right) \]
      13. add-sqr-sqrt68.9%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{1 - v}\right) + 4.5\right) \]
      14. sqrt-prod59.9%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{1 - v}\right) + 4.5\right) \]
      15. add-sqr-sqrt99.7%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{w}}{1 - v}\right) + 4.5\right) \]
    6. Applied egg-rr99.7%

      \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \color{blue}{\left(\frac{r \cdot w}{1} \cdot \frac{r \cdot w}{1 - v}\right)} + 4.5\right) \]
    7. Taylor expanded in r around inf 71.7%

      \[\leadsto \color{blue}{3} - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
    8. Step-by-step derivation
      1. /-rgt-identity71.7%

        \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\color{blue}{\left(r \cdot w\right)} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
      2. *-commutative71.7%

        \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\color{blue}{\left(w \cdot r\right)} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
    9. Applied egg-rr71.7%

      \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\color{blue}{\left(w \cdot r\right)} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
    10. Taylor expanded in v around inf 71.7%

      \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(w \cdot r\right) \cdot \color{blue}{\left(-1 \cdot \frac{r \cdot w}{v}\right)}\right) + 4.5\right) \]
    11. Step-by-step derivation
      1. mul-1-neg71.7%

        \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(w \cdot r\right) \cdot \color{blue}{\left(-\frac{r \cdot w}{v}\right)}\right) + 4.5\right) \]
    12. Simplified71.7%

      \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(w \cdot r\right) \cdot \color{blue}{\left(-\frac{r \cdot w}{v}\right)}\right) + 4.5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq 1.82 \cdot 10^{+21}:\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v}\right) - 4.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 77.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq 5.8 \cdot 10^{+15}:\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + 0.375 \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v}\right) - 4.5\right)\\ \end{array} \end{array} \]
(FPCore (v w r)
 :precision binary64
 (if (<= v 5.8e+15)
   (+ (/ 2.0 (* r r)) (+ -1.5 (* 0.375 (/ (* r (* r (* w w))) (+ v -1.0)))))
   (+ 3.0 (- (* (* 0.125 (+ 3.0 (* v -2.0))) (* (* r w) (/ (* r w) v))) 4.5))))
double code(double v, double w, double r) {
	double tmp;
	if (v <= 5.8e+15) {
		tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * ((r * (r * (w * w))) / (v + -1.0))));
	} else {
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / v))) - 4.5);
	}
	return tmp;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    real(8) :: tmp
    if (v <= 5.8d+15) then
        tmp = (2.0d0 / (r * r)) + ((-1.5d0) + (0.375d0 * ((r * (r * (w * w))) / (v + (-1.0d0)))))
    else
        tmp = 3.0d0 + (((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * w) * ((r * w) / v))) - 4.5d0)
    end if
    code = tmp
end function
public static double code(double v, double w, double r) {
	double tmp;
	if (v <= 5.8e+15) {
		tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * ((r * (r * (w * w))) / (v + -1.0))));
	} else {
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / v))) - 4.5);
	}
	return tmp;
}
def code(v, w, r):
	tmp = 0
	if v <= 5.8e+15:
		tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * ((r * (r * (w * w))) / (v + -1.0))))
	else:
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / v))) - 4.5)
	return tmp
function code(v, w, r)
	tmp = 0.0
	if (v <= 5.8e+15)
		tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(0.375 * Float64(Float64(r * Float64(r * Float64(w * w))) / Float64(v + -1.0)))));
	else
		tmp = Float64(3.0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(Float64(r * w) * Float64(Float64(r * w) / v))) - 4.5));
	end
	return tmp
end
function tmp_2 = code(v, w, r)
	tmp = 0.0;
	if (v <= 5.8e+15)
		tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * ((r * (r * (w * w))) / (v + -1.0))));
	else
		tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * ((r * w) / v))) - 4.5);
	end
	tmp_2 = tmp;
end
code[v_, w_, r_] := If[LessEqual[v, 5.8e+15], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(0.375 * N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 + N[(N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;v \leq 5.8 \cdot 10^{+15}:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + 0.375 \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\

\mathbf{else}:\\
\;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v}\right) - 4.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if v < 5.8e15

    1. Initial program 87.5%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Simplified91.3%

      \[\leadsto \color{blue}{\frac{2}{r \cdot r} + \left(\left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in v around 0 85.4%

      \[\leadsto \frac{2}{r \cdot r} + \left(\color{blue}{0.375} \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right) \]

    if 5.8e15 < v

    1. Initial program 76.2%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Step-by-step derivation
      1. associate--l-76.2%

        \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} + 4.5\right)} \]
      2. associate-*l*69.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \color{blue}{\left(\left(w \cdot w\right) \cdot \left(r \cdot r\right)\right)}}{1 - v} + 4.5\right) \]
      3. sqr-neg69.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{\left(\left(-r\right) \cdot \left(-r\right)\right)}\right)}{1 - v} + 4.5\right) \]
      4. associate-*l*76.2%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \color{blue}{\left(\left(\left(w \cdot w\right) \cdot \left(-r\right)\right) \cdot \left(-r\right)\right)}}{1 - v} + 4.5\right) \]
      5. associate-/l*87.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\color{blue}{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \frac{\left(\left(w \cdot w\right) \cdot \left(-r\right)\right) \cdot \left(-r\right)}{1 - v}} + 4.5\right) \]
      6. fma-define87.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{\mathsf{fma}\left(0.125 \cdot \left(3 - 2 \cdot v\right), \frac{\left(\left(w \cdot w\right) \cdot \left(-r\right)\right) \cdot \left(-r\right)}{1 - v}, 4.5\right)} \]
    3. Simplified87.1%

      \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{1 - v} + 4.5\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt87.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{\color{blue}{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}{1 - v} + 4.5\right) \]
      2. *-un-lft-identity87.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)} \cdot \sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{\color{blue}{1 \cdot \left(1 - v\right)}} + 4.5\right) \]
      3. times-frac87.0%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \color{blue}{\left(\frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right)} + 4.5\right) \]
      4. associate-*r*78.4%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      5. sqrt-prod78.5%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      6. sqrt-prod48.6%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      7. add-sqr-sqrt62.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      8. sqrt-prod41.8%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      9. add-sqr-sqrt67.3%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot \color{blue}{w}}{1} \cdot \frac{\sqrt{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}{1 - v}\right) + 4.5\right) \]
      10. associate-*r*58.5%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\sqrt{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}{1 - v}\right) + 4.5\right) \]
      11. sqrt-prod58.5%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\sqrt{r \cdot r} \cdot \sqrt{w \cdot w}}}{1 - v}\right) + 4.5\right) \]
      12. sqrt-prod42.1%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{\left(\sqrt{r} \cdot \sqrt{r}\right)} \cdot \sqrt{w \cdot w}}{1 - v}\right) + 4.5\right) \]
      13. add-sqr-sqrt68.9%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{\color{blue}{r} \cdot \sqrt{w \cdot w}}{1 - v}\right) + 4.5\right) \]
      14. sqrt-prod59.9%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{\left(\sqrt{w} \cdot \sqrt{w}\right)}}{1 - v}\right) + 4.5\right) \]
      15. add-sqr-sqrt99.7%

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot \color{blue}{w}}{1 - v}\right) + 4.5\right) \]
    6. Applied egg-rr99.7%

      \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \color{blue}{\left(\frac{r \cdot w}{1} \cdot \frac{r \cdot w}{1 - v}\right)} + 4.5\right) \]
    7. Taylor expanded in r around inf 71.7%

      \[\leadsto \color{blue}{3} - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\frac{r \cdot w}{1} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
    8. Step-by-step derivation
      1. /-rgt-identity71.7%

        \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\color{blue}{\left(r \cdot w\right)} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
      2. *-commutative71.7%

        \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\color{blue}{\left(w \cdot r\right)} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
    9. Applied egg-rr71.7%

      \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\color{blue}{\left(w \cdot r\right)} \cdot \frac{r \cdot w}{1 - v}\right) + 4.5\right) \]
    10. Taylor expanded in v around inf 71.7%

      \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(w \cdot r\right) \cdot \color{blue}{\left(-1 \cdot \frac{r \cdot w}{v}\right)}\right) + 4.5\right) \]
    11. Step-by-step derivation
      1. mul-1-neg71.7%

        \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(w \cdot r\right) \cdot \color{blue}{\left(-\frac{r \cdot w}{v}\right)}\right) + 4.5\right) \]
    12. Simplified71.7%

      \[\leadsto 3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(w \cdot r\right) \cdot \color{blue}{\left(-\frac{r \cdot w}{v}\right)}\right) + 4.5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq 5.8 \cdot 10^{+15}:\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + 0.375 \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v}\right) - 4.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 68.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;r \leq 6.2 \cdot 10^{-121}:\\ \;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + 0.375 \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\ \end{array} \end{array} \]
(FPCore (v w r)
 :precision binary64
 (if (<= r 6.2e-121)
   (- (+ 3.0 (/ (/ 2.0 r) r)) 4.5)
   (+ (/ 2.0 (* r r)) (+ -1.5 (* 0.375 (/ (* r (* r (* w w))) (+ v -1.0)))))))
double code(double v, double w, double r) {
	double tmp;
	if (r <= 6.2e-121) {
		tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
	} else {
		tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * ((r * (r * (w * w))) / (v + -1.0))));
	}
	return tmp;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    real(8) :: tmp
    if (r <= 6.2d-121) then
        tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
    else
        tmp = (2.0d0 / (r * r)) + ((-1.5d0) + (0.375d0 * ((r * (r * (w * w))) / (v + (-1.0d0)))))
    end if
    code = tmp
end function
public static double code(double v, double w, double r) {
	double tmp;
	if (r <= 6.2e-121) {
		tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
	} else {
		tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * ((r * (r * (w * w))) / (v + -1.0))));
	}
	return tmp;
}
def code(v, w, r):
	tmp = 0
	if r <= 6.2e-121:
		tmp = (3.0 + ((2.0 / r) / r)) - 4.5
	else:
		tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * ((r * (r * (w * w))) / (v + -1.0))))
	return tmp
function code(v, w, r)
	tmp = 0.0
	if (r <= 6.2e-121)
		tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5);
	else
		tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(0.375 * Float64(Float64(r * Float64(r * Float64(w * w))) / Float64(v + -1.0)))));
	end
	return tmp
end
function tmp_2 = code(v, w, r)
	tmp = 0.0;
	if (r <= 6.2e-121)
		tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
	else
		tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * ((r * (r * (w * w))) / (v + -1.0))));
	end
	tmp_2 = tmp;
end
code[v_, w_, r_] := If[LessEqual[r, 6.2e-121], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(0.375 * N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;r \leq 6.2 \cdot 10^{-121}:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + 0.375 \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if r < 6.1999999999999997e-121

    1. Initial program 82.3%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Simplified82.9%

      \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(0.375 + 0.125 \cdot \left(v \cdot -2\right), \left(r \cdot r\right) \cdot \frac{w \cdot w}{1 - v}, 4.5\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in r around 0 68.5%

      \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{4.5} \]
    5. Step-by-step derivation
      1. associate-/r*68.5%

        \[\leadsto \left(3 + \color{blue}{\frac{\frac{2}{r}}{r}}\right) - 4.5 \]
      2. div-inv68.5%

        \[\leadsto \left(3 + \color{blue}{\frac{2}{r} \cdot \frac{1}{r}}\right) - 4.5 \]
    6. Applied egg-rr68.5%

      \[\leadsto \left(3 + \color{blue}{\frac{2}{r} \cdot \frac{1}{r}}\right) - 4.5 \]
    7. Step-by-step derivation
      1. associate-*r/68.5%

        \[\leadsto \left(3 + \color{blue}{\frac{\frac{2}{r} \cdot 1}{r}}\right) - 4.5 \]
      2. *-rgt-identity68.5%

        \[\leadsto \left(3 + \frac{\color{blue}{\frac{2}{r}}}{r}\right) - 4.5 \]
    8. Simplified68.5%

      \[\leadsto \left(3 + \color{blue}{\frac{\frac{2}{r}}{r}}\right) - 4.5 \]

    if 6.1999999999999997e-121 < r

    1. Initial program 89.5%

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Simplified93.6%

      \[\leadsto \color{blue}{\frac{2}{r \cdot r} + \left(\left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in v around 0 74.7%

      \[\leadsto \frac{2}{r \cdot r} + \left(\color{blue}{0.375} \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1} + -1.5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;r \leq 6.2 \cdot 10^{-121}:\\ \;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + 0.375 \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 99.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + -0.25 \cdot v}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right) \end{array} \]
(FPCore (v w r)
 :precision binary64
 (+
  (/ 2.0 (* r r))
  (+ -1.5 (/ (+ 0.375 (* -0.25 v)) (/ (+ v -1.0) (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
	return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((v + -1.0) / ((r * w) * (r * w)))));
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    code = (2.0d0 / (r * r)) + ((-1.5d0) + ((0.375d0 + ((-0.25d0) * v)) / ((v + (-1.0d0)) / ((r * w) * (r * w)))))
end function
public static double code(double v, double w, double r) {
	return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((v + -1.0) / ((r * w) * (r * w)))));
}
def code(v, w, r):
	return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((v + -1.0) / ((r * w) * (r * w)))))
function code(v, w, r)
	return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(Float64(0.375 + Float64(-0.25 * v)) / Float64(Float64(v + -1.0) / Float64(Float64(r * w) * Float64(r * w))))))
end
function tmp = code(v, w, r)
	tmp = (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((v + -1.0) / ((r * w) * (r * w)))));
end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(N[(0.375 + N[(-0.25 * v), $MachinePrecision]), $MachinePrecision] / N[(N[(v + -1.0), $MachinePrecision] / N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + -0.25 \cdot v}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right)
\end{array}
Derivation
  1. Initial program 84.9%

    \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
  2. Simplified89.3%

    \[\leadsto \color{blue}{\frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{1 - v}\right)\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. associate-*r/90.1%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \left(r \cdot \color{blue}{\frac{\left(w \cdot w\right) \cdot r}{1 - v}}\right)\right) \]
    2. *-commutative90.1%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \left(r \cdot \frac{\color{blue}{r \cdot \left(w \cdot w\right)}}{1 - v}\right)\right) \]
    3. associate-/l*90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \color{blue}{\frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{1 - v}}\right) \]
    4. clear-num90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\right) \cdot \color{blue}{\frac{1}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}\right) \]
    5. un-div-inv90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\frac{0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}\right) \]
    6. fma-undefine90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{0.125 \cdot \color{blue}{\left(v \cdot -2 + 3\right)}}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    7. *-commutative90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{0.125 \cdot \left(\color{blue}{-2 \cdot v} + 3\right)}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    8. distribute-lft-in90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{\color{blue}{0.125 \cdot \left(-2 \cdot v\right) + 0.125 \cdot 3}}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    9. metadata-eval90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{0.125 \cdot \left(-2 \cdot v\right) + \color{blue}{0.375}}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    10. associate-*r*90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{\color{blue}{\left(0.125 \cdot -2\right) \cdot v} + 0.375}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    11. metadata-eval90.3%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{\color{blue}{-0.25} \cdot v + 0.375}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}\right) \]
    12. associate-*r*83.7%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{\left(r \cdot r\right) \cdot \left(w \cdot w\right)}}}\right) \]
    13. pow283.7%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{{r}^{2}} \cdot \left(w \cdot w\right)}}\right) \]
    14. pow283.7%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{{r}^{2} \cdot \color{blue}{{w}^{2}}}}\right) \]
    15. pow-prod-down99.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{{\left(r \cdot w\right)}^{2}}}}\right) \]
  5. Applied egg-rr99.8%

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{{\left(r \cdot w\right)}^{2}}}}\right) \]
  6. Step-by-step derivation
    1. unpow299.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}}\right) \]
  7. Applied egg-rr99.8%

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{-0.25 \cdot v + 0.375}{\frac{1 - v}{\color{blue}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}}\right) \]
  8. Final simplification99.8%

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + -0.25 \cdot v}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right) \]
  9. Add Preprocessing

Alternative 8: 56.6% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \left(\frac{2}{r \cdot r} + 3\right) - 4.5 \end{array} \]
(FPCore (v w r) :precision binary64 (- (+ (/ 2.0 (* r r)) 3.0) 4.5))
double code(double v, double w, double r) {
	return ((2.0 / (r * r)) + 3.0) - 4.5;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    code = ((2.0d0 / (r * r)) + 3.0d0) - 4.5d0
end function
public static double code(double v, double w, double r) {
	return ((2.0 / (r * r)) + 3.0) - 4.5;
}
def code(v, w, r):
	return ((2.0 / (r * r)) + 3.0) - 4.5
function code(v, w, r)
	return Float64(Float64(Float64(2.0 / Float64(r * r)) + 3.0) - 4.5)
end
function tmp = code(v, w, r)
	tmp = ((2.0 / (r * r)) + 3.0) - 4.5;
end
code[v_, w_, r_] := N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{2}{r \cdot r} + 3\right) - 4.5
\end{array}
Derivation
  1. Initial program 84.9%

    \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
  2. Simplified81.3%

    \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(0.375 + 0.125 \cdot \left(v \cdot -2\right), \left(r \cdot r\right) \cdot \frac{w \cdot w}{1 - v}, 4.5\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in r around 0 60.3%

    \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{4.5} \]
  5. Final simplification60.3%

    \[\leadsto \left(\frac{2}{r \cdot r} + 3\right) - 4.5 \]
  6. Add Preprocessing

Alternative 9: 14.4% accurate, 29.0× speedup?

\[\begin{array}{l} \\ -1.5 \end{array} \]
(FPCore (v w r) :precision binary64 -1.5)
double code(double v, double w, double r) {
	return -1.5;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    code = -1.5d0
end function
public static double code(double v, double w, double r) {
	return -1.5;
}
def code(v, w, r):
	return -1.5
function code(v, w, r)
	return -1.5
end
function tmp = code(v, w, r)
	tmp = -1.5;
end
code[v_, w_, r_] := -1.5
\begin{array}{l}

\\
-1.5
\end{array}
Derivation
  1. Initial program 84.9%

    \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
  2. Simplified81.3%

    \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(0.375 + 0.125 \cdot \left(v \cdot -2\right), \left(r \cdot r\right) \cdot \frac{w \cdot w}{1 - v}, 4.5\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in r around 0 60.3%

    \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{4.5} \]
  5. Taylor expanded in r around inf 19.7%

    \[\leadsto \color{blue}{-1.5} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2024177 
(FPCore (v w r)
  :name "Rosa's TurbineBenchmark"
  :precision binary64
  (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))