?

Average Error: 12.8 → 0.3
Time: 1.8min
Precision: binary64
Cost: 20608

?

\[\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 \]
\[-\left(1.5 - \left(2 \cdot {r}^{-2} - {\left(w \cdot r\right)}^{2} \cdot \frac{\mathsf{fma}\left(v, 2, -3\right) \cdot -0.125}{1 - v}\right)\right) \]
(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
 (-
  (-
   1.5
   (-
    (* 2.0 (pow r -2.0))
    (* (pow (* w r) 2.0) (/ (* (fma v 2.0 -3.0) -0.125) (- 1.0 v)))))))
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 -(1.5 - ((2.0 * pow(r, -2.0)) - (pow((w * r), 2.0) * ((fma(v, 2.0, -3.0) * -0.125) / (1.0 - v)))));
}
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(1.5 - Float64(Float64(2.0 * (r ^ -2.0)) - Float64((Float64(w * r) ^ 2.0) * Float64(Float64(fma(v, 2.0, -3.0) * -0.125) / Float64(1.0 - v))))))
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[(1.5 - N[(N[(2.0 * N[Power[r, -2.0], $MachinePrecision]), $MachinePrecision] - N[(N[Power[N[(w * r), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(N[(v * 2.0 + -3.0), $MachinePrecision] * -0.125), $MachinePrecision] / N[(1.0 - v), $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
-\left(1.5 - \left(2 \cdot {r}^{-2} - {\left(w \cdot r\right)}^{2} \cdot \frac{\mathsf{fma}\left(v, 2, -3\right) \cdot -0.125}{1 - v}\right)\right)

Error?

Derivation?

  1. Initial program 12.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. Simplified0.4

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

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

Alternatives

Alternative 1
Error0.4
Cost14272
\[-\left(1.5 - \left(\frac{\frac{2}{r}}{r} - {\left(w \cdot r\right)}^{2} \cdot \frac{\mathsf{fma}\left(v, 2, -3\right) \cdot -0.125}{1 - v}\right)\right) \]
Alternative 2
Error0.4
Cost8324
\[\begin{array}{l} t_0 := {\left(w \cdot r\right)}^{2}\\ t_1 := 0.375 + -0.25 \cdot v\\ \left(\left(3 + \frac{2}{r \cdot r}\right) - \begin{array}{l} \mathbf{if}\;t_1 \ne 0:\\ \;\;\;\;\frac{t_0}{\frac{1 - v}{t_1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1 \cdot t_0}{1 - v}\\ \end{array}\right) - 4.5 \end{array} \]
Alternative 3
Error0.5
Cost7884
\[\begin{array}{l} t_0 := \frac{2}{r \cdot r}\\ t_1 := -\left(1.5 - \left(t_0 - \begin{array}{l} \mathbf{if}\;w \cdot r \ne 0:\\ \;\;\;\;\frac{w \cdot r}{\frac{1}{w \cdot r}}\\ \mathbf{else}:\\ \;\;\;\;{\left(w \cdot r\right)}^{2}\\ \end{array} \cdot 0.25\right)\right)\\ \mathbf{if}\;v \leq -1.8 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;v \leq 4 \cdot 10^{+62}:\\ \;\;\;\;\left(\left(3 + t_0\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right)}{1 - v}\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error0.9
Cost2120
\[\begin{array}{l} t_0 := \left(w \cdot r\right) \cdot \left(w \cdot r\right)\\ t_1 := \frac{2}{r \cdot r}\\ t_2 := -\left(1.5 - \left(t_1 - t_0 \cdot 0.25\right)\right)\\ \mathbf{if}\;v \leq -1 \cdot 10^{+77}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;v \leq 4.5 \cdot 10^{+86}:\\ \;\;\;\;\left(\left(3 + t_1\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot t_0}{1 - v}\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error1.5
Cost1992
\[\begin{array}{l} t_0 := \frac{2}{r \cdot r}\\ t_1 := -\left(1.5 - \left(t_0 - \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right) \cdot 0.25\right)\right)\\ \mathbf{if}\;v \leq -1.1 \cdot 10^{+24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;v \leq 2 \cdot 10^{+25}:\\ \;\;\;\;\left(\left(3 + t_0\right) - \left(\left(0.375 + -0.25 \cdot v\right) \cdot \left(\left(r \cdot w\right) \cdot w\right)\right) \cdot \frac{r}{1 - v}\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error9.3
Cost1152
\[-\left(1.5 - \left(\frac{2}{r \cdot r} - \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right) \cdot 0.25\right)\right) \]
Alternative 7
Error21.2
Cost512
\[-\left(1.5 - \frac{2}{r \cdot r}\right) \]

Error

Reproduce?

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