Rosa's TurbineBenchmark

Percentage Accurate: 85.0% → 99.1%
Time: 14.3s
Alternatives: 8
Speedup: 1.7×

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 8 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: 85.0% 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.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(3 + \frac{2}{r \cdot r}\right) + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{w}{\frac{v + -1}{r}}\right) - 4.5\right) \end{array} \]
(FPCore (v w r)
 :precision binary64
 (+
  (+ 3.0 (/ 2.0 (* r r)))
  (- (* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (/ w (/ (+ v -1.0) r)))) 4.5)))
double code(double v, double w, double r) {
	return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w / ((v + -1.0) / r)))) - 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))) * ((r * w) * (w / ((v + (-1.0d0)) / r)))) - 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))) * ((r * w) * (w / ((v + -1.0) / r)))) - 4.5);
}
def code(v, w, r):
	return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w / ((v + -1.0) / r)))) - 4.5)
function code(v, w, r)
	return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(r * w) * Float64(w / Float64(Float64(v + -1.0) / r)))) - 4.5))
end
function tmp = code(v, w, r)
	tmp = (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w / ((v + -1.0) / r)))) - 4.5);
end
code[v_, w_, r_] := 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[(r * w), $MachinePrecision] * N[(w / N[(N[(v + -1.0), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\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-84.8%

      \[\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*79.9%

      \[\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-neg79.9%

      \[\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*84.8%

      \[\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.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-define87.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. Simplified87.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. associate-/l*87.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(r \cdot \frac{r \cdot \left(w \cdot w\right)}{1 - v}\right)} + 4.5\right) \]
    2. *-commutative87.7%

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

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

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

      \[\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(\left(r \cdot w\right) \cdot \left(w \cdot \frac{r}{1 - v}\right)\right)} + 4.5\right) \]
    6. add-sqr-sqrt48.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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(\left(w \cdot r\right) \cdot \frac{w}{\frac{1 - v}{r}}\right)} + 4.5\right) \]
  7. Final simplification99.8%

    \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{w}{\frac{v + -1}{r}}\right) - 4.5\right) \]
  8. Add Preprocessing

Alternative 2: 98.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{r \cdot r}\\ \mathbf{if}\;v \leq -1.2 \cdot 10^{+22}:\\ \;\;\;\;t\_0 + \left(-1.5 - \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot 0.25\right)\\ \mathbf{elif}\;v \leq 2.2 \cdot 10^{-17}:\\ \;\;\;\;\left(\left(3 + t\_0\right) - \frac{w}{\frac{1 - v}{r}} \cdot \left(r \cdot \left(w \cdot 0.375\right)\right)\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\ \end{array} \end{array} \]
(FPCore (v w r)
 :precision binary64
 (let* ((t_0 (/ 2.0 (* r r))))
   (if (<= v -1.2e+22)
     (+ t_0 (- -1.5 (* (* r (* w (* r w))) 0.25)))
     (if (<= v 2.2e-17)
       (- (- (+ 3.0 t_0) (* (/ w (/ (- 1.0 v) r)) (* r (* w 0.375)))) 4.5)
       (+ t_0 (- -1.5 (* (* (* r w) (* r w)) 0.25)))))))
double code(double v, double w, double r) {
	double t_0 = 2.0 / (r * r);
	double tmp;
	if (v <= -1.2e+22) {
		tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * 0.25));
	} else if (v <= 2.2e-17) {
		tmp = ((3.0 + t_0) - ((w / ((1.0 - v) / r)) * (r * (w * 0.375)))) - 4.5;
	} else {
		tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
	}
	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 <= (-1.2d+22)) then
        tmp = t_0 + ((-1.5d0) - ((r * (w * (r * w))) * 0.25d0))
    else if (v <= 2.2d-17) then
        tmp = ((3.0d0 + t_0) - ((w / ((1.0d0 - v) / r)) * (r * (w * 0.375d0)))) - 4.5d0
    else
        tmp = t_0 + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
    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 <= -1.2e+22) {
		tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * 0.25));
	} else if (v <= 2.2e-17) {
		tmp = ((3.0 + t_0) - ((w / ((1.0 - v) / r)) * (r * (w * 0.375)))) - 4.5;
	} else {
		tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
	}
	return tmp;
}
def code(v, w, r):
	t_0 = 2.0 / (r * r)
	tmp = 0
	if v <= -1.2e+22:
		tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * 0.25))
	elif v <= 2.2e-17:
		tmp = ((3.0 + t_0) - ((w / ((1.0 - v) / r)) * (r * (w * 0.375)))) - 4.5
	else:
		tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25))
	return tmp
