Rosa's TurbineBenchmark

?

Percentage Accurate: 84.2% → 99.8%
Time: 10.6s
Precision: binary64
Cost: 7872

?

\[\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 \]
\[\begin{array}{l} \\ \frac{2}{r \cdot r} + \left(-1.5 - \frac{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}{\frac{1 - v}{\mathsf{fma}\left(v, -0.25, 0.375\right)}}\right) \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))
(FPCore (v w r)
 :precision binary64
 (+
  (/ 2.0 (* r r))
  (- -1.5 (/ (* (* r w) (* r w)) (/ (- 1.0 v) (fma v -0.25 0.375))))))
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;
}
double code(double v, double w, double r) {
	return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) / ((1.0 - v) / fma(v, -0.25, 0.375))));
}
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 code(v, w, r)
	return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) / Float64(Float64(1.0 - v) / fma(v, -0.25, 0.375)))))
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]
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] / N[(N[(1.0 - v), $MachinePrecision] / N[(v * -0.25 + 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\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
\begin{array}{l}

\\
\frac{2}{r \cdot r} + \left(-1.5 - \frac{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}{\frac{1 - v}{\mathsf{fma}\left(v, -0.25, 0.375\right)}}\right)
\end{array}

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.

Herbie found 9 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

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.

Bogosity?

Bogosity

Derivation?

  1. Initial program 85.9%

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

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

    [Start]85.9%

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

    associate--l- [=>]85.9%

    \[ \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)} \]

    +-commutative [=>]85.9%

    \[ \color{blue}{\left(\frac{2}{r \cdot r} + 3\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) \]

    associate--l+ [=>]85.9%

    \[ \color{blue}{\frac{2}{r \cdot r} + \left(3 - \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)\right)} \]

    +-commutative [=>]85.9%

    \[ \frac{2}{r \cdot r} + \left(3 - \color{blue}{\left(4.5 + \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)}\right) \]

    associate--r+ [=>]85.9%

    \[ \frac{2}{r \cdot r} + \color{blue}{\left(\left(3 - 4.5\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)} \]

    metadata-eval [=>]85.9%

    \[ \frac{2}{r \cdot r} + \left(\color{blue}{-1.5} - \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) \]

    associate-*l/ [<=]88.8%

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

    *-commutative [=>]88.8%

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

    *-commutative [=>]88.8%

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

    *-commutative [=>]88.8%

    \[ \frac{2}{r \cdot r} + \left(-1.5 - \left(r \cdot \color{blue}{\left(r \cdot \left(w \cdot w\right)\right)}\right) \cdot \frac{0.125 \cdot \left(3 - 2 \cdot v\right)}{1 - v}\right) \]
  3. Taylor expanded in r around 0 88.8%

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

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

    [Start]88.8%

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

    unpow2 [=>]88.8%

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

    associate-*l* [=>]97.1%

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

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \color{blue}{\frac{{\left(r \cdot w\right)}^{2}}{\frac{1 - v}{\mathsf{fma}\left(v, -0.25, 0.375\right)}}}\right) \]
    Step-by-step derivation

    [Start]97.1%

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

    clear-num [=>]97.1%

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

    un-div-inv [=>]97.1%

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

    associate-*r* [=>]99.8%

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

    *-commutative [<=]99.8%

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

    pow2 [=>]99.8%

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

    *-commutative [=>]99.8%

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

    +-commutative [=>]99.8%

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

    fma-def [=>]99.8%

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

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

    [Start]99.8%

    \[ \frac{2}{r \cdot r} + \left(-1.5 - \frac{{\left(r \cdot w\right)}^{2}}{\frac{1 - v}{\mathsf{fma}\left(v, -0.25, 0.375\right)}}\right) \]

    unpow2 [=>]99.8%

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

    \[\leadsto \frac{2}{r \cdot r} + \left(-1.5 - \frac{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}{\frac{1 - v}{\mathsf{fma}\left(v, -0.25, 0.375\right)}}\right) \]

Alternatives

Alternative 1
Accuracy99.8%
Cost7872
\[\frac{2}{r \cdot r} + \left(-1.5 - \frac{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}{\frac{1 - v}{\mathsf{fma}\left(v, -0.25, 0.375\right)}}\right) \]
Alternative 2
Accuracy96.8%
Cost1600
\[\frac{2}{r \cdot r} + \left(-1.5 - \frac{0.375 + v \cdot -0.25}{1 - v} \cdot \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right)\right) \]
Alternative 3
Accuracy99.8%
Cost1600
\[\frac{2}{r \cdot r} + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot \frac{0.375 + v \cdot -0.25}{1 - v}\right) \]
Alternative 4
Accuracy96.5%
Cost1481
\[\begin{array}{l} t_0 := w \cdot \left(r \cdot w\right)\\ t_1 := \frac{2}{r \cdot r} + 3\\ \mathbf{if}\;v \leq -3600000000000 \lor \neg \left(v \leq 0.005\right):\\ \;\;\;\;\left(t_1 - r \cdot \left(t_0 \cdot 0.25\right)\right) + -4.5\\ \mathbf{else}:\\ \;\;\;\;-4.5 + \left(t_1 - 0.375 \cdot \left(r \cdot t_0\right)\right)\\ \end{array} \]
Alternative 5
Accuracy85.4%
Cost1353
\[\begin{array}{l} \mathbf{if}\;r \leq -1.8 \cdot 10^{-114} \lor \neg \left(r \leq 4.8 \cdot 10^{-135}\right):\\ \;\;\;\;\frac{2}{r \cdot r} + \left(\left(\left(r \cdot r\right) \cdot \left(w \cdot w\right)\right) \cdot -0.375 - 1.5\right)\\ \mathbf{else}:\\ \;\;\;\;-1.5 + \frac{\frac{2}{r}}{r}\\ \end{array} \]
Alternative 6
Accuracy85.1%
Cost1353
\[\begin{array}{l} \mathbf{if}\;r \leq -2.3 \cdot 10^{-115} \lor \neg \left(r \leq 1.65 \cdot 10^{-137}\right):\\ \;\;\;\;\frac{2}{r \cdot r} + \left(-0.25 \cdot \left(\left(r \cdot r\right) \cdot \left(w \cdot w\right)\right) - 1.5\right)\\ \mathbf{else}:\\ \;\;\;\;-1.5 + \frac{\frac{2}{r}}{r}\\ \end{array} \]
Alternative 7
Accuracy90.8%
Cost1216
\[\left(\left(\frac{2}{r \cdot r} + 3\right) - r \cdot \left(\left(w \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\right) + -4.5 \]
Alternative 8
Accuracy57.3%
Cost448
\[\frac{2}{r \cdot r} + -1.5 \]
Alternative 9
Accuracy57.3%
Cost448
\[-1.5 + \frac{\frac{2}{r}}{r} \]

Reproduce?

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