
(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
(+
3.0
(-
(/ 2.0 (* r r))
(+
(/ 0.125 (/ (* (/ (- 1.0 v) (* r w)) (/ (/ 1.0 r) w)) (+ 3.0 (* v -2.0))))
4.5))))
double code(double v, double w, double r) {
return 3.0 + ((2.0 / (r * r)) - ((0.125 / ((((1.0 - v) / (r * w)) * ((1.0 / r) / w)) / (3.0 + (v * -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 / ((((1.0d0 - v) / (r * w)) * ((1.0d0 / r) / w)) / (3.0d0 + (v * (-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 / ((((1.0 - v) / (r * w)) * ((1.0 / r) / w)) / (3.0 + (v * -2.0)))) + 4.5));
}
def code(v, w, r): return 3.0 + ((2.0 / (r * r)) - ((0.125 / ((((1.0 - v) / (r * w)) * ((1.0 / r) / w)) / (3.0 + (v * -2.0)))) + 4.5))
function code(v, w, r) return Float64(3.0 + Float64(Float64(2.0 / Float64(r * r)) - Float64(Float64(0.125 / Float64(Float64(Float64(Float64(1.0 - v) / Float64(r * w)) * Float64(Float64(1.0 / r) / w)) / Float64(3.0 + Float64(v * -2.0)))) + 4.5))) end
function tmp = code(v, w, r) tmp = 3.0 + ((2.0 / (r * r)) - ((0.125 / ((((1.0 - v) / (r * w)) * ((1.0 / r) / w)) / (3.0 + (v * -2.0)))) + 4.5)); end
code[v_, w_, r_] := N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(0.125 / N[(N[(N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / r), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 + \left(\frac{2}{r \cdot r} - \left(\frac{0.125}{\frac{\frac{1 - v}{r \cdot w} \cdot \frac{\frac{1}{r}}{w}}{3 + v \cdot -2}} + 4.5\right)\right)
\end{array}
Initial program 85.6%
associate--l-85.6%
associate--l+85.6%
Simplified88.5%
associate-/r*86.9%
div-inv86.9%
associate-*r*95.1%
*-commutative95.1%
times-frac99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(+
3.0
(-
(/ 2.0 (* r r))
(+
4.5
(/
0.125
(/ (* (/ (- 1.0 v) (* r w)) (/ 1.0 (* r w))) (+ 3.0 (* v -2.0))))))))
double code(double v, double w, double r) {
return 3.0 + ((2.0 / (r * r)) - (4.5 + (0.125 / ((((1.0 - v) / (r * w)) * (1.0 / (r * w))) / (3.0 + (v * -2.0))))));
}
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 + (0.125d0 / ((((1.0d0 - v) / (r * w)) * (1.0d0 / (r * w))) / (3.0d0 + (v * (-2.0d0)))))))
end function
public static double code(double v, double w, double r) {
return 3.0 + ((2.0 / (r * r)) - (4.5 + (0.125 / ((((1.0 - v) / (r * w)) * (1.0 / (r * w))) / (3.0 + (v * -2.0))))));
}
def code(v, w, r): return 3.0 + ((2.0 / (r * r)) - (4.5 + (0.125 / ((((1.0 - v) / (r * w)) * (1.0 / (r * w))) / (3.0 + (v * -2.0))))))
function code(v, w, r) return Float64(3.0 + Float64(Float64(2.0 / Float64(r * r)) - Float64(4.5 + Float64(0.125 / Float64(Float64(Float64(Float64(1.0 - v) / Float64(r * w)) * Float64(1.0 / Float64(r * w))) / Float64(3.0 + Float64(v * -2.0))))))) end
function tmp = code(v, w, r) tmp = 3.0 + ((2.0 / (r * r)) - (4.5 + (0.125 / ((((1.0 - v) / (r * w)) * (1.0 / (r * w))) / (3.0 + (v * -2.0)))))); end
code[v_, w_, r_] := N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(4.5 + N[(0.125 / N[(N[(N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 + \left(\frac{2}{r \cdot r} - \left(4.5 + \frac{0.125}{\frac{\frac{1 - v}{r \cdot w} \cdot \frac{1}{r \cdot w}}{3 + v \cdot -2}}\right)\right)
\end{array}
Initial program 85.6%
associate--l-85.6%
associate--l+85.6%
Simplified88.5%
associate-*r*84.8%
*-commutative84.8%
div-inv84.8%
associate-*r/84.8%
unswap-sqr99.7%
times-frac99.7%
*-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 6.9e-56)
(+ 3.0 (- t_0 (+ 4.5 (/ 0.125 (/ (/ (/ 0.5 r) (* r w)) w)))))
(+
t_0
(- -1.5 (* (* r (* r w)) (/ (* w (+ 0.375 (* v -0.25))) (- 1.0 v))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 6.9e-56) {
tmp = 3.0 + (t_0 - (4.5 + (0.125 / (((0.5 / r) / (r * w)) / w))));
} else {
tmp = t_0 + (-1.5 - ((r * (r * w)) * ((w * (0.375 + (v * -0.25))) / (1.0 - v))));
}
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 (r <= 6.9d-56) then
tmp = 3.0d0 + (t_0 - (4.5d0 + (0.125d0 / (((0.5d0 / r) / (r * w)) / w))))
else
tmp = t_0 + ((-1.5d0) - ((r * (r * w)) * ((w * (0.375d0 + (v * (-0.25d0)))) / (1.0d0 - v))))
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 (r <= 6.9e-56) {
tmp = 3.0 + (t_0 - (4.5 + (0.125 / (((0.5 / r) / (r * w)) / w))));
} else {
tmp = t_0 + (-1.5 - ((r * (r * w)) * ((w * (0.375 + (v * -0.25))) / (1.0 - v))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 6.9e-56: tmp = 3.0 + (t_0 - (4.5 + (0.125 / (((0.5 / r) / (r * w)) / w)))) else: tmp = t_0 + (-1.5 - ((r * (r * w)) * ((w * (0.375 + (v * -0.25))) / (1.0 - v)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 6.9e-56) tmp = Float64(3.0 + Float64(t_0 - Float64(4.5 + Float64(0.125 / Float64(Float64(Float64(0.5 / r) / Float64(r * w)) / w))))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(r * Float64(r * w)) * Float64(Float64(w * Float64(0.375 + Float64(v * -0.25))) / Float64(1.0 - v))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 6.9e-56) tmp = 3.0 + (t_0 - (4.5 + (0.125 / (((0.5 / r) / (r * w)) / w)))); else tmp = t_0 + (-1.5 - ((r * (r * w)) * ((w * (0.375 + (v * -0.25))) / (1.0 - v)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 6.9e-56], N[(3.0 + N[(t$95$0 - N[(4.5 + N[(0.125 / N[(N[(N[(0.5 / r), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(N[(w * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 6.9 \cdot 10^{-56}:\\
\;\;\;\;3 + \left(t_0 - \left(4.5 + \frac{0.125}{\frac{\frac{\frac{0.5}{r}}{r \cdot w}}{w}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - \left(r \cdot \left(r \cdot w\right)\right) \cdot \frac{w \cdot \left(0.375 + v \cdot -0.25\right)}{1 - v}\right)\\
\end{array}
\end{array}
if r < 6.8999999999999996e-56Initial program 83.2%
associate--l-83.2%
associate--l+83.2%
Simplified84.8%
Taylor expanded in v around inf 77.7%
unpow277.7%
unpow277.7%
swap-sqr92.9%
unpow292.9%
Simplified92.9%
associate-/r/92.9%
metadata-eval92.9%
unpow292.9%
associate-*r*92.9%
*-commutative92.9%
associate-*l*92.9%
*-commutative92.9%
associate-*l*92.9%
Applied egg-rr92.9%
associate-*l*92.2%
*-commutative92.2%
associate-*l*92.2%
associate-*r*92.2%
metadata-eval92.2%
associate-/r/92.2%
associate-/r*92.2%
associate-/r*92.4%
Applied egg-rr92.4%
if 6.8999999999999996e-56 < r Initial program 90.8%
Simplified92.8%
Taylor expanded in w around 0 94.1%
Final simplification93.0%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 2.9e+181)
(+
t_0
(- -1.5 (* (/ (+ 0.375 (* v -0.25)) (/ (- 1.0 v) w)) (* r (* r w)))))
(+ 3.0 (- t_0 (+ 4.5 (* r (* w (* w (* r 0.25))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 2.9e+181) {
tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / ((1.0 - v) / w)) * (r * (r * w))));
} else {
tmp = 3.0 + (t_0 - (4.5 + (r * (w * (w * (r * 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 (r <= 2.9d+181) then
tmp = t_0 + ((-1.5d0) - (((0.375d0 + (v * (-0.25d0))) / ((1.0d0 - v) / w)) * (r * (r * w))))
else
tmp = 3.0d0 + (t_0 - (4.5d0 + (r * (w * (w * (r * 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 (r <= 2.9e+181) {
tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / ((1.0 - v) / w)) * (r * (r * w))));
} else {
tmp = 3.0 + (t_0 - (4.5 + (r * (w * (w * (r * 0.25))))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 2.9e+181: tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / ((1.0 - v) / w)) * (r * (r * w)))) else: tmp = 3.0 + (t_0 - (4.5 + (r * (w * (w * (r * 0.25)))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 2.9e+181) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(Float64(1.0 - v) / w)) * Float64(r * Float64(r * w))))); else tmp = Float64(3.0 + Float64(t_0 - Float64(4.5 + Float64(r * Float64(w * Float64(w * Float64(r * 0.25))))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 2.9e+181) tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / ((1.0 - v) / w)) * (r * (r * w)))); else tmp = 3.0 + (t_0 - (4.5 + (r * (w * (w * (r * 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[r, 2.9e+181], N[(t$95$0 + N[(-1.5 - N[(N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision] * N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 + N[(t$95$0 - N[(4.5 + N[(r * N[(w * N[(w * N[(r * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 2.9 \cdot 10^{+181}:\\
\;\;\;\;t_0 + \left(-1.5 - \frac{0.375 + v \cdot -0.25}{\frac{1 - v}{w}} \cdot \left(r \cdot \left(r \cdot w\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 + \left(t_0 - \left(4.5 + r \cdot \left(w \cdot \left(w \cdot \left(r \cdot 0.25\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if r < 2.9e181Initial program 85.6%
Simplified97.2%
if 2.9e181 < r Initial program 86.0%
associate--l-86.0%
associate--l+86.0%
Simplified89.4%
Taylor expanded in v around inf 74.8%
unpow274.8%
unpow274.8%
swap-sqr93.2%
unpow293.2%
Simplified93.2%
associate-/r/93.2%
metadata-eval93.2%
unpow293.2%
associate-*r*93.2%
*-commutative93.2%
associate-*l*93.2%
*-commutative93.2%
*-commutative93.2%
associate-*r*93.2%
associate-*l*93.2%
Applied egg-rr93.2%
Final simplification96.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* r (* r w))) (t_1 (/ 2.0 (* r r))))
(if (or (<= v -100000000000.0) (not (<= v 2e-11)))
(+ t_1 (- -1.5 (* t_0 (* w 0.25))))
(+ t_1 (- -1.5 (* t_0 (* w 0.375)))))))
double code(double v, double w, double r) {
double t_0 = r * (r * w);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -100000000000.0) || !(v <= 2e-11)) {
tmp = t_1 + (-1.5 - (t_0 * (w * 0.25)));
} else {
tmp = t_1 + (-1.5 - (t_0 * (w * 0.375)));
}
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) :: t_1
real(8) :: tmp
t_0 = r * (r * w)
t_1 = 2.0d0 / (r * r)
if ((v <= (-100000000000.0d0)) .or. (.not. (v <= 2d-11))) then
tmp = t_1 + ((-1.5d0) - (t_0 * (w * 0.25d0)))
else
tmp = t_1 + ((-1.5d0) - (t_0 * (w * 0.375d0)))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = r * (r * w);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -100000000000.0) || !(v <= 2e-11)) {
tmp = t_1 + (-1.5 - (t_0 * (w * 0.25)));
} else {
tmp = t_1 + (-1.5 - (t_0 * (w * 0.375)));
}
return tmp;
}
def code(v, w, r): t_0 = r * (r * w) t_1 = 2.0 / (r * r) tmp = 0 if (v <= -100000000000.0) or not (v <= 2e-11): tmp = t_1 + (-1.5 - (t_0 * (w * 0.25))) else: tmp = t_1 + (-1.5 - (t_0 * (w * 0.375))) return tmp
function code(v, w, r) t_0 = Float64(r * Float64(r * w)) t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -100000000000.0) || !(v <= 2e-11)) tmp = Float64(t_1 + Float64(-1.5 - Float64(t_0 * Float64(w * 0.25)))); else tmp = Float64(t_1 + Float64(-1.5 - Float64(t_0 * Float64(w * 0.375)))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = r * (r * w); t_1 = 2.0 / (r * r); tmp = 0.0; if ((v <= -100000000000.0) || ~((v <= 2e-11))) tmp = t_1 + (-1.5 - (t_0 * (w * 0.25))); else tmp = t_1 + (-1.5 - (t_0 * (w * 0.375))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -100000000000.0], N[Not[LessEqual[v, 2e-11]], $MachinePrecision]], N[(t$95$1 + N[(-1.5 - N[(t$95$0 * N[(w * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(-1.5 - N[(t$95$0 * N[(w * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \left(r \cdot w\right)\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -100000000000 \lor \neg \left(v \leq 2 \cdot 10^{-11}\right):\\
\;\;\;\;t_1 + \left(-1.5 - t_0 \cdot \left(w \cdot 0.25\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 + \left(-1.5 - t_0 \cdot \left(w \cdot 0.375\right)\right)\\
\end{array}
\end{array}
if v < -1e11 or 1.99999999999999988e-11 < v Initial program 79.3%
Simplified94.1%
Taylor expanded in v around inf 97.2%
*-commutative97.2%
Simplified97.2%
if -1e11 < v < 1.99999999999999988e-11Initial program 91.6%
Simplified96.3%
Taylor expanded in v around 0 95.5%
*-commutative95.5%
Simplified95.5%
Final simplification96.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (* r (* r w))))
(if (<= v -1.25)
(+ 3.0 (- t_0 (+ 4.5 (* (* r w) (* w (* r 0.25))))))
(if (<= v 2e-11)
(+ t_0 (- -1.5 (* t_1 (* w 0.375))))
(+ t_0 (- -1.5 (* t_1 (* w 0.25))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = r * (r * w);
double tmp;
if (v <= -1.25) {
tmp = 3.0 + (t_0 - (4.5 + ((r * w) * (w * (r * 0.25)))));
} else if (v <= 2e-11) {
tmp = t_0 + (-1.5 - (t_1 * (w * 0.375)));
} else {
tmp = t_0 + (-1.5 - (t_1 * (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) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = r * (r * w)
if (v <= (-1.25d0)) then
tmp = 3.0d0 + (t_0 - (4.5d0 + ((r * w) * (w * (r * 0.25d0)))))
else if (v <= 2d-11) then
tmp = t_0 + ((-1.5d0) - (t_1 * (w * 0.375d0)))
else
tmp = t_0 + ((-1.5d0) - (t_1 * (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 t_1 = r * (r * w);
double tmp;
if (v <= -1.25) {
tmp = 3.0 + (t_0 - (4.5 + ((r * w) * (w * (r * 0.25)))));
} else if (v <= 2e-11) {
tmp = t_0 + (-1.5 - (t_1 * (w * 0.375)));
} else {
tmp = t_0 + (-1.5 - (t_1 * (w * 0.25)));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = r * (r * w) tmp = 0 if v <= -1.25: tmp = 3.0 + (t_0 - (4.5 + ((r * w) * (w * (r * 0.25))))) elif v <= 2e-11: tmp = t_0 + (-1.5 - (t_1 * (w * 0.375))) else: tmp = t_0 + (-1.5 - (t_1 * (w * 0.25))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(r * Float64(r * w)) tmp = 0.0 if (v <= -1.25) tmp = Float64(3.0 + Float64(t_0 - Float64(4.5 + Float64(Float64(r * w) * Float64(w * Float64(r * 0.25)))))); elseif (v <= 2e-11) tmp = Float64(t_0 + Float64(-1.5 - Float64(t_1 * Float64(w * 0.375)))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(t_1 * Float64(w * 0.25)))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = r * (r * w); tmp = 0.0; if (v <= -1.25) tmp = 3.0 + (t_0 - (4.5 + ((r * w) * (w * (r * 0.25))))); elseif (v <= 2e-11) tmp = t_0 + (-1.5 - (t_1 * (w * 0.375))); else tmp = t_0 + (-1.5 - (t_1 * (w * 0.25))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1.25], N[(3.0 + N[(t$95$0 - N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 2e-11], N[(t$95$0 + N[(-1.5 - N[(t$95$1 * N[(w * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(t$95$1 * N[(w * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := r \cdot \left(r \cdot w\right)\\
\mathbf{if}\;v \leq -1.25:\\
\;\;\;\;3 + \left(t_0 - \left(4.5 + \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.25\right)\right)\right)\right)\\
\mathbf{elif}\;v \leq 2 \cdot 10^{-11}:\\
\;\;\;\;t_0 + \left(-1.5 - t_1 \cdot \left(w \cdot 0.375\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - t_1 \cdot \left(w \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if v < -1.25Initial program 74.3%
associate--l-74.3%
associate--l+74.3%
Simplified82.8%
Taylor expanded in v around inf 75.4%
unpow275.4%
unpow275.4%
swap-sqr98.3%
unpow298.3%
Simplified98.3%
associate-/r/98.3%
metadata-eval98.3%
unpow298.3%
associate-*r*98.3%
*-commutative98.3%
associate-*l*98.3%
*-commutative98.3%
associate-*l*98.3%
Applied egg-rr98.3%
if -1.25 < v < 1.99999999999999988e-11Initial program 91.2%
Simplified96.9%
Taylor expanded in v around 0 96.0%
*-commutative96.0%
Simplified96.0%
if 1.99999999999999988e-11 < v Initial program 85.8%
Simplified96.1%
Taylor expanded in v around inf 99.5%
*-commutative99.5%
Simplified99.5%
Final simplification97.5%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* (* r (* r w)) (* w 0.25)))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - ((r * (r * w)) * (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 * (r * w)) * (w * 0.25d0)))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - ((r * (r * w)) * (w * 0.25)));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - ((r * (r * w)) * (w * 0.25)))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(r * Float64(r * w)) * Float64(w * 0.25)))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - ((r * (r * w)) * (w * 0.25))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(w * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - \left(r \cdot \left(r \cdot w\right)\right) \cdot \left(w \cdot 0.25\right)\right)
\end{array}
Initial program 85.6%
Simplified95.2%
Taylor expanded in v around inf 90.3%
*-commutative90.3%
Simplified90.3%
Final simplification90.3%
(FPCore (v w r) :precision binary64 (if (<= r 4.1e+136) (+ (/ 2.0 (* r r)) -1.5) (* (* w w) (* (* r r) -0.25))))
double code(double v, double w, double r) {
double tmp;
if (r <= 4.1e+136) {
tmp = (2.0 / (r * r)) + -1.5;
} else {
tmp = (w * w) * ((r * r) * -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) :: tmp
if (r <= 4.1d+136) then
tmp = (2.0d0 / (r * r)) + (-1.5d0)
else
tmp = (w * w) * ((r * r) * (-0.25d0))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 4.1e+136) {
tmp = (2.0 / (r * r)) + -1.5;
} else {
tmp = (w * w) * ((r * r) * -0.25);
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 4.1e+136: tmp = (2.0 / (r * r)) + -1.5 else: tmp = (w * w) * ((r * r) * -0.25) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 4.1e+136) tmp = Float64(Float64(2.0 / Float64(r * r)) + -1.5); else tmp = Float64(Float64(w * w) * Float64(Float64(r * r) * -0.25)); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 4.1e+136) tmp = (2.0 / (r * r)) + -1.5; else tmp = (w * w) * ((r * r) * -0.25); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 4.1e+136], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision], N[(N[(w * w), $MachinePrecision] * N[(N[(r * r), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 4.1 \cdot 10^{+136}:\\
\;\;\;\;\frac{2}{r \cdot r} + -1.5\\
\mathbf{else}:\\
\;\;\;\;\left(w \cdot w\right) \cdot \left(\left(r \cdot r\right) \cdot -0.25\right)\\
\end{array}
\end{array}
if r < 4.0999999999999998e136Initial program 85.7%
associate--l-85.7%
associate--l+85.7%
Simplified87.8%
Taylor expanded in v around inf 79.7%
unpow279.7%
unpow279.7%
swap-sqr91.9%
unpow291.9%
Simplified91.9%
associate-/r/91.8%
metadata-eval91.8%
unpow291.8%
associate-*r*91.8%
*-commutative91.8%
associate-*l*91.8%
*-commutative91.8%
associate-*l*91.8%
Applied egg-rr91.8%
Taylor expanded in r around 0 65.4%
sub-neg65.4%
associate-*r/65.4%
metadata-eval65.4%
unpow265.4%
metadata-eval65.4%
Simplified65.4%
if 4.0999999999999998e136 < r Initial program 84.9%
associate--l-84.9%
associate--l+84.9%
Simplified92.1%
Taylor expanded in v around inf 74.7%
unpow274.7%
unpow274.7%
swap-sqr90.3%
unpow290.3%
Simplified90.3%
associate-/r/90.3%
metadata-eval90.3%
unpow290.3%
associate-*r*90.3%
*-commutative90.3%
associate-*l*90.3%
*-commutative90.3%
associate-*l*90.3%
Applied egg-rr90.3%
Taylor expanded in r around inf 72.1%
associate-*r*72.1%
*-commutative72.1%
unpow272.1%
*-commutative72.1%
unpow272.1%
Simplified72.1%
Final simplification66.4%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) -1.5))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + -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 = (2.0d0 / (r * r)) + (-1.5d0)
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + -1.5;
}
def code(v, w, r): return (2.0 / (r * r)) + -1.5
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + -1.5) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + -1.5; end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + -1.5
\end{array}
Initial program 85.6%
associate--l-85.6%
associate--l+85.6%
Simplified88.5%
Taylor expanded in v around inf 79.0%
unpow279.0%
unpow279.0%
swap-sqr91.6%
unpow291.6%
Simplified91.6%
associate-/r/91.6%
metadata-eval91.6%
unpow291.6%
associate-*r*91.6%
*-commutative91.6%
associate-*l*91.6%
*-commutative91.6%
associate-*l*91.6%
Applied egg-rr91.6%
Taylor expanded in r around 0 57.2%
sub-neg57.2%
associate-*r/57.2%
metadata-eval57.2%
unpow257.2%
metadata-eval57.2%
Simplified57.2%
Final simplification57.2%
(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 85.6%
Simplified95.2%
Taylor expanded in v around inf 90.3%
*-commutative90.3%
Simplified90.3%
Taylor expanded in r around 0 43.2%
unpow243.2%
associate-/r*43.2%
Simplified43.2%
Taylor expanded in r around 0 43.2%
unpow243.2%
Simplified43.2%
Final simplification43.2%
herbie shell --seed 2023297
(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))