function code(v, w, r)
	t_0 = Float64(2.0 / Float64(r * r))
	tmp = 0.0
	if (v <= -1.2e+22)
		tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(r * Float64(w * Float64(r * w))) * 0.25)));
	elseif (v <= 2.2e-17)
		tmp = Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(w / Float64(Float64(1.0 - v) / r)) * Float64(r * Float64(w * 0.375)))) - 4.5);
	else
		tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25)));
	end
	return tmp
end
function tmp_2 = code(v, w, r)
	t_0 = 2.0 / (r * r);
	tmp = 0.0;
	if (v <= -1.2e+22)
		tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * 0.25));
	elseif (v <= 2.2e-17)
		tmp = ((3.0 + t_0) - ((w / ((1.0 - v) / r)) * (r * (w * 0.375)))) - 4.5;
	else
		tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
	end
	tmp_2 = tmp;
end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1.2e+22], N[(t$95$0 + N[(-1.5 - N[(N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 2.2e-17], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(w / N[(N[(1.0 - v), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] * N[(r * N[(w * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.2 \cdot 10^{+22}:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot 0.25\right)\\

\mathbf{elif}\;v \leq 2.2 \cdot 10^{-17}:\\
\;\;\;\;\left(\left(3 + t\_0\right) - \frac{w}{\frac{1 - v}{r}} \cdot \left(r \cdot \left(w \cdot 0.375\right)\right)\right) - 4.5\\

\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if v < -1.2e22

    1. Initial program 80.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. Simplified86.2%

      \[\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. Taylor expanded in v around inf 79.9%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({r}^{2} \cdot {w}^{2}\right) \cdot 0.25}\right) \]
      2. *-commutative79.9%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({w}^{2} \cdot {r}^{2}\right)} \cdot 0.25\right) \]
      3. unpow279.9%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\color{blue}{\left(w \cdot w\right)} \cdot {r}^{2}\right) \cdot 0.25\right) \]
      4. unpow279.9%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\left(w \cdot w\right) \cdot \color{blue}{\left(r \cdot r\right)}\right) \cdot 0.25\right) \]
      5. swap-sqr99.8%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{{\left(w \cdot r\right)}^{2}} \cdot 0.25\right) \]
      7. *-commutative99.8%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - {\color{blue}{\left(r \cdot w\right)}}^{2} \cdot 0.25\right) \]
    6. Simplified99.8%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - {\color{blue}{\left(w \cdot r\right)}}^{2} \cdot 0.25\right) \]
      2. unpow299.8%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right)} \cdot 0.25\right) \]
      3. associate-*r*99.9%

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

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

    if -1.2e22 < v < 2.2e-17

    1. Initial program 85.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. Add Preprocessing
    3. Step-by-step derivation
      1. associate-/l*85.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{\left(\left(\left(0.375 + v \cdot -0.25\right) \cdot r\right) \cdot w\right) \cdot \frac{w}{\frac{1 - v}{r}}}\right) - 4.5 \]
    5. Taylor expanded in v around 0 99.8%

      \[\leadsto \left(\left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{\left(0.375 \cdot \left(r \cdot w\right)\right)} \cdot \frac{w}{\frac{1 - v}{r}}\right) - 4.5 \]
    6. Step-by-step derivation
      1. *-commutative99.8%

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

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

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

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

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

    if 2.2e-17 < v

    1. Initial program 87.8%

      \[\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. Simplified92.9%

      \[\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. Taylor expanded in v around inf 89.7%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({r}^{2} \cdot {w}^{2}\right) \cdot 0.25}\right) \]
      2. *-commutative89.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({w}^{2} \cdot {r}^{2}\right)} \cdot 0.25\right) \]
      3. unpow289.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\color{blue}{\left(w \cdot w\right)} \cdot {r}^{2}\right) \cdot 0.25\right) \]
      4. unpow289.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\left(w \cdot w\right) \cdot \color{blue}{\left(r \cdot r\right)}\right) \cdot 0.25\right) \]
      5. swap-sqr99.2%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{{\left(w \cdot r\right)}^{2}} \cdot 0.25\right) \]
      7. *-commutative99.2%

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

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - {\color{blue}{\left(w \cdot r\right)}}^{2} \cdot 0.25\right) \]
      2. unpow299.2%

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

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

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

