
(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 (+ (* (/ (fma v 0.25 -0.375) (- 1.0 v)) (pow (* r w) 2.0)) (fma 2.0 (pow r -2.0) -1.5)))
double code(double v, double w, double r) {
return ((fma(v, 0.25, -0.375) / (1.0 - v)) * pow((r * w), 2.0)) + fma(2.0, pow(r, -2.0), -1.5);
}
function code(v, w, r) return Float64(Float64(Float64(fma(v, 0.25, -0.375) / Float64(1.0 - v)) * (Float64(r * w) ^ 2.0)) + fma(2.0, (r ^ -2.0), -1.5)) end
code[v_, w_, r_] := N[(N[(N[(N[(v * 0.25 + -0.375), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[Power[r, -2.0], $MachinePrecision] + -1.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(v, 0.25, -0.375\right)}{1 - v} \cdot {\left(r \cdot w\right)}^{2} + \mathsf{fma}\left(2, {r}^{-2}, -1.5\right)
\end{array}
Initial program 85.2%
sub-neg85.2%
+-commutative85.2%
associate--l+85.2%
associate-/l*87.8%
distribute-neg-frac87.8%
associate-/r/87.8%
fma-def87.8%
sub-neg87.8%
Simplified79.9%
fma-udef79.9%
unswap-sqr99.8%
pow299.8%
div-inv99.8%
fma-def99.8%
pow299.8%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= (* w w) 5e-316)
(+ t_0 (- -1.5 (* 0.375 (* r (* w (* r w))))))
(if (<= (* w w) 1e+297)
(+
t_0
(- -1.5 (* (/ (+ 0.375 (* v -0.25)) (- 1.0 v)) (* r (* r (* w w))))))
(+ t_0 (- -1.5 (* 0.375 (* (* r w) (* r w)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((w * w) <= 5e-316) {
tmp = t_0 + (-1.5 - (0.375 * (r * (w * (r * w)))));
} else if ((w * w) <= 1e+297) {
tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w)))));
} else {
tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w))));
}
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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if ((w * w) <= 5d-316) then
tmp = t_0 + ((-1.5d0) - (0.375d0 * (r * (w * (r * w)))))
else if ((w * w) <= 1d+297) then
tmp = t_0 + ((-1.5d0) - (((0.375d0 + (v * (-0.25d0))) / (1.0d0 - v)) * (r * (r * (w * w)))))
else
tmp = t_0 + ((-1.5d0) - (0.375d0 * ((r * w) * (r * w))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((w * w) <= 5e-316) {
tmp = t_0 + (-1.5 - (0.375 * (r * (w * (r * w)))));
} else if ((w * w) <= 1e+297) {
tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w)))));
} else {
tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (w * w) <= 5e-316: tmp = t_0 + (-1.5 - (0.375 * (r * (w * (r * w))))) elif (w * w) <= 1e+297: tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w))))) else: tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(w * w) <= 5e-316) tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(r * Float64(w * Float64(r * w)))))); elseif (Float64(w * w) <= 1e+297) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(1.0 - v)) * Float64(r * Float64(r * Float64(w * w)))))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * w) * Float64(r * w))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((w * w) <= 5e-316) tmp = t_0 + (-1.5 - (0.375 * (r * (w * (r * w))))); elseif ((w * w) <= 1e+297) tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w))))); else tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w)))); end tmp_2 = 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-316], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(w * w), $MachinePrecision], 1e+297], N[(t$95$0 + N[(-1.5 - N[(N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \cdot w \leq 5 \cdot 10^{-316}:\\
\;\;\;\;t_0 + \left(-1.5 - 0.375 \cdot \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right)\right)\\
\mathbf{elif}\;w \cdot w \leq 10^{+297}:\\
\;\;\;\;t_0 + \left(-1.5 - \frac{0.375 + v \cdot -0.25}{1 - v} \cdot \left(r \cdot \left(r \cdot \left(w \cdot w\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 w w) < 5.000000017e-316Initial program 81.7%
associate--l-81.7%
+-commutative81.7%
associate--l+81.8%
+-commutative81.8%
associate--r+81.8%
metadata-eval81.8%
associate-*l/81.8%
*-commutative81.8%
*-commutative81.8%
*-commutative81.8%
Simplified81.8%
Taylor expanded in r around 0 81.8%
*-commutative81.8%
unpow281.8%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in v around 0 63.6%
*-commutative63.6%
unpow263.6%
unpow263.6%
swap-sqr92.5%
unpow292.5%
*-commutative92.5%
Simplified92.5%
unpow292.5%
*-commutative92.5%
*-commutative92.5%
associate-*r*92.5%
*-commutative92.5%
Applied egg-rr92.5%
if 5.000000017e-316 < (*.f64 w w) < 1e297Initial program 94.2%
associate--l-94.2%
+-commutative94.2%
associate--l+94.2%
+-commutative94.2%
associate--r+94.2%
metadata-eval94.2%
associate-*l/99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
if 1e297 < (*.f64 w w) Initial program 73.2%
associate--l-73.2%
+-commutative73.2%
associate--l+73.2%
+-commutative73.2%
associate--r+73.2%
metadata-eval73.2%
associate-*l/73.2%
*-commutative73.2%
*-commutative73.2%
*-commutative73.2%
Simplified73.2%
Taylor expanded in r around 0 73.2%
*-commutative73.2%
unpow273.2%
associate-*r*95.9%
*-commutative95.9%
Simplified95.9%
Taylor expanded in v around 0 73.2%
*-commutative73.2%
unpow273.2%
unpow273.2%
swap-sqr97.6%
unpow297.6%
*-commutative97.6%
Simplified97.6%
unpow297.6%
*-commutative97.6%
*-commutative97.6%
Applied egg-rr97.6%
Final simplification97.3%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* (/ (+ 0.375 (* v -0.25)) (- 1.0 v)) (* r (* w (* r w)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (w * (r * w)))));
}
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) - (((0.375d0 + (v * (-0.25d0))) / (1.0d0 - v)) * (r * (w * (r * w)))))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (w * (r * w)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (w * (r * w)))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(1.0 - v)) * Float64(r * Float64(w * Float64(r * w)))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (w * (r * w))))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\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)
\end{array}
Initial program 85.2%
associate--l-85.2%
+-commutative85.2%
associate--l+85.2%
+-commutative85.2%
associate--r+85.2%
metadata-eval85.2%
associate-*l/87.8%
*-commutative87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in r around 0 87.8%
*-commutative87.8%
unpow287.8%
associate-*r*98.7%
*-commutative98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* 0.375 (* (* r w) (* r w))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * (r * w))));
}
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) - (0.375d0 * ((r * w) * (r * w))))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * (r * w))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * (r * w))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * w) * Float64(r * w))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * (r * w)))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right)
\end{array}
Initial program 85.2%
associate--l-85.2%
+-commutative85.2%
associate--l+85.2%
+-commutative85.2%
associate--r+85.2%
metadata-eval85.2%
associate-*l/87.8%
*-commutative87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in r around 0 87.8%
*-commutative87.8%
unpow287.8%
associate-*r*98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in v around 0 77.9%
*-commutative77.9%
unpow277.9%
unpow277.9%
swap-sqr93.8%
unpow293.8%
*-commutative93.8%
Simplified93.8%
unpow293.8%
*-commutative93.8%
*-commutative93.8%
Applied egg-rr93.8%
Final simplification93.8%
(FPCore (v w r) :precision binary64 (if (<= r 9e+36) (+ -1.5 (/ 2.0 (* r r))) (* (* r r) (* -0.25 (* w w)))))
double code(double v, double w, double r) {
double tmp;
if (r <= 9e+36) {
tmp = -1.5 + (2.0 / (r * r));
} else {
tmp = (r * r) * (-0.25 * (w * w));
}
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 <= 9d+36) then
tmp = (-1.5d0) + (2.0d0 / (r * r))
else
tmp = (r * r) * ((-0.25d0) * (w * w))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 9e+36) {
tmp = -1.5 + (2.0 / (r * r));
} else {
tmp = (r * r) * (-0.25 * (w * w));
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 9e+36: tmp = -1.5 + (2.0 / (r * r)) else: tmp = (r * r) * (-0.25 * (w * w)) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 9e+36) tmp = Float64(-1.5 + Float64(2.0 / Float64(r * r))); else tmp = Float64(Float64(r * r) * Float64(-0.25 * Float64(w * w))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 9e+36) tmp = -1.5 + (2.0 / (r * r)); else tmp = (r * r) * (-0.25 * (w * w)); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 9e+36], N[(-1.5 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * r), $MachinePrecision] * N[(-0.25 * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 9 \cdot 10^{+36}:\\
\;\;\;\;-1.5 + \frac{2}{r \cdot r}\\
\mathbf{else}:\\
\;\;\;\;\left(r \cdot r\right) \cdot \left(-0.25 \cdot \left(w \cdot w\right)\right)\\
\end{array}
\end{array}
if r < 8.99999999999999994e36Initial program 84.5%
sub-neg84.5%
+-commutative84.5%
associate--l+84.5%
associate-/l*86.0%
distribute-neg-frac86.0%
associate-/r/86.1%
fma-def86.1%
sub-neg86.1%
Simplified81.8%
Taylor expanded in r around 0 66.2%
sub-neg66.2%
associate-*r/66.2%
metadata-eval66.2%
unpow266.2%
metadata-eval66.2%
Simplified66.2%
if 8.99999999999999994e36 < r Initial program 87.2%
sub-neg87.2%
+-commutative87.2%
associate--l+87.2%
associate-/l*92.9%
distribute-neg-frac92.9%
associate-/r/92.9%
fma-def92.9%
sub-neg92.9%
Simplified74.5%
Taylor expanded in v around inf 69.7%
associate--l+69.7%
associate-*r/69.7%
metadata-eval69.7%
unpow269.7%
*-commutative69.7%
unpow269.7%
unpow269.7%
Simplified69.7%
Taylor expanded in r around inf 56.5%
unpow256.5%
unpow256.5%
associate-*r*56.5%
Simplified56.5%
Final simplification63.7%
(FPCore (v w r) :precision binary64 (if (<= r 8.2e+38) (+ -1.5 (/ 2.0 (* r r))) (* -0.375 (* (* r r) (* w w)))))
double code(double v, double w, double r) {
double tmp;
if (r <= 8.2e+38) {
tmp = -1.5 + (2.0 / (r * r));
} else {
tmp = -0.375 * ((r * r) * (w * w));
}
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 <= 8.2d+38) then
tmp = (-1.5d0) + (2.0d0 / (r * r))
else
tmp = (-0.375d0) * ((r * r) * (w * w))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 8.2e+38) {
tmp = -1.5 + (2.0 / (r * r));
} else {
tmp = -0.375 * ((r * r) * (w * w));
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 8.2e+38: tmp = -1.5 + (2.0 / (r * r)) else: tmp = -0.375 * ((r * r) * (w * w)) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 8.2e+38) tmp = Float64(-1.5 + Float64(2.0 / Float64(r * r))); else tmp = Float64(-0.375 * Float64(Float64(r * r) * Float64(w * w))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 8.2e+38) tmp = -1.5 + (2.0 / (r * r)); else tmp = -0.375 * ((r * r) * (w * w)); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 8.2e+38], N[(-1.5 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.375 * N[(N[(r * r), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 8.2 \cdot 10^{+38}:\\
\;\;\;\;-1.5 + \frac{2}{r \cdot r}\\
\mathbf{else}:\\
\;\;\;\;-0.375 \cdot \left(\left(r \cdot r\right) \cdot \left(w \cdot w\right)\right)\\
\end{array}
\end{array}
if r < 8.2000000000000007e38Initial program 84.5%
sub-neg84.5%
+-commutative84.5%
associate--l+84.5%
associate-/l*86.0%
distribute-neg-frac86.0%
associate-/r/86.1%
fma-def86.1%
sub-neg86.1%
Simplified81.8%
Taylor expanded in r around 0 66.2%
sub-neg66.2%
associate-*r/66.2%
metadata-eval66.2%
unpow266.2%
metadata-eval66.2%
Simplified66.2%
if 8.2000000000000007e38 < r Initial program 87.2%
associate--l-87.2%
+-commutative87.2%
associate--l+87.2%
+-commutative87.2%
associate--r+87.2%
metadata-eval87.2%
associate-*l/92.9%
*-commutative92.9%
*-commutative92.9%
*-commutative92.9%
Simplified92.9%
Taylor expanded in r around 0 92.9%
*-commutative92.9%
unpow292.9%
associate-*r*99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in v around 0 70.8%
*-commutative70.8%
unpow270.8%
unpow270.8%
swap-sqr90.2%
unpow290.2%
*-commutative90.2%
Simplified90.2%
unpow290.2%
*-commutative90.2%
*-commutative90.2%
Applied egg-rr90.2%
Taylor expanded in r around inf 56.9%
*-commutative56.9%
unpow256.9%
unpow256.9%
*-commutative56.9%
Simplified56.9%
Final simplification63.8%
(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(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 83.6%
sub-neg83.6%
+-commutative83.6%
associate--l+83.6%
associate-/l*85.2%
distribute-neg-frac85.2%
associate-/r/85.2%
fma-def85.2%
sub-neg85.2%
Simplified80.7%
Taylor expanded in v around 0 79.2%
associate--l+79.2%
associate-*r/79.2%
metadata-eval79.2%
unpow279.2%
*-commutative79.2%
unpow279.2%
unpow279.2%
Simplified79.2%
Taylor expanded in r around 0 58.2%
unpow258.2%
Simplified58.2%
if 1.1499999999999999 < r Initial program 89.0%
sub-neg89.0%
+-commutative89.0%
associate--l+89.0%
associate-/l*93.9%
distribute-neg-frac93.9%
associate-/r/93.9%
fma-def93.9%
sub-neg93.9%
Simplified78.1%
Taylor expanded in r around 0 32.8%
sub-neg32.8%
associate-*r/32.8%
metadata-eval32.8%
unpow232.8%
metadata-eval32.8%
Simplified32.8%
Taylor expanded in r around inf 32.8%
Final simplification50.6%
(FPCore (v w r) :precision binary64 (+ -1.5 (/ 2.0 (* r r))))
double code(double v, double w, double r) {
return -1.5 + (2.0 / (r * r));
}
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) + (2.0d0 / (r * r))
end function
public static double code(double v, double w, double r) {
return -1.5 + (2.0 / (r * r));
}
def code(v, w, r): return -1.5 + (2.0 / (r * r))
function code(v, w, r) return Float64(-1.5 + Float64(2.0 / Float64(r * r))) end
function tmp = code(v, w, r) tmp = -1.5 + (2.0 / (r * r)); end
code[v_, w_, r_] := N[(-1.5 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1.5 + \frac{2}{r \cdot r}
\end{array}
Initial program 85.2%
sub-neg85.2%
+-commutative85.2%
associate--l+85.2%
associate-/l*87.8%
distribute-neg-frac87.8%
associate-/r/87.8%
fma-def87.8%
sub-neg87.8%
Simplified79.9%
Taylor expanded in r around 0 56.6%
sub-neg56.6%
associate-*r/56.6%
metadata-eval56.6%
unpow256.6%
metadata-eval56.6%
Simplified56.6%
Final simplification56.6%
(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 85.2%
sub-neg85.2%
+-commutative85.2%
associate--l+85.2%
associate-/l*87.8%
distribute-neg-frac87.8%
associate-/r/87.8%
fma-def87.8%
sub-neg87.8%
Simplified79.9%
Taylor expanded in r around 0 56.6%
sub-neg56.6%
associate-*r/56.6%
metadata-eval56.6%
unpow256.6%
metadata-eval56.6%
Simplified56.6%
Taylor expanded in r around inf 16.2%
Final simplification16.2%
herbie shell --seed 2023207
(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))