Rosa's TurbineBenchmark

Percentage Accurate: 85.1% → 98.8%
Time: 15.3s
Alternatives: 19
Speedup: 1.6×

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 19 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.1% 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: 98.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\\ t_1 := 3 + \frac{2}{r \cdot r}\\ \mathbf{if}\;w \cdot w \leq 10^{-230}:\\ \;\;\;\;t\_1 - \mathsf{fma}\left(t\_0, \left(w \cdot \left(w \cdot r\right)\right) \cdot \frac{r}{1 - v}, 4.5\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1 - \mathsf{fma}\left(t\_0, w \cdot \frac{r \cdot \left(w \cdot r\right)}{1 - v}, 4.5\right)\\ \end{array} \end{array} \]
(FPCore (v w r)
 :precision binary64
 (let* ((t_0 (* 0.125 (fma v -2.0 3.0))) (t_1 (+ 3.0 (/ 2.0 (* r r)))))
   (if (<= (* w w) 1e-230)
     (- t_1 (fma t_0 (* (* w (* w r)) (/ r (- 1.0 v))) 4.5))
     (- t_1 (fma t_0 (* w (/ (* r (* w r)) (- 1.0 v))) 4.5)))))
double code(double v, double w, double r) {
	double t_0 = 0.125 * fma(v, -2.0, 3.0);
	double t_1 = 3.0 + (2.0 / (r * r));
	double tmp;
	if ((w * w) <= 1e-230) {
		tmp = t_1 - fma(t_0, ((w * (w * r)) * (r / (1.0 - v))), 4.5);
	} else {
		tmp = t_1 - fma(t_0, (w * ((r * (w * r)) / (1.0 - v))), 4.5);
	}
	return tmp;
}
function code(v, w, r)
	t_0 = Float64(0.125 * fma(v, -2.0, 3.0))
	t_1 = Float64(3.0 + Float64(2.0 / Float64(r * r)))
	tmp = 0.0
	if (Float64(w * w) <= 1e-230)
		tmp = Float64(t_1 - fma(t_0, Float64(Float64(w * Float64(w * r)) * Float64(r / Float64(1.0 - v))), 4.5));
	else
		tmp = Float64(t_1 - fma(t_0, Float64(w * Float64(Float64(r * Float64(w * r)) / Float64(1.0 - v))), 4.5));
	end
	return tmp