Alternative 3: 98.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{r \cdot r}\\ \mathbf{if}\;v \leq -1.25 \cdot 10^{+21}:\\ \;\;\;\;t\_0 + \left(-1.5 - \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot 0.25\right)\\ \mathbf{elif}\;v \leq 10^{-17}:\\ \;\;\;\;\left(\left(3 + t\_0\right) + \left(\left(r \cdot w\right) \cdot 0.375\right) \cdot \frac{w}{\frac{v + -1}{r}}\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\ \end{array} \end{array} \]
(FPCore (v w r)
 :precision binary64
 (let* ((t_0 (/ 2.0 (* r r))))
   (if (<= v -1.25e+21)
     (+ t_0 (- -1.5 (* (* r (* w (* r w))) 0.25)))
     (if (<= v 1e-17)
       (- (+ (+ 3.0 t_0) (* (* (* r w) 0.375) (/ w (/ (+ v -1.0) r)))) 4.5)
       (+ t_0 (- -1.5 (* (* (* r w) (* r w)) 0.25)))))))
double code(double v, double w, double r) {
	double t_0 = 2.0 / (r * r);
	double tmp;
	if (v <= -1.25e+21) {
		tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * 0.25));
	} else if (v <= 1e-17) {
		tmp = ((3.0 + t_0) + (((r * w) * 0.375) * (w / ((v + -1.0) / r)))) - 4.5;
	} else {
		tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
	}
	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 <= (-1.25d+21)) then
        tmp = t_0 + ((-1.5d0) - ((r * (w * (r * w))) * 0.25d0))
    else if (v <= 1d-17) then
        tmp = ((3.0d0 + t_0) + (((r * w) * 0.375d0) * (w / ((v + (-1.0d0)) / r)))) - 4.5d0
    else
        tmp = t_0 + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
    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 <= -1.25e+21) {
		tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * 0.25));
	} else if (v <= 1e-17) {
		tmp = ((3.0 + t_0) + (((r * w) * 0.375) * (w / ((v + -1.0) / r)))) - 4.5;
	} else {
		tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
	}
	return tmp;
}
def code(v, w, r):
	t_0 = 2.0 / (r * r)
	tmp = 0
	if v <= -1.25e+21:
		tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * 0.25))
	elif v <= 1e-17:
		tmp = ((3.0 + t_0) + (((r * w) * 0.375) * (w / ((v + -1.0) / r)))) - 4.5
	else:
		tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25))
	return tmp
function code(v, w, r)
	t_0 = Float64(2.0 / Float64(r * r))
	tmp = 0.0
	if (v <= -1.25e+21)
		tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(r * Float64(w * Float64(r * w))) * 0.25)));
	elseif (v <= 1e-17)
		tmp = Float64(Float64(Float64(3.0 + t_0) + Float64(Float64(Float64(r * w) * 0.375) * Float64(w / Float64(Float64(v + -1.0) / r)))) - 4.5);
	else
		tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25)));
	end
	return tmp
end
function tmp_2 = code(v, w, r)
	t_0 = 2.0 / (r * r);
	tmp = 0.0;
	if (v <= -1.25e+21)
		tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * 0.25));
	elseif (v <= 1e-17)
		tmp = ((3.0 + t_0) + (((r * w) * 0.375) * (w / ((v + -1.0) / r)))) - 4.5;
	else
		tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
	end
	tmp_2 = tmp;
