Rosa's TurbineBenchmark

Percentage Accurate: 84.6% → 99.1%
Time: 13.5s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 84.6% 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, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \cdot w \leq 5 \cdot 10^{+300}:\\
\;\;\;\;\left(3 + t\_0\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}:\\
\;\;\;\;\mathsf{fma}\left(w \cdot \left(\left(r \cdot r\right) \cdot -0.375\right), w, t\_0 + -1.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 w w) < 5.00000000000000026e300

    1. Initial program 93.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 rewrites99.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)} \]

    if 5.00000000000000026e300 < (*.f64 w w)

    1. Initial program 59.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. 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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{2}{r \cdot r} + \left({w}^{2} \cdot \left(\frac{-3}{8} \cdot {r}^{2}\right) + \color{blue}{\frac{-3}{2}}\right) \]
      16. 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)} \]
    5. Applied rewrites59.3%

      \[\leadsto \color{blue}{\frac{2}{r \cdot r} + \mathsf{fma}\left(w \cdot w, \left(r \cdot r\right) \cdot -0.375, -1.5\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites98.6%

        \[\leadsto \mathsf{fma}\left(w \cdot \left(\left(r \cdot r\right) \cdot -0.375\right), \color{blue}{w}, -1.5 + \frac{2}{r \cdot r}\right) \]
    7. Recombined 2 regimes into one program.
    8. Final simplification99.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;w \cdot w \leq 5 \cdot 10^{+300}:\\ \;\;\;\;\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}:\\ \;\;\;\;\mathsf{fma}\left(w \cdot \left(\left(r \cdot r\right) \cdot -0.375\right), w, \frac{2}{r \cdot r} + -1.5\right)\\ \end{array} \]
    9. Add Preprocessing

    Alternative 2: 94.8% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \left(\left(w \cdot w\right) \cdot r\right)\\ t_1 := \frac{2}{r \cdot r}\\ t_2 := \left(3 + t\_1\right) + \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot t\_0}{v + -1}\\ t_3 := -1.5 + \mathsf{fma}\left(r \cdot \left(w \cdot \left(r \cdot -0.25\right)\right), w, t\_1\right)\\ \mathbf{if}\;t\_2 \leq -\infty:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq -1 \cdot 10^{+98}:\\ \;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(v, 0.25, -0.375\right)}{1 - v}\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \end{array} \]
    (FPCore (v w r)
     :precision binary64
     (let* ((t_0 (* r (* (* w w) r)))
            (t_1 (/ 2.0 (* r r)))
            (t_2
             (+ (+ 3.0 t_1) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) t_0) (+ v -1.0))))
            (t_3 (+ -1.5 (fma (* r (* w (* r -0.25))) w t_1))))
       (if (<= t_2 (- INFINITY))
         t_3
         (if (<= t_2 -1e+98) (/ (* t_0 (fma v 0.25 -0.375)) (- 1.0 v)) t_3))))
    double code(double v, double w, double r) {
    	double t_0 = r * ((w * w) * r);
    	double t_1 = 2.0 / (r * r);
    	double t_2 = (3.0 + t_1) + (((0.125 * (3.0 - (2.0 * v))) * t_0) / (v + -1.0));
    	double t_3 = -1.5 + fma((r * (w * (r * -0.25))), w, t_1);
    	double tmp;
    	if (t_2 <= -((double) INFINITY)) {
    		tmp = t_3;
    	} else if (t_2 <= -1e+98) {
    		tmp = (t_0 * fma(v, 0.25, -0.375)) / (1.0 - v);
    	} else {
    		tmp = t_3;
    	}
    	return tmp;
    }
    
    function code(v, w, r)
    	t_0 = Float64(r * Float64(Float64(w * w) * r))
    	t_1 = Float64(2.0 / Float64(r * r))
    	t_2 = Float64(Float64(3.0 + t_1) + Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * t_0) / Float64(v + -1.0)))
    	t_3 = Float64(-1.5 + fma(Float64(r * Float64(w * Float64(r * -0.25))), w, t_1))
    	tmp = 0.0
    	if (t_2 <= Float64(-Inf))
    		tmp = t_3;
    	elseif (t_2 <= -1e+98)
    		tmp = Float64(Float64(t_0 * fma(v, 0.25, -0.375)) / Float64(1.0 - v));
    	else
    		tmp = t_3;
    	end
    	return tmp
    end
    
    code[v_, w_, r_] := Block[{t$95$0 = N[(r * N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(3.0 + t$95$1), $MachinePrecision] + N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(-1.5 + N[(N[(r * N[(w * N[(r * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * w + t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$3, If[LessEqual[t$95$2, -1e+98], N[(N[(t$95$0 * N[(v * 0.25 + -0.375), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := r \cdot \left(\left(w \cdot w\right) \cdot r\right)\\
    t_1 := \frac{2}{r \cdot r}\\
    t_2 := \left(3 + t\_1\right) + \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot t\_0}{v + -1}\\
    t_3 := -1.5 + \mathsf{fma}\left(r \cdot \left(w \cdot \left(r \cdot -0.25\right)\right), w, t\_1\right)\\
    \mathbf{if}\;t\_2 \leq -\infty:\\
    \;\;\;\;t\_3\\
    
    \mathbf{elif}\;t\_2 \leq -1 \cdot 10^{+98}:\\
    \;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(v, 0.25, -0.375\right)}{1 - v}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_3\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 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 or -9.99999999999999998e97 < (-.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 83.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. 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 rewrites89.8%

        \[\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. Step-by-step derivation
        1. Applied rewrites94.6%

          \[\leadsto -1.5 + \mathsf{fma}\left(\left(w \cdot \left(r \cdot -0.25\right)\right) \cdot r, w, \frac{2}{r \cdot r}\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))) < -9.99999999999999998e97

        1. Initial program 98.1%

          \[\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 r around 0

          \[\leadsto \color{blue}{\frac{2}{{r}^{2}}} \]
        4. Step-by-step derivation
          1. lower-/.f64N/A

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

            \[\leadsto \frac{2}{\color{blue}{r \cdot r}} \]
          3. lower-*.f641.5

            \[\leadsto \frac{2}{\color{blue}{r \cdot r}} \]
        5. Applied rewrites1.5%

          \[\leadsto \color{blue}{\frac{2}{r \cdot r}} \]
        6. Taylor expanded in r around inf

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\left(\frac{-1}{8} \cdot \left(r \cdot r\right)\right) \cdot \left(w \cdot \color{blue}{\left(w \cdot \left(3 - 2 \cdot v\right)\right)}\right)}{1 - v} \]
          12. cancel-sign-sub-invN/A

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{\left(-0.125 \cdot \left(r \cdot r\right)\right) \cdot \left(w \cdot \left(w \cdot \mathsf{fma}\left(v, -2, 3\right)\right)\right)}{1 - v}} \]
        9. Taylor expanded in v around 0

          \[\leadsto \frac{\frac{-3}{8} \cdot \left({r}^{2} \cdot {w}^{2}\right) + \frac{1}{4} \cdot \left({r}^{2} \cdot \left(v \cdot {w}^{2}\right)\right)}{\color{blue}{1} - v} \]
        10. Step-by-step derivation
          1. Applied rewrites97.9%

            \[\leadsto \frac{\left(r \cdot \left(r \cdot \left(w \cdot w\right)\right)\right) \cdot \mathsf{fma}\left(v, 0.25, -0.375\right)}{\color{blue}{1} - v} \]
        11. Recombined 2 regimes into one program.
        12. Final simplification94.8%

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

        Reproduce

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