end
code[v_, w_, r_] := Block[{t$95$0 = N[(0.125 * N[(v * -2.0 + 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(w * w), $MachinePrecision], 1e-230], N[(t$95$1 - N[(t$95$0 * N[(N[(w * N[(w * r), $MachinePrecision]), $MachinePrecision] * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision], N[(t$95$1 - N[(t$95$0 * N[(w * N[(N[(r * N[(w * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.125 \cdot \mathsf{fma}\left(v, -2, 3\right)\\
t_1 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;w \cdot w \leq 10^{-230}:\\
\;\;\;\;t\_1 - \mathsf{fma}\left(t\_0, \left(w \cdot \left(w \cdot r\right)\right) \cdot \frac{r}{1 - v}, 4.5\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1 - \mathsf{fma}\left(t\_0, w \cdot \frac{r \cdot \left(w \cdot r\right)}{1 - v}, 4.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 w w) < 1.00000000000000005e-230

    1. Initial program 86.4%

      \[\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. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(\frac{1}{8} \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) - \frac{9}{2}} \]
      2. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(\frac{1}{8} \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)} - \frac{9}{2} \]
      3. associate--l-N/A

        \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} + \frac{9}{2}\right)} \]
      4. lower--.f64N/A

        \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} + \frac{9}{2}\right)} \]
      5. lift-/.f64N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\color{blue}{\frac{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}} + \frac{9}{2}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\color{blue}{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}}{1 - v} + \frac{9}{2}\right) \]
      7. associate-/l*N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\color{blue}{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \frac{\left(\left(w \cdot w\right) \cdot r\right) \cdot r}{1 - v}} + \frac{9}{2}\right) \]
      8. lower-fma.f64N/A

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

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

    if 1.00000000000000005e-230 < (*.f64 w w)

    1. Initial program 84.7%

      \[\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. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(\frac{1}{8} \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) - \frac{9}{2}} \]
      2. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(\frac{1}{8} \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)} - \frac{9}{2} \]
      3. associate--l-N/A

        \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} + \frac{9}{2}\right)} \]
      4. lower--.f64N/A

        \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} + \frac{9}{2}\right)} \]
      5. lift-/.f64N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\color{blue}{\frac{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}} + \frac{9}{2}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\color{blue}{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}}{1 - v} + \frac{9}{2}\right) \]
      7. associate-/l*N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\color{blue}{\left(\frac{1}{8} \cdot \left(3 - 2 \cdot v\right)\right) \cdot \frac{\left(\left(w \cdot w\right) \cdot r\right) \cdot r}{1 - v}} + \frac{9}{2}\right) \]
      8. lower-fma.f64N/A

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

      \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(0.125 \cdot \mathsf{fma}\left(v, -2, 3\right), \left(w \cdot \left(r \cdot w\right)\right) \cdot \frac{r}{1 - v}, 4.5\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(\frac{1}{8} \cdot \mathsf{fma}\left(v, -2, 3\right), \color{blue}{\left(w \cdot \left(r \cdot w\right)\right) \cdot \frac{r}{1 - v}}, \frac{9}{2}\right) \]
      2. lift-*.f64N/A

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

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(\frac{1}{8} \cdot \mathsf{fma}\left(v, -2, 3\right), \color{blue}{w \cdot \left(\left(r \cdot w\right) \cdot \frac{r}{1 - v}\right)}, \frac{9}{2}\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(\frac{1}{8} \cdot \mathsf{fma}\left(v, -2, 3\right), \color{blue}{\left(\left(r \cdot w\right) \cdot \frac{r}{1 - v}\right) \cdot w}, \frac{9}{2}\right) \]
      5. lower-*.f64N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(\frac{1}{8} \cdot \mathsf{fma}\left(v, -2, 3\right), \color{blue}{\left(\left(r \cdot w\right) \cdot \frac{r}{1 - v}\right) \cdot w}, \frac{9}{2}\right) \]
      6. lift-/.f64N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(\frac{1}{8} \cdot \mathsf{fma}\left(v, -2, 3\right), \left(\left(r \cdot w\right) \cdot \color{blue}{\frac{r}{1 - v}}\right) \cdot w, \frac{9}{2}\right) \]
      7. associate-*r/N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(\frac{1}{8} \cdot \mathsf{fma}\left(v, -2, 3\right), \color{blue}{\frac{\left(r \cdot w\right) \cdot r}{1 - v}} \cdot w, \frac{9}{2}\right) \]
      8. lower-/.f64N/A

        \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(\frac{1}{8} \cdot \mathsf{fma}\left(v, -2, 3\right), \color{blue}{\frac{\left(r \cdot w\right) \cdot r}{1 - v}} \cdot w, \frac{9}{2}\right) \]
      9. lower-*.f6499.8

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

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

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

Alternative 2: 89.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{r \cdot r}\\ t_1 := \left(3 + t\_0\right) + \frac{\left(r \cdot \left(\left(w \cdot w\right) \cdot r\right)\right) \cdot \left(0.125 \cdot \left(2 \cdot v - 3\right)\right)}{1 - v}\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;-0.25 \cdot \left(w \cdot \left(w \cdot \left(r \cdot r\right)\right)\right)\\ \mathbf{elif}\;t\_1 \leq -5 \cdot 10^{+20}:\\ \;\;\;\;\left(r \cdot r\right) \cdot \left(\left(w \cdot w\right) \cdot -0.375\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 + -1.5\\ \end{array} \end{array} \]
(FPCore (v w r)
 :precision binary64
 (let* ((t_0 (/ 2.0 (* r r)))
        (t_1
         (+
          (+ 3.0 t_0)
          (/ (* (* r (* (* w w) r)) (* 0.125 (- (* 2.0 v) 3.0))) (- 1.0 v)))))
   (if (<= t_1 (- INFINITY))
     (* -0.25 (* w (* w (* r r))))
     (if (<= t_1 -5e+20) (* (* r r) (* (* w w) -0.375)) (+ t_0 -1.5)))))
double code(double v, double w, double r) {
	double t_0 = 2.0 / (r * r);
	double t_1 = (3.0 + t_0) + (((r * ((w * w) * r)) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = -0.25 * (w * (w * (r * r)));
	} else if (t_1 <= -5e+20) {
		tmp = (r * r) * ((w * w) * -0.375);
	} else {
		tmp = t_0 + -1.5;
	}
	return tmp;
}
public static double code(double v, double w, double r) {
	double t_0 = 2.0 / (r * r);
	double t_1 = (3.0 + t_0) + (((r * ((w * w) * r)) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v));
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = -0.25 * (w * (w * (r * r)));
	} else if (t_1 <= -5e+20) {
		tmp = (r * r) * ((w * w) * -0.375);
	} else {
		tmp = t_0 + -1.5;
	}
	return tmp;
}
def code(v, w, r):
	t_0 = 2.0 / (r * r)
	t_1 = (3.0 + t_0) + (((r * ((w * w) * r)) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))
	tmp = 0
	if t_1 <= -math.inf:
		tmp = -0.25 * (w * (w * (r * r)))
	elif t_1 <= -5e+20:
		tmp = (r * r) * ((w * w) * -0.375)
	else:
		tmp = t_0 + -1.5
	return tmp
