
(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:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) (+ (* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (* w (/ 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))) * ((r * w) * (w * (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))) * ((r * w) * (w * (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))) * ((r * w) * (w * (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))) * ((r * w) * (w * (r / (1.0 - v))))) + 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(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))) * ((r * w) * (w * (r / (1.0 - v))))) + 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[(r / N[(1.0 - v), $MachinePrecision]), $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 \left(w \cdot \frac{r}{1 - v}\right)\right) + 4.5\right)
\end{array}
Initial program 86.8%
associate--l-86.8%
associate-*l*81.6%
sqr-neg81.6%
associate-*l*86.8%
+-commutative86.8%
+-commutative86.8%
associate-/l*89.3%
fma-define89.3%
Simplified89.3%
associate-/l*88.6%
*-commutative88.6%
associate-*r/88.2%
associate-*l*95.7%
associate-*r*99.2%
Applied egg-rr99.2%
(FPCore (v w r) :precision binary64 (+ (+ 3.0 (/ 2.0 (* r r))) (- (* (* 0.125 (+ 3.0 (* -2.0 v))) (* w (* r (* w (/ r (+ v -1.0)))))) 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 * (r * (w * (r / (v + -1.0)))))) - 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 * (r * (w * (r / (v + (-1.0d0))))))) - 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 * (r * (w * (r / (v + -1.0)))))) - 4.5);
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * (w * (r * (w * (r / (v + -1.0)))))) - 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(w * Float64(r * Float64(w * Float64(r / Float64(v + -1.0)))))) - 4.5)) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * (w * (r * (w * (r / (v + -1.0)))))) - 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[(w * N[(r * N[(w * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $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(w \cdot \left(r \cdot \left(w \cdot \frac{r}{v + -1}\right)\right)\right) - 4.5\right)
\end{array}
Initial program 86.8%
associate--l-86.8%
associate-*l*81.6%
sqr-neg81.6%
associate-*l*86.8%
+-commutative86.8%
+-commutative86.8%
associate-/l*89.3%
fma-define89.3%
Simplified89.3%
associate-/l*88.6%
*-commutative88.6%
associate-*r/88.2%
*-commutative88.2%
associate-*l*95.7%
associate-*l*97.8%
Applied egg-rr97.8%
Final simplification97.8%
(FPCore (v w r)
:precision binary64
(if (<= r 300000.0)
(+ (/ 2.0 (* r r)) (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(-
3.0
(+
(* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (* w (/ r (- 1.0 v)))))
4.5))))
double code(double v, double w, double r) {
double tmp;
if (r <= 300000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = 3.0 - (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))) + 4.5);
}
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) :: tmp
if (r <= 300000.0d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
else
tmp = 3.0d0 - (((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * ((r * w) * (w * (r / (1.0d0 - v))))) + 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 300000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = 3.0 - (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))) + 4.5);
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 300000.0: tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = 3.0 - (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))) + 4.5) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 300000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(3.0 - Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(r * w) * Float64(w * Float64(r / Float64(1.0 - v))))) + 4.5)); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 300000.0) tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = 3.0 - (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))) + 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 300000.0], 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], N[(3.0 - N[(N[(N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(w * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 300000:\\
\;\;\;\;\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)\\
\mathbf{else}:\\
\;\;\;\;3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \left(w \cdot \frac{r}{1 - v}\right)\right) + 4.5\right)\\
\end{array}
\end{array}
if r < 3e5Initial program 85.6%
Simplified86.1%
Taylor expanded in v around inf 82.6%
*-commutative82.6%
unpow282.6%
unpow282.6%
swap-sqr96.5%
unpow296.5%
Simplified96.5%
unpow296.5%
Applied egg-rr96.5%
if 3e5 < r Initial program 90.3%
associate--l-90.3%
associate-*l*74.2%
sqr-neg74.2%
associate-*l*90.3%
+-commutative90.3%
+-commutative90.3%
associate-/l*96.1%
fma-define96.0%
Simplified96.1%
associate-/l*94.6%
*-commutative94.6%
associate-*r/94.6%
associate-*l*96.3%
associate-*r*99.8%
Applied egg-rr99.8%
Taylor expanded in r around inf 99.8%
(FPCore (v w r)
:precision binary64
(if (<= r 880000.0)
(+ (/ 2.0 (* r r)) (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(+
3.0
(-
(* (* 0.125 (+ 3.0 (* -2.0 v))) (* w (* r (* w (/ r (+ v -1.0))))))
4.5))))
double code(double v, double w, double r) {
double tmp;
if (r <= 880000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (-2.0 * v))) * (w * (r * (w * (r / (v + -1.0)))))) - 4.5);
}
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) :: tmp
if (r <= 880000.0d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
else
tmp = 3.0d0 + (((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * (w * (r * (w * (r / (v + (-1.0d0))))))) - 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 880000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (-2.0 * v))) * (w * (r * (w * (r / (v + -1.0)))))) - 4.5);
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 880000.0: tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = 3.0 + (((0.125 * (3.0 + (-2.0 * v))) * (w * (r * (w * (r / (v + -1.0)))))) - 4.5) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 880000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(3.0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(w * Float64(r * Float64(w * Float64(r / Float64(v + -1.0)))))) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 880000.0) tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = 3.0 + (((0.125 * (3.0 + (-2.0 * v))) * (w * (r * (w * (r / (v + -1.0)))))) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 880000.0], 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], N[(3.0 + N[(N[(N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w * N[(r * N[(w * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 880000:\\
\;\;\;\;\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)\\
\mathbf{else}:\\
\;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(w \cdot \left(r \cdot \left(w \cdot \frac{r}{v + -1}\right)\right)\right) - 4.5\right)\\
\end{array}
\end{array}
if r < 8.8e5Initial program 85.6%
Simplified86.1%
Taylor expanded in v around inf 82.6%
*-commutative82.6%
unpow282.6%
unpow282.6%
swap-sqr96.5%
unpow296.5%
Simplified96.5%
unpow296.5%
Applied egg-rr96.5%
if 8.8e5 < r Initial program 90.3%
associate--l-90.3%
associate-*l*74.2%
sqr-neg74.2%
associate-*l*90.3%
+-commutative90.3%
+-commutative90.3%
associate-/l*96.1%
fma-define96.0%
Simplified96.1%
Taylor expanded in r around inf 96.1%
associate-/l*94.6%
*-commutative94.6%
associate-*r/94.6%
*-commutative94.6%
associate-*l*96.3%
associate-*l*95.6%
Applied egg-rr95.6%
Final simplification96.3%
(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}
Initial program 86.8%
Simplified88.2%
Taylor expanded in v around inf 79.6%
*-commutative79.6%
unpow279.6%
unpow279.6%
swap-sqr95.2%
unpow295.2%
Simplified95.2%
unpow295.2%
Applied egg-rr95.2%
(FPCore (v w r) :precision binary64 (if (<= r 1.15) (/ (- -2.0) (* r r)) -1.5))
double code(double v, double w, double r) {
double tmp;
if (r <= 1.15) {
tmp = -(-2.0) / (r * r);
} else {
tmp = -1.5;
}
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) :: tmp
if (r <= 1.15d0) then
tmp = -(-2.0d0) / (r * r)
else
tmp = -1.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 1.15) {
tmp = -(-2.0) / (r * r);
} else {
tmp = -1.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 1.15: tmp = -(-2.0) / (r * r) else: tmp = -1.5 return tmp
function code(v, w, r) tmp = 0.0 if (r <= 1.15) tmp = Float64(Float64(-(-2.0)) / Float64(r * r)); else tmp = -1.5; end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 1.15) tmp = -(-2.0) / (r * r); else tmp = -1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 1.15], N[((--2.0) / N[(r * r), $MachinePrecision]), $MachinePrecision], -1.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 1.15:\\
\;\;\;\;\frac{--2}{r \cdot r}\\
\mathbf{else}:\\
\;\;\;\;-1.5\\
\end{array}
\end{array}
if r < 1.1499999999999999Initial program 85.6%
Simplified83.0%
Taylor expanded in r around 0 75.3%
Taylor expanded in r around 0 67.7%
metadata-eval67.7%
associate-*r/67.7%
unpow267.7%
associate-/r*67.6%
*-lft-identity67.6%
associate-*l/67.5%
unpow-167.5%
unpow-167.5%
pow-sqr67.7%
metadata-eval67.7%
Simplified67.7%
metadata-eval67.7%
pow-flip67.7%
pow267.7%
div-inv67.7%
metadata-eval67.7%
frac-times67.5%
frac-2neg67.5%
metadata-eval67.5%
frac-times67.7%
metadata-eval67.7%
Applied egg-rr67.7%
if 1.1499999999999999 < r Initial program 90.3%
Simplified75.3%
Taylor expanded in r around 0 29.9%
Taylor expanded in r around inf 29.9%
Final simplification58.2%
(FPCore (v w r) :precision binary64 (if (<= r 1.15) (/ (/ 2.0 r) r) -1.5))
double code(double v, double w, double r) {
double tmp;
if (r <= 1.15) {
tmp = (2.0 / r) / r;
} else {
tmp = -1.5;
}
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) :: tmp
if (r <= 1.15d0) then
tmp = (2.0d0 / r) / r
else
tmp = -1.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 1.15) {
tmp = (2.0 / r) / r;
} else {
tmp = -1.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 1.15: tmp = (2.0 / r) / r else: tmp = -1.5 return tmp
function code(v, w, r) tmp = 0.0 if (r <= 1.15) tmp = Float64(Float64(2.0 / r) / r); else tmp = -1.5; end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 1.15) tmp = (2.0 / r) / r; else tmp = -1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 1.15], N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision], -1.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 1.15:\\
\;\;\;\;\frac{\frac{2}{r}}{r}\\
\mathbf{else}:\\
\;\;\;\;-1.5\\
\end{array}
\end{array}
if r < 1.1499999999999999Initial program 85.6%
Simplified83.0%
Taylor expanded in r around 0 75.3%
Taylor expanded in r around 0 67.7%
metadata-eval67.7%
associate-*r/67.7%
unpow267.7%
associate-/r*67.6%
*-lft-identity67.6%
associate-*l/67.5%
unpow-167.5%
unpow-167.5%
pow-sqr67.7%
metadata-eval67.7%
Simplified67.7%
metadata-eval67.7%
pow-flip67.7%
pow267.7%
div-inv67.7%
associate-/r*67.6%
Applied egg-rr67.6%
if 1.1499999999999999 < r Initial program 90.3%
Simplified75.3%
Taylor expanded in r around 0 29.9%
Taylor expanded in r around inf 29.9%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) 4.5))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * 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))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - 4.5;
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) - 4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - 4.5) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) - 4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) - 4.5
\end{array}
Initial program 86.8%
Simplified81.1%
Taylor expanded in r around 0 64.0%
(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}
Initial program 86.8%
Simplified81.1%
Taylor expanded in r around 0 64.0%
Taylor expanded in r around inf 13.7%
herbie shell --seed 2024160
(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))