
(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 10 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 88.4%
sub-neg88.4%
+-commutative88.4%
associate--l+88.4%
associate-/l*91.3%
distribute-neg-frac91.3%
associate-/r/91.3%
fma-def91.3%
sub-neg91.3%
Simplified84.5%
fma-udef84.5%
unswap-sqr99.8%
pow299.8%
div-inv99.8%
fma-def99.8%
pow299.7%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (- (+ 3.0 (/ 2.0 (* r r))) (/ (* 0.125 (+ 3.0 (* v -2.0))) (/ (- 1.0 v) (pow (* r w) 2.0)))) -4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) / pow((r * w), 2.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 + (v * (-2.0d0)))) / ((1.0d0 - v) / ((r * w) ** 2.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 + (v * -2.0))) / ((1.0 - v) / Math.pow((r * w), 2.0)))) + -4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) / math.pow((r * w), 2.0)))) + -4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) / Float64(Float64(1.0 - v) / (Float64(r * w) ^ 2.0)))) + -4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) / ((r * w) ^ 2.0)))) + -4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] / N[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{\frac{1 - v}{{\left(r \cdot w\right)}^{2}}}\right) + -4.5
\end{array}
Initial program 88.4%
sub-neg88.4%
associate-/l*91.3%
cancel-sign-sub-inv91.3%
metadata-eval91.3%
*-commutative91.3%
*-commutative91.3%
metadata-eval91.3%
Simplified91.3%
Taylor expanded in r around 0 84.5%
*-commutative84.5%
unpow284.5%
unpow284.5%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= (* w w) 5e+270)
(+
t_0
(- -1.5 (* (* r (* w (* r w))) (/ (+ 0.375 (* v -0.25)) (- 1.0 v)))))
(+ t_0 (* (pow (* r w) 2.0) -0.25)))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((w * w) <= 5e+270) {
tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} else {
tmp = t_0 + (pow((r * w), 2.0) * -0.25);
}
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+270) then
tmp = t_0 + ((-1.5d0) - ((r * (w * (r * w))) * ((0.375d0 + (v * (-0.25d0))) / (1.0d0 - v))))
else
tmp = t_0 + (((r * w) ** 2.0d0) * (-0.25d0))
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+270) {
tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} else {
tmp = t_0 + (Math.pow((r * w), 2.0) * -0.25);
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (w * w) <= 5e+270: tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))) else: tmp = t_0 + (math.pow((r * w), 2.0) * -0.25) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(w * w) <= 5e+270) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(r * Float64(w * Float64(r * w))) * Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(1.0 - v))))); else tmp = Float64(t_0 + Float64((Float64(r * w) ^ 2.0) * -0.25)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((w * w) <= 5e+270) tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))); else tmp = t_0 + (((r * w) ^ 2.0) * -0.25); 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+270], N[(t$95$0 + N[(-1.5 - N[(N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(N[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \cdot w \leq 5 \cdot 10^{+270}:\\
\;\;\;\;t_0 + \left(-1.5 - \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot \frac{0.375 + v \cdot -0.25}{1 - v}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + {\left(r \cdot w\right)}^{2} \cdot -0.25\\
\end{array}
\end{array}
if (*.f64 w w) < 4.99999999999999976e270Initial program 92.4%
associate--l-92.4%
+-commutative92.4%
associate--l+92.4%
+-commutative92.4%
associate--r+92.4%
metadata-eval92.4%
associate-*l/95.7%
*-commutative95.7%
*-commutative95.7%
*-commutative95.7%
Simplified95.7%
Taylor expanded in r around 0 95.7%
*-commutative95.7%
unpow295.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
if 4.99999999999999976e270 < (*.f64 w w) Initial program 75.4%
sub-neg75.4%
+-commutative75.4%
associate--l+75.4%
associate-/l*76.9%
distribute-neg-frac76.9%
associate-/r/76.9%
fma-def76.9%
sub-neg76.9%
Simplified77.0%
Taylor expanded in v around inf 77.0%
associate--l+77.0%
associate-*r/77.0%
metadata-eval77.0%
unpow277.0%
*-commutative77.0%
unpow277.0%
unpow277.0%
Simplified77.0%
Taylor expanded in w around inf 77.0%
unpow277.0%
unpow277.0%
*-commutative77.0%
swap-sqr98.6%
unpow298.6%
*-commutative98.6%
Simplified98.6%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= (* w w) 5e-318)
(+ t_0 (- -1.5 (* 0.375 (* (* r w) (* r w)))))
(if (<= (* w w) 1e+278)
(+
t_0
(- -1.5 (* (/ (+ 0.375 (* v -0.25)) (- 1.0 v)) (* r (* r (* w w))))))
(+ t_0 (- -1.5 (* 0.375 (* w (* w (* r r))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((w * w) <= 5e-318) {
tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w))));
} else if ((w * w) <= 1e+278) {
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 * (w * (w * (r * r)))));
}
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-318) then
tmp = t_0 + ((-1.5d0) - (0.375d0 * ((r * w) * (r * w))))
else if ((w * w) <= 1d+278) 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 * (w * (w * (r * r)))))
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-318) {
tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w))));
} else if ((w * w) <= 1e+278) {
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 * (w * (w * (r * r)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (w * w) <= 5e-318: tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w)))) elif (w * w) <= 1e+278: 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 * (w * (w * (r * r))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(w * w) <= 5e-318) tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * w) * Float64(r * w))))); elseif (Float64(w * w) <= 1e+278) 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(w * Float64(w * Float64(r * r)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((w * w) <= 5e-318) tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w)))); elseif ((w * w) <= 1e+278) 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 * (w * (w * (r * r))))); 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-318], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(w * w), $MachinePrecision], 1e+278], 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[(w * N[(w * N[(r * r), $MachinePrecision]), $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^{-318}:\\
\;\;\;\;t_0 + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right)\\
\mathbf{elif}\;w \cdot w \leq 10^{+278}:\\
\;\;\;\;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(w \cdot \left(w \cdot \left(r \cdot r\right)\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 w w) < 4.9999987e-318Initial program 88.2%
associate--l-88.2%
+-commutative88.2%
associate--l+88.2%
+-commutative88.2%
associate--r+88.2%
metadata-eval88.2%
associate-*l/88.2%
*-commutative88.2%
*-commutative88.2%
*-commutative88.2%
Simplified88.2%
Taylor expanded in r around 0 88.2%
*-commutative88.2%
unpow288.2%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in v around 0 73.8%
*-commutative73.8%
unpow273.8%
unpow273.8%
swap-sqr96.3%
unpow296.3%
*-commutative96.3%
Simplified96.3%
unpow296.3%
*-commutative96.3%
*-commutative96.3%
Applied egg-rr96.3%
if 4.9999987e-318 < (*.f64 w w) < 9.99999999999999964e277Initial program 93.9%
associate--l-93.9%
+-commutative93.9%
associate--l+93.9%
+-commutative93.9%
associate--r+93.9%
metadata-eval93.9%
associate-*l/99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
if 9.99999999999999964e277 < (*.f64 w w) Initial program 76.6%
associate--l-76.6%
+-commutative76.6%
associate--l+76.6%
+-commutative76.6%
associate--r+76.6%
metadata-eval76.6%
associate-*l/76.6%
*-commutative76.6%
*-commutative76.6%
*-commutative76.6%
Simplified76.6%
Taylor expanded in r around 0 76.6%
*-commutative76.6%
unpow276.6%
associate-*r*91.8%
*-commutative91.8%
Simplified91.8%
Taylor expanded in v around 0 76.6%
*-commutative76.6%
unpow276.6%
unpow276.6%
swap-sqr98.6%
unpow298.6%
*-commutative98.6%
Simplified98.6%
unpow298.6%
unswap-sqr76.6%
associate-*l*98.6%
Applied egg-rr98.6%
Final simplification98.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= (* w w) 1e+278)
(+
t_0
(- -1.5 (* (* r (* w (* r w))) (/ (+ 0.375 (* v -0.25)) (- 1.0 v)))))
(+ t_0 (- -1.5 (* 0.375 (* w (* w (* r r)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((w * w) <= 1e+278) {
tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} else {
tmp = t_0 + (-1.5 - (0.375 * (w * (w * (r * r)))));
}
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) <= 1d+278) then
tmp = t_0 + ((-1.5d0) - ((r * (w * (r * w))) * ((0.375d0 + (v * (-0.25d0))) / (1.0d0 - v))))
else
tmp = t_0 + ((-1.5d0) - (0.375d0 * (w * (w * (r * r)))))
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) <= 1e+278) {
tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} else {
tmp = t_0 + (-1.5 - (0.375 * (w * (w * (r * r)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (w * w) <= 1e+278: tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))) else: tmp = t_0 + (-1.5 - (0.375 * (w * (w * (r * r))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(w * w) <= 1e+278) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(r * Float64(w * Float64(r * w))) * Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(1.0 - v))))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(w * Float64(w * Float64(r * r)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((w * w) <= 1e+278) tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))); else tmp = t_0 + (-1.5 - (0.375 * (w * (w * (r * r))))); 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], 1e+278], N[(t$95$0 + N[(-1.5 - N[(N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(w * N[(w * N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \cdot w \leq 10^{+278}:\\
\;\;\;\;t_0 + \left(-1.5 - \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot \frac{0.375 + v \cdot -0.25}{1 - v}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - 0.375 \cdot \left(w \cdot \left(w \cdot \left(r \cdot r\right)\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 w w) < 9.99999999999999964e277Initial program 91.9%
associate--l-91.9%
+-commutative91.9%
associate--l+91.9%
+-commutative91.9%
associate--r+91.9%
metadata-eval91.9%
associate-*l/95.7%
*-commutative95.7%
*-commutative95.7%
*-commutative95.7%
Simplified95.7%
Taylor expanded in r around 0 95.7%
*-commutative95.7%
unpow295.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
if 9.99999999999999964e277 < (*.f64 w w) Initial program 76.6%
associate--l-76.6%
+-commutative76.6%
associate--l+76.6%
+-commutative76.6%
associate--r+76.6%
metadata-eval76.6%
associate-*l/76.6%
*-commutative76.6%
*-commutative76.6%
*-commutative76.6%
Simplified76.6%
Taylor expanded in r around 0 76.6%
*-commutative76.6%
unpow276.6%
associate-*r*91.8%
*-commutative91.8%
Simplified91.8%
Taylor expanded in v around 0 76.6%
*-commutative76.6%
unpow276.6%
unpow276.6%
swap-sqr98.6%
unpow298.6%
*-commutative98.6%
Simplified98.6%
unpow298.6%
unswap-sqr76.6%
associate-*l*98.6%
Applied egg-rr98.6%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= w 2e-162)
(+ -1.5 t_0)
(+ t_0 (- -1.5 (* 0.375 (* w (* w (* r r)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (w <= 2e-162) {
tmp = -1.5 + t_0;
} else {
tmp = t_0 + (-1.5 - (0.375 * (w * (w * (r * r)))));
}
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 <= 2d-162) then
tmp = (-1.5d0) + t_0
else
tmp = t_0 + ((-1.5d0) - (0.375d0 * (w * (w * (r * r)))))
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 <= 2e-162) {
tmp = -1.5 + t_0;
} else {
tmp = t_0 + (-1.5 - (0.375 * (w * (w * (r * r)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if w <= 2e-162: tmp = -1.5 + t_0 else: tmp = t_0 + (-1.5 - (0.375 * (w * (w * (r * r))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (w <= 2e-162) tmp = Float64(-1.5 + t_0); else tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(w * Float64(w * Float64(r * r)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (w <= 2e-162) tmp = -1.5 + t_0; else tmp = t_0 + (-1.5 - (0.375 * (w * (w * (r * r))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, 2e-162], N[(-1.5 + t$95$0), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(w * N[(w * N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \leq 2 \cdot 10^{-162}:\\
\;\;\;\;-1.5 + t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - 0.375 \cdot \left(w \cdot \left(w \cdot \left(r \cdot r\right)\right)\right)\right)\\
\end{array}
\end{array}
if w < 1.99999999999999991e-162Initial program 88.6%
sub-neg88.6%
+-commutative88.6%
associate--l+88.6%
associate-/l*90.8%
distribute-neg-frac90.8%
associate-/r/90.9%
fma-def90.9%
sub-neg90.9%
Simplified81.5%
Taylor expanded in r around 0 59.6%
sub-neg59.6%
associate-*r/59.6%
metadata-eval59.6%
unpow259.6%
metadata-eval59.6%
Simplified59.6%
if 1.99999999999999991e-162 < w Initial program 88.0%
associate--l-88.0%
+-commutative88.0%
associate--l+88.0%
+-commutative88.0%
associate--r+88.0%
metadata-eval88.0%
associate-*l/92.1%
*-commutative92.1%
*-commutative92.1%
*-commutative92.1%
Simplified92.1%
Taylor expanded in r around 0 92.1%
*-commutative92.1%
unpow292.1%
associate-*r*97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in v around 0 85.8%
*-commutative85.8%
unpow285.8%
unpow285.8%
swap-sqr93.7%
unpow293.7%
*-commutative93.7%
Simplified93.7%
unpow293.7%
unswap-sqr85.8%
associate-*l*93.5%
Applied egg-rr93.5%
Final simplification71.7%
(FPCore (v w r) :precision binary64 (let* ((t_0 (/ 2.0 (* r r)))) (if (<= w 1.1e-109) (+ -1.5 t_0) (+ t_0 (* (* r r) (* w (* w -0.25)))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (w <= 1.1e-109) {
tmp = -1.5 + t_0;
} else {
tmp = t_0 + ((r * r) * (w * (w * -0.25)));
}
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 <= 1.1d-109) then
tmp = (-1.5d0) + t_0
else
tmp = t_0 + ((r * r) * (w * (w * (-0.25d0))))
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 <= 1.1e-109) {
tmp = -1.5 + t_0;
} else {
tmp = t_0 + ((r * r) * (w * (w * -0.25)));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if w <= 1.1e-109: tmp = -1.5 + t_0 else: tmp = t_0 + ((r * r) * (w * (w * -0.25))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (w <= 1.1e-109) tmp = Float64(-1.5 + t_0); else tmp = Float64(t_0 + Float64(Float64(r * r) * Float64(w * Float64(w * -0.25)))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (w <= 1.1e-109) tmp = -1.5 + t_0; else tmp = t_0 + ((r * r) * (w * (w * -0.25))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, 1.1e-109], N[(-1.5 + t$95$0), $MachinePrecision], N[(t$95$0 + N[(N[(r * r), $MachinePrecision] * N[(w * N[(w * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \leq 1.1 \cdot 10^{-109}:\\
\;\;\;\;-1.5 + t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(r \cdot r\right) \cdot \left(w \cdot \left(w \cdot -0.25\right)\right)\\
\end{array}
\end{array}
if w < 1.1e-109Initial program 89.3%
sub-neg89.3%
+-commutative89.3%
associate--l+89.3%
associate-/l*91.4%
distribute-neg-frac91.4%
associate-/r/91.4%
fma-def91.4%
sub-neg91.4%
Simplified82.6%
Taylor expanded in r around 0 61.7%
sub-neg61.7%
associate-*r/61.7%
metadata-eval61.7%
unpow261.8%
metadata-eval61.8%
Simplified61.8%
if 1.1e-109 < w Initial program 86.4%
sub-neg86.4%
+-commutative86.4%
associate--l+86.4%
associate-/l*91.0%
distribute-neg-frac91.0%
associate-/r/91.0%
fma-def91.0%
sub-neg91.0%
Simplified88.7%
Taylor expanded in v around inf 79.1%
associate--l+79.1%
associate-*r/79.1%
metadata-eval79.1%
unpow279.1%
*-commutative79.1%
unpow279.1%
unpow279.1%
Simplified79.1%
Taylor expanded in w around inf 77.9%
unpow277.9%
unpow277.9%
associate-*r*77.9%
*-commutative77.9%
associate-*l*77.9%
Simplified77.9%
Final simplification66.8%
(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 88.4%
associate--l-88.4%
+-commutative88.4%
associate--l+88.4%
+-commutative88.4%
associate--r+88.4%
metadata-eval88.4%
associate-*l/91.3%
*-commutative91.3%
*-commutative91.3%
*-commutative91.3%
Simplified91.3%
Taylor expanded in r around 0 91.3%
*-commutative91.3%
unpow291.3%
associate-*r*97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in v around 0 81.1%
*-commutative81.1%
unpow281.1%
unpow281.1%
swap-sqr93.4%
unpow293.4%
*-commutative93.4%
Simplified93.4%
unpow293.4%
*-commutative93.4%
*-commutative93.4%
Applied egg-rr93.4%
Final simplification93.4%
(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 88.4%
sub-neg88.4%
+-commutative88.4%
associate--l+88.4%
associate-/l*91.3%
distribute-neg-frac91.3%
associate-/r/91.3%
fma-def91.3%
sub-neg91.3%
Simplified84.5%
Taylor expanded in r around 0 57.8%
sub-neg57.8%
associate-*r/57.8%
metadata-eval57.8%
unpow257.8%
metadata-eval57.8%
Simplified57.8%
Final simplification57.8%
(FPCore (v w r) :precision binary64 (/ 2.0 (* r r)))
double code(double v, double w, double r) {
return 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 = 2.0d0 / (r * r)
end function
public static double code(double v, double w, double r) {
return 2.0 / (r * r);
}
def code(v, w, r): return 2.0 / (r * r)
function code(v, w, r) return Float64(2.0 / Float64(r * r)) end
function tmp = code(v, w, r) tmp = 2.0 / (r * r); end
code[v_, w_, r_] := N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r}
\end{array}
Initial program 88.4%
sub-neg88.4%
+-commutative88.4%
associate--l+88.4%
associate-/l*91.3%
distribute-neg-frac91.3%
associate-/r/91.3%
fma-def91.3%
sub-neg91.3%
Simplified84.5%
fma-udef84.5%
unswap-sqr99.8%
pow299.8%
div-inv99.8%
fma-def99.8%
pow299.7%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 46.0%
unpow246.0%
Simplified46.0%
Final simplification46.0%
herbie shell --seed 2023258
(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))