function code(v, w, r)
	t_0 = Float64(2.0 / Float64(r * r))
	t_1 = Float64(Float64(3.0 + t_0) + Float64(Float64(Float64(r * Float64(Float64(w * w) * r)) * Float64(0.125 * Float64(Float64(2.0 * v) - 3.0))) / Float64(1.0 - v)))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(-0.25 * Float64(w * Float64(w * Float64(r * r))));
	elseif (t_1 <= -5e+20)
		tmp = Float64(Float64(r * r) * Float64(Float64(w * w) * -0.375));
	else
		tmp = Float64(t_0 + -1.5);
	end
	return tmp
end
function tmp_2 = code(v, w, r)
	t_0 = 2.0 / (r * r);
	t_1 = (3.0 + t_0) + (((r * ((w * w) * r)) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v));
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = -0.25 * (w * (w * (r * r)));
	elseif (t_1 <= -5e+20)
		tmp = (r * r) * ((w * w) * -0.375);
	else
		tmp = t_0 + -1.5;
	end
	tmp_2 = tmp;
end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(3.0 + t$95$0), $MachinePrecision] + N[(N[(N[(r * N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] * N[(0.125 * N[(N[(2.0 * v), $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(-0.25 * N[(w * N[(w * N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -5e+20], N[(N[(r * r), $MachinePrecision] * N[(N[(w * w), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + -1.5), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := \left(3 + t\_0\right) + \frac{\left(r \cdot \left(\left(w \cdot w\right) \cdot r\right)\right) \cdot \left(0.125 \cdot \left(2 \cdot v - 3\right)\right)}{1 - v}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-0.25 \cdot \left(w \cdot \left(w \cdot \left(r \cdot r\right)\right)\right)\\

\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{+20}:\\
\;\;\;\;\left(r \cdot r\right) \cdot \left(\left(w \cdot w\right) \cdot -0.375\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0 + -1.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) < -inf.0

    1. Initial program 83.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. Add Preprocessing
    3. Taylor expanded in v around inf

      \[\leadsto \color{blue}{2 \cdot \frac{1}{{r}^{2}} - \left(\frac{3}{2} + \frac{1}{4} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right)} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \color{blue}{2 \cdot \frac{1}{{r}^{2}} + \left(\mathsf{neg}\left(\left(\frac{3}{2} + \frac{1}{4} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\frac{3}{2} + \frac{1}{4} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right)\right)\right) + 2 \cdot \frac{1}{{r}^{2}}} \]
      3. distribute-neg-inN/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{3}{2}\right)\right) + \left(\mathsf{neg}\left(\frac{1}{4} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right)\right)\right)} + 2 \cdot \frac{1}{{r}^{2}} \]
      4. metadata-evalN/A

        \[\leadsto \left(\color{blue}{\frac{-3}{2}} + \left(\mathsf{neg}\left(\frac{1}{4} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right)\right)\right) + 2 \cdot \frac{1}{{r}^{2}} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \left(\frac{-3}{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{4}\right)\right) \cdot \left({r}^{2} \cdot {w}^{2}\right)}\right) + 2 \cdot \frac{1}{{r}^{2}} \]
      6. metadata-evalN/A

        \[\leadsto \left(\frac{-3}{2} + \color{blue}{\frac{-1}{4}} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right) + 2 \cdot \frac{1}{{r}^{2}} \]
      7. associate-+l+N/A

        \[\leadsto \color{blue}{\frac{-3}{2} + \left(\frac{-1}{4} \cdot \left({r}^{2} \cdot {w}^{2}\right) + 2 \cdot \frac{1}{{r}^{2}}\right)} \]
      8. lower-+.f64N/A

        \[\leadsto \color{blue}{\frac{-3}{2} + \left(\frac{-1}{4} \cdot \left({r}^{2} \cdot {w}^{2}\right) + 2 \cdot \frac{1}{{r}^{2}}\right)} \]
      9. associate-*r*N/A

        \[\leadsto \frac{-3}{2} + \left(\color{blue}{\left(\frac{-1}{4} \cdot {r}^{2}\right) \cdot {w}^{2}} + 2 \cdot \frac{1}{{r}^{2}}\right) \]
      10. unpow2N/A

        \[\leadsto \frac{-3}{2} + \left(\left(\frac{-1}{4} \cdot {r}^{2}\right) \cdot \color{blue}{\left(w \cdot w\right)} + 2 \cdot \frac{1}{{r}^{2}}\right) \]
      11. associate-*r*N/A

        \[\leadsto \frac{-3}{2} + \left(\color{blue}{\left(\left(\frac{-1}{4} \cdot {r}^{2}\right) \cdot w\right) \cdot w} + 2 \cdot \frac{1}{{r}^{2}}\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{-3}{2} + \color{blue}{\mathsf{fma}\left(\left(\frac{-1}{4} \cdot {r}^{2}\right) \cdot w, w, 2 \cdot \frac{1}{{r}^{2}}\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{-3}{2} + \mathsf{fma}\left(\color{blue}{\left(\frac{-1}{4} \cdot {r}^{2}\right) \cdot w}, w, 2 \cdot \frac{1}{{r}^{2}}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \frac{-3}{2} + \mathsf{fma}\left(\color{blue}{\left(\frac{-1}{4} \cdot {r}^{2}\right)} \cdot w, w, 2 \cdot \frac{1}{{r}^{2}}\right) \]
      15. unpow2N/A

        \[\leadsto \frac{-3}{2} + \mathsf{fma}\left(\left(\frac{-1}{4} \cdot \color{blue}{\left(r \cdot r\right)}\right) \cdot w, w, 2 \cdot \frac{1}{{r}^{2}}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \frac{-3}{2} + \mathsf{fma}\left(\left(\frac{-1}{4} \cdot \color{blue}{\left(r \cdot r\right)}\right) \cdot w, w, 2 \cdot \frac{1}{{r}^{2}}\right) \]
      17. associate-*r/N/A

        \[\leadsto \frac{-3}{2} + \mathsf{fma}\left(\left(\frac{-1}{4} \cdot \left(r \cdot r\right)\right) \cdot w, w, \color{blue}{\frac{2 \cdot 1}{{r}^{2}}}\right) \]
    5. Applied rewrites95.4%

      \[\leadsto \color{blue}{-1.5 + \mathsf{fma}\left(\left(-0.25 \cdot \left(r \cdot r\right)\right) \cdot w, w, \frac{2}{r \cdot r}\right)} \]
    6. Taylor expanded in r around inf

      \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left({r}^{2} \cdot {w}^{2}\right)} \]
    7. Step-by-step derivation
      1. Applied rewrites90.7%

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

      if -inf.0 < (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) < -5e20

      1. Initial program 98.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. Add Preprocessing
      3. Taylor expanded in v around 0

        \[\leadsto \color{blue}{2 \cdot \frac{1}{{r}^{2}} - \left(\frac{3}{2} + \frac{3}{8} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right)} \]
      4. Step-by-step derivation
        1. lower--.f64N/A

          \[\leadsto \color{blue}{2 \cdot \frac{1}{{r}^{2}} - \left(\frac{3}{2} + \frac{3}{8} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right)} \]
        2. associate-*r/N/A

          \[\leadsto \color{blue}{\frac{2 \cdot 1}{{r}^{2}}} - \left(\frac{3}{2} + \frac{3}{8} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right) \]
        3. metadata-evalN/A

          \[\leadsto \frac{\color{blue}{2}}{{r}^{2}} - \left(\frac{3}{2} + \frac{3}{8} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right) \]
        4. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{2}{{r}^{2}}} - \left(\frac{3}{2} + \frac{3}{8} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right) \]
        5. unpow2N/A

          \[\leadsto \frac{2}{\color{blue}{r \cdot r}} - \left(\frac{3}{2} + \frac{3}{8} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right) \]
        6. lower-*.f64N/A

          \[\leadsto \frac{2}{\color{blue}{r \cdot r}} - \left(\frac{3}{2} + \frac{3}{8} \cdot \left({r}^{2} \cdot {w}^{2}\right)\right) \]
        7. +-commutativeN/A

          \[\leadsto \frac{2}{r \cdot r} - \color{blue}{\left(\frac{3}{8} \cdot \left({r}^{2} \cdot {w}^{2}\right) + \frac{3}{2}\right)} \]
        8. associate-*r*N/A

          \[\leadsto \frac{2}{r \cdot r} - \left(\color{blue}{\left(\frac{3}{8} \cdot {r}^{2}\right) \cdot {w}^{2}} + \frac{3}{2}\right) \]
        9. *-commutativeN/A

          \[\leadsto \frac{2}{r \cdot r} - \left(\color{blue}{{w}^{2} \cdot \left(\frac{3}{8} \cdot {r}^{2}\right)} + \frac{3}{2}\right) \]
        10. lower-fma.f64N/A

          \[\leadsto \frac{2}{r \cdot r} - \color{blue}{\mathsf{fma}\left({w}^{2}, \frac{3}{8} \cdot {r}^{2}, \frac{3}{2}\right)} \]
        11. unpow2N/A

          \[\leadsto \frac{2}{r \cdot r} - \mathsf{fma}\left(\color{blue}{w \cdot w}, \frac{3}{8} \cdot {r}^{2}, \frac{3}{2}\right) \]
        12. lower-*.f64N/A

          \[\leadsto \frac{2}{r \cdot r} - \mathsf{fma}\left(\color{blue}{w \cdot w}, \frac{3}{8} \cdot {r}^{2}, \frac{3}{2}\right) \]
        13. lower-*.f64N/A

          \[\leadsto \frac{2}{r \cdot r} - \mathsf{fma}\left(w \cdot w, \color{blue}{\frac{3}{8} \cdot {r}^{2}}, \frac{3}{2}\right) \]
        14. unpow2N/A

          \[\leadsto \frac{2}{r \cdot r} - \mathsf{fma}\left(w \cdot w, \frac{3}{8} \cdot \color{blue}{\left(r \cdot r\right)}, \frac{3}{2}\right) \]
        15. lower-*.f6450.5

          \[\leadsto \frac{2}{r \cdot r} - \mathsf{fma}\left(w \cdot w, 0.375 \cdot \color{blue}{\left(r \cdot r\right)}, 1.5\right) \]
      5. Applied rewrites50.5%

        \[\leadsto \color{blue}{\frac{2}{r \cdot r} - \mathsf{fma}\left(w \cdot w, 0.375 \cdot \left(r \cdot r\right), 1.5\right)} \]
      6. Taylor expanded in r around inf

        \[\leadsto \frac{-3}{8} \cdot \color{blue}{\left({r}^{2} \cdot {w}^{2}\right)} \]
      7. Step-by-step derivation
        1. Applied rewrites50.1%

          \[\leadsto \left(r \cdot r\right) \cdot \color{blue}{\left(\left(w \cdot w\right) \cdot -0.375\right)} \]

        if -5e20 < (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v)))

        1. Initial program 84.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. Taylor expanded in w around 0

          \[\leadsto \color{blue}{2 \cdot \frac{1}{{r}^{2}} - \frac{3}{2}} \]
        4. Step-by-step derivation
          1. sub-negN/A

            \[\leadsto \color{blue}{2 \cdot \frac{1}{{r}^{2}} + \left(\mathsf{neg}\left(\frac{3}{2}\right)\right)} \]
          2. metadata-evalN/A

            \[\leadsto 2 \cdot \frac{1}{{r}^{2}} + \color{blue}{\frac{-3}{2}} \]
          3. +-commutativeN/A

            \[\leadsto \color{blue}{\frac{-3}{2} + 2 \cdot \frac{1}{{r}^{2}}} \]
          4. lower-+.f64N/A

            \[\leadsto \color{blue}{\frac{-3}{2} + 2 \cdot \frac{1}{{r}^{2}}} \]
          5. associate-*r/N/A

            \[\leadsto \frac{-3}{2} + \color{blue}{\frac{2 \cdot 1}{{r}^{2}}} \]
          6. metadata-evalN/A

            \[\leadsto \frac{-3}{2} + \frac{\color{blue}{2}}{{r}^{2}} \]
          7. lower-/.f64N/A

            \[\leadsto \frac{-3}{2} + \color{blue}{\frac{2}{{r}^{2}}} \]
          8. unpow2N/A

            \[\leadsto \frac{-3}{2} + \frac{2}{\color{blue}{r \cdot r}} \]
          9. lower-*.f6494.4

            \[\leadsto -1.5 + \frac{2}{\color{blue}{r \cdot r}} \]
        5. Applied rewrites94.4%

          \[\leadsto \color{blue}{-1.5 + \frac{2}{r \cdot r}} \]
      8. Recombined 3 regimes into one program.
      9. Final simplification89.6%

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

      Reproduce

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