end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1.25e+21], N[(t$95$0 + N[(-1.5 - N[(N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 1e-17], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] + N[(N[(N[(r * w), $MachinePrecision] * 0.375), $MachinePrecision] * N[(w / N[(N[(v + -1.0), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.25 \cdot 10^{+21}:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot 0.25\right)\\

\mathbf{elif}\;v \leq 10^{-17}:\\
\;\;\;\;\left(\left(3 + t\_0\right) + \left(\left(r \cdot w\right) \cdot 0.375\right) \cdot \frac{w}{\frac{v + -1}{r}}\right) - 4.5\\

\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\


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

    1. Initial program 80.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. Simplified86.2%

      \[\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. Taylor expanded in v around inf 79.9%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({r}^{2} \cdot {w}^{2}\right) \cdot 0.25}\right) \]
      2. *-commutative79.9%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({w}^{2} \cdot {r}^{2}\right)} \cdot 0.25\right) \]
      3. unpow279.9%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\color{blue}{\left(w \cdot w\right)} \cdot {r}^{2}\right) \cdot 0.25\right) \]
      4. unpow279.9%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\left(w \cdot w\right) \cdot \color{blue}{\left(r \cdot r\right)}\right) \cdot 0.25\right) \]
      5. swap-sqr99.8%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{{\left(w \cdot r\right)}^{2}} \cdot 0.25\right) \]
      7. *-commutative99.8%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - {\color{blue}{\left(r \cdot w\right)}}^{2} \cdot 0.25\right) \]
    6. Simplified99.8%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - {\color{blue}{\left(w \cdot r\right)}}^{2} \cdot 0.25\right) \]
      2. unpow299.8%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right)} \cdot 0.25\right) \]
      3. associate-*r*99.9%

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

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

    if -1.25e21 < v < 1.00000000000000007e-17

    1. Initial program 85.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. Add Preprocessing
    3. Step-by-step derivation
      1. associate-/l*85.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{\left(\left(\left(0.375 + v \cdot -0.25\right) \cdot r\right) \cdot w\right) \cdot \frac{w}{\frac{1 - v}{r}}}\right) - 4.5 \]
    5. Taylor expanded in v around 0 99.8%

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

    if 1.00000000000000007e-17 < v

    1. Initial program 87.8%

      \[\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. Simplified92.9%

      \[\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. Taylor expanded in v around inf 89.7%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({r}^{2} \cdot {w}^{2}\right) \cdot 0.25}\right) \]
      2. *-commutative89.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({w}^{2} \cdot {r}^{2}\right)} \cdot 0.25\right) \]
      3. unpow289.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\color{blue}{\left(w \cdot w\right)} \cdot {r}^{2}\right) \cdot 0.25\right) \]
      4. unpow289.7%

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\left(w \cdot w\right) \cdot \color{blue}{\left(r \cdot r\right)}\right) \cdot 0.25\right) \]
      5. swap-sqr99.2%

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{{\left(w \cdot r\right)}^{2}} \cdot 0.25\right) \]
      7. *-commutative99.2%

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

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

        \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - {\color{blue}{\left(w \cdot r\right)}}^{2} \cdot 0.25\right) \]
      2. unpow299.2%

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

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

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

Alternative 4: 99.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + v \cdot -0.25}{\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 (* v -0.25)) (/ (+ v -1.0) (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
	return (2.0 / (r * r)) + (-1.5 + ((0.375 + (v * -0.25)) / ((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 + (v * (-0.25d0))) / ((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 + (v * -0.25)) / ((v + -1.0) / ((r * w) * (r * w)))));
}
def code(v, w, r):
	return (2.0 / (r * r)) + (-1.5 + ((0.375 + (v * -0.25)) / ((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(v * -0.25)) / 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 + (v * -0.25)) / ((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[(v * -0.25), $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 + v \cdot -0.25}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right)
\end{array}
Derivation
  1. Initial program 84.8%

    \[\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. Simplified87.7%

    \[\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. fma-undefine87.7%

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

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

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

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(0.125 \cdot \left(3 + \color{blue}{\left(-2\right)} \cdot v\right)\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{1 - v}\right)\right)\right) \]
    5. cancel-sign-sub-inv87.7%

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

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

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

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

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

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\frac{0.125 \cdot \left(3 - 2 \cdot v\right)}{\frac{1 - v}{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}}}\right) \]
    11. cancel-sign-sub-inv87.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 93.4% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \frac{2}{r \cdot r} + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right) \end{array} \]
(FPCore (v w r)
 :precision binary64
 (+ (/ 2.0 (* r r)) (- -1.5 (* (* (* r w) (* r w)) 0.25))))
double code(double v, double w, double r) {
	return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
}
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) - (((r * w) * (r * w)) * 0.25d0))
end function
public static double code(double v, double w, double r) {
	return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
}
def code(v, w, r):
	return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25))
function code(v, w, r)
	return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25)))
end
function tmp = code(v, w, r)
	tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\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. Simplified87.7%

    \[\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. Taylor expanded in v around inf 79.8%

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

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({r}^{2} \cdot {w}^{2}\right) \cdot 0.25}\right) \]
    2. *-commutative79.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left({w}^{2} \cdot {r}^{2}\right)} \cdot 0.25\right) \]
    3. unpow279.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\color{blue}{\left(w \cdot w\right)} \cdot {r}^{2}\right) \cdot 0.25\right) \]
    4. unpow279.8%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \left(\left(w \cdot w\right) \cdot \color{blue}{\left(r \cdot r\right)}\right) \cdot 0.25\right) \]
    5. swap-sqr94.7%

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

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{{\left(w \cdot r\right)}^{2}} \cdot 0.25\right) \]
    7. *-commutative94.7%

      \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - {\color{blue}{\left(r \cdot w\right)}}^{2} \cdot 0.25\right) \]
  6. Simplified94.7%

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

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

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

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right)} \cdot 0.25\right) \]
  9. Final simplification94.7%

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

Alternative 6: 57.0% accurate, 4.1× speedup?

\[\begin{array}{l} \\ -1.5 - \frac{-2}{r \cdot r} \end{array} \]
(FPCore (v w r) :precision binary64 (- -1.5 (/ -2.0 (* r r))))
double code(double v, double w, double r) {
	return -1.5 - (-2.0 / (r * r));
}
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) - ((-2.0d0) / (r * r))
end function
public static double code(double v, double w, double r) {
	return -1.5 - (-2.0 / (r * r));
}
def code(v, w, r):
	return -1.5 - (-2.0 / (r * r))
function code(v, w, r)
	return Float64(-1.5 - Float64(-2.0 / Float64(r * r)))
end
function tmp = code(v, w, r)
	tmp = -1.5 - (-2.0 / (r * r));
end
code[v_, w_, r_] := N[(-1.5 - N[(-2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-1.5 - \frac{-2}{r \cdot r}
\end{array}
Derivation
  1. Initial program 84.8%

    \[\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.8%

    \[\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 59.9%

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

      \[\leadsto \color{blue}{\left(\frac{2}{r \cdot r} + 3\right)} - 4.5 \]
    2. associate--l+59.9%

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

      \[\leadsto \color{blue}{2 \cdot \frac{1}{r \cdot r}} + \left(3 - 4.5\right) \]
    4. pow259.9%

      \[\leadsto 2 \cdot \frac{1}{\color{blue}{{r}^{2}}} + \left(3 - 4.5\right) \]
    5. pow-flip60.0%

      \[\leadsto 2 \cdot \color{blue}{{r}^{\left(-2\right)}} + \left(3 - 4.5\right) \]
    6. metadata-eval60.0%

      \[\leadsto 2 \cdot {r}^{\color{blue}{-2}} + \left(3 - 4.5\right) \]
    7. metadata-eval60.0%

      \[\leadsto 2 \cdot {r}^{-2} + \color{blue}{-1.5} \]
  6. Applied egg-rr60.0%

    \[\leadsto \color{blue}{2 \cdot {r}^{-2} + -1.5} \]
  7. Step-by-step derivation
    1. sqr-pow59.8%

      \[\leadsto 2 \cdot \color{blue}{\left({r}^{\left(\frac{-2}{2}\right)} \cdot {r}^{\left(\frac{-2}{2}\right)}\right)} + -1.5 \]
    2. metadata-eval59.8%

      \[\leadsto 2 \cdot \left({r}^{\color{blue}{-1}} \cdot {r}^{\left(\frac{-2}{2}\right)}\right) + -1.5 \]
    3. inv-pow59.8%

      \[\leadsto 2 \cdot \left(\color{blue}{\frac{1}{r}} \cdot {r}^{\left(\frac{-2}{2}\right)}\right) + -1.5 \]
    4. metadata-eval59.8%

      \[\leadsto 2 \cdot \left(\frac{1}{r} \cdot {r}^{\color{blue}{-1}}\right) + -1.5 \]
    5. inv-pow59.8%

      \[\leadsto 2 \cdot \left(\frac{1}{r} \cdot \color{blue}{\frac{1}{r}}\right) + -1.5 \]
    6. associate-*r*59.8%

      \[\leadsto \color{blue}{\left(2 \cdot \frac{1}{r}\right) \cdot \frac{1}{r}} + -1.5 \]
    7. div-inv59.8%

      \[\leadsto \color{blue}{\frac{2}{r}} \cdot \frac{1}{r} + -1.5 \]
    8. frac-2neg59.8%

      \[\leadsto \color{blue}{\frac{-2}{-r}} \cdot \frac{1}{r} + -1.5 \]
    9. metadata-eval59.8%

      \[\leadsto \frac{\color{blue}{-2}}{-r} \cdot \frac{1}{r} + -1.5 \]
    10. frac-times59.9%

      \[\leadsto \color{blue}{\frac{-2 \cdot 1}{\left(-r\right) \cdot r}} + -1.5 \]
    11. metadata-eval59.9%

      \[\leadsto \frac{\color{blue}{-2}}{\left(-r\right) \cdot r} + -1.5 \]
  8. Applied egg-rr59.9%

    \[\leadsto \color{blue}{\frac{-2}{\left(-r\right) \cdot r}} + -1.5 \]
  9. Final simplification59.9%

    \[\leadsto -1.5 - \frac{-2}{r \cdot r} \]
  10. Add Preprocessing

Alternative 7: 57.0% accurate, 4.1× speedup?

\[\begin{array}{l} \\ -1.5 + \frac{\frac{2}{r}}{r} \end{array} \]
(FPCore (v w r) :precision binary64 (+ -1.5 (/ (/ 2.0 r) r)))
double code(double v, double w, double r) {
	return -1.5 + ((2.0 / r) / r);
}
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) + ((2.0d0 / r) / r)
end function
public static double code(double v, double w, double r) {
	return -1.5 + ((2.0 / r) / r);
}
def code(v, w, r):
	return -1.5 + ((2.0 / r) / r)
function code(v, w, r)
	return Float64(-1.5 + Float64(Float64(2.0 / r) / r))
end
function tmp = code(v, w, r)
	tmp = -1.5 + ((2.0 / r) / r);
end
code[v_, w_, r_] := N[(-1.5 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-1.5 + \frac{\frac{2}{r}}{r}
\end{array}
Derivation
  1. Initial program 84.8%

    \[\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.8%

    \[\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 59.9%

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

      \[\leadsto \color{blue}{\left(\frac{2}{r \cdot r} + 3\right)} - 4.5 \]
    2. associate--l+59.9%

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

      \[\leadsto \color{blue}{2 \cdot \frac{1}{r \cdot r}} + \left(3 - 4.5\right) \]
    4. pow259.9%

      \[\leadsto 2 \cdot \frac{1}{\color{blue}{{r}^{2}}} + \left(3 - 4.5\right) \]
    5. pow-flip60.0%

      \[\leadsto 2 \cdot \color{blue}{{r}^{\left(-2\right)}} + \left(3 - 4.5\right) \]
    6. metadata-eval60.0%

      \[\leadsto 2 \cdot {r}^{\color{blue}{-2}} + \left(3 - 4.5\right) \]
    7. metadata-eval60.0%

      \[\leadsto 2 \cdot {r}^{-2} + \color{blue}{-1.5} \]
  6. Applied egg-rr60.0%

    \[\leadsto \color{blue}{2 \cdot {r}^{-2} + -1.5} \]
  7. Step-by-step derivation
    1. sqr-pow59.8%

      \[\leadsto 2 \cdot \color{blue}{\left({r}^{\left(\frac{-2}{2}\right)} \cdot {r}^{\left(\frac{-2}{2}\right)}\right)} + -1.5 \]
    2. metadata-eval59.8%

      \[\leadsto 2 \cdot \left({r}^{\color{blue}{-1}} \cdot {r}^{\left(\frac{-2}{2}\right)}\right) + -1.5 \]
    3. inv-pow59.8%

      \[\leadsto 2 \cdot \left(\color{blue}{\frac{1}{r}} \cdot {r}^{\left(\frac{-2}{2}\right)}\right) + -1.5 \]
    4. metadata-eval59.8%

      \[\leadsto 2 \cdot \left(\frac{1}{r} \cdot {r}^{\color{blue}{-1}}\right) + -1.5 \]
    5. inv-pow59.8%

      \[\leadsto 2 \cdot \left(\frac{1}{r} \cdot \color{blue}{\frac{1}{r}}\right) + -1.5 \]
    6. associate-*r*59.8%

      \[\leadsto \color{blue}{\left(2 \cdot \frac{1}{r}\right) \cdot \frac{1}{r}} + -1.5 \]
    7. div-inv59.8%

      \[\leadsto \color{blue}{\frac{2}{r}} \cdot \frac{1}{r} + -1.5 \]
    8. div-inv59.9%

      \[\leadsto \color{blue}{\frac{\frac{2}{r}}{r}} + -1.5 \]
  8. Applied egg-rr59.9%

    \[\leadsto \color{blue}{\frac{\frac{2}{r}}{r}} + -1.5 \]
  9. Final simplification59.9%

    \[\leadsto -1.5 + \frac{\frac{2}{r}}{r} \]
  10. Add Preprocessing

Alternative 8: 14.6% 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.8%

    \[\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.8%

    \[\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 59.9%

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

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

Reproduce

?
herbie shell --seed 2024085 
(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))