
(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 86.3%
sub-neg86.3%
+-commutative86.3%
associate--l+86.3%
associate-/l*89.2%
distribute-neg-frac89.2%
associate-/r/89.2%
fma-def89.2%
sub-neg89.2%
Simplified81.0%
fma-udef81.0%
unswap-sqr99.7%
pow299.7%
div-inv99.7%
fma-def99.7%
pow299.7%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (/ (pow (* r w) 2.0) (/ (- 1.0 v) (fma -0.25 v 0.375))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (pow((r * w), 2.0) / ((1.0 - v) / fma(-0.25, v, 0.375))));
}
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64((Float64(r * w) ^ 2.0) / Float64(Float64(1.0 - v) / fma(-0.25, v, 0.375))))) end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] / N[(-0.25 * v + 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - \frac{{\left(r \cdot w\right)}^{2}}{\frac{1 - v}{\mathsf{fma}\left(-0.25, v, 0.375\right)}}\right)
\end{array}
Initial program 86.3%
associate--l-86.3%
+-commutative86.3%
associate--l+86.3%
+-commutative86.3%
associate--r+86.3%
metadata-eval86.3%
associate-*l/89.2%
*-commutative89.2%
*-commutative89.2%
*-commutative89.2%
Simplified89.2%
Taylor expanded in r around 0 89.2%
*-commutative89.2%
unpow289.2%
associate-*r*97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in r around 0 79.1%
associate-/l*80.9%
+-commutative80.9%
*-commutative80.9%
*-commutative80.9%
unpow280.9%
unpow280.9%
swap-sqr99.7%
unpow299.7%
associate-/l*96.1%
*-commutative96.1%
associate-/l*99.8%
*-commutative99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (- (+ (/ 2.0 (* r r)) 3.0) (/ (* 0.125 (+ 3.0 (* v -2.0))) (* (- 1.0 v) (/ 1.0 (* (* r w) (* r w)))))) -4.5))
double code(double v, double w, double r) {
return (((2.0 / (r * r)) + 3.0) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) * (1.0 / ((r * w) * (r * w)))))) + -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 = (((2.0d0 / (r * r)) + 3.0d0) - ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) / ((1.0d0 - v) * (1.0d0 / ((r * w) * (r * w)))))) + (-4.5d0)
end function
public static double code(double v, double w, double r) {
return (((2.0 / (r * r)) + 3.0) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) * (1.0 / ((r * w) * (r * w)))))) + -4.5;
}
def code(v, w, r): return (((2.0 / (r * r)) + 3.0) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) * (1.0 / ((r * w) * (r * w)))))) + -4.5
function code(v, w, r) return Float64(Float64(Float64(Float64(2.0 / Float64(r * r)) + 3.0) - Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) / Float64(Float64(1.0 - v) * Float64(1.0 / Float64(Float64(r * w) * Float64(r * w)))))) + -4.5) end
function tmp = code(v, w, r) tmp = (((2.0 / (r * r)) + 3.0) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) * (1.0 / ((r * w) * (r * w)))))) + -4.5; end
code[v_, w_, r_] := N[(N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision] - N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] * N[(1.0 / N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\frac{2}{r \cdot r} + 3\right) - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{\left(1 - v\right) \cdot \frac{1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right) + -4.5
\end{array}
Initial program 86.3%
sub-neg86.3%
associate-/l*89.2%
cancel-sign-sub-inv89.2%
metadata-eval89.2%
*-commutative89.2%
*-commutative89.2%
metadata-eval89.2%
Simplified89.2%
div-inv89.2%
associate-*r*80.9%
unswap-sqr99.7%
pow299.7%
Applied egg-rr99.7%
unpow299.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 3.2e-112)
t_0
(+
t_0
(- -1.5 (* (/ (+ 0.375 (* v -0.25)) (- 1.0 v)) (* r (* r (* w w)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 3.2e-112) {
tmp = t_0;
} else {
tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if (r <= 3.2d-112) then
tmp = t_0
else
tmp = t_0 + ((-1.5d0) - (((0.375d0 + (v * (-0.25d0))) / (1.0d0 - v)) * (r * (r * (w * 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 (r <= 3.2e-112) {
tmp = t_0;
} else {
tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 3.2e-112: tmp = t_0 else: tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 3.2e-112) tmp = t_0; else 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)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 3.2e-112) tmp = t_0; else tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 3.2e-112], t$95$0, 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 3.2 \cdot 10^{-112}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;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)\\
\end{array}
\end{array}
if r < 3.19999999999999993e-112Initial program 87.0%
sub-neg87.0%
+-commutative87.0%
associate--l+87.0%
associate-/l*88.0%
distribute-neg-frac88.0%
associate-/r/88.0%
fma-def88.0%
sub-neg88.0%
Simplified81.4%
fma-udef81.4%
unswap-sqr99.8%
pow299.8%
div-inv99.8%
fma-def99.8%
pow299.8%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in r around 0 61.6%
unpow261.6%
Simplified61.6%
if 3.19999999999999993e-112 < r Initial program 84.5%
associate--l-84.5%
+-commutative84.5%
associate--l+84.5%
+-commutative84.5%
associate--r+84.5%
metadata-eval84.5%
associate-*l/92.3%
*-commutative92.3%
*-commutative92.3%
*-commutative92.3%
Simplified92.3%
Final simplification70.4%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* (* r (* w (* r w))) (/ (+ 0.375 (* v -0.25)) (- 1.0 v))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
}
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.375d0 + (v * (-0.25d0))) / (1.0d0 - v))))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(r * Float64(w * Float64(r * w))) * Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(1.0 - v))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + 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]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \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)
\end{array}
Initial program 86.3%
associate--l-86.3%
+-commutative86.3%
associate--l+86.3%
+-commutative86.3%
associate--r+86.3%
metadata-eval86.3%
associate-*l/89.2%
*-commutative89.2%
*-commutative89.2%
*-commutative89.2%
Simplified89.2%
Taylor expanded in r around 0 89.2%
*-commutative89.2%
unpow289.2%
associate-*r*97.5%
*-commutative97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 4.2e-112)
t_0
(if (<= r 1.55e+162)
(+ t_0 (- (* -0.375 (* (* r r) (* w w))) 1.5))
(if (or (<= r 2e+177) (and (not (<= r 2.7e+205)) (<= r 6.2e+235)))
(+ -1.5 t_0)
(* -0.375 (* (* r w) (* r w))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 4.2e-112) {
tmp = t_0;
} else if (r <= 1.55e+162) {
tmp = t_0 + ((-0.375 * ((r * r) * (w * w))) - 1.5);
} else if ((r <= 2e+177) || (!(r <= 2.7e+205) && (r <= 6.2e+235))) {
tmp = -1.5 + t_0;
} else {
tmp = -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 (r <= 4.2d-112) then
tmp = t_0
else if (r <= 1.55d+162) then
tmp = t_0 + (((-0.375d0) * ((r * r) * (w * w))) - 1.5d0)
else if ((r <= 2d+177) .or. (.not. (r <= 2.7d+205)) .and. (r <= 6.2d+235)) then
tmp = (-1.5d0) + t_0
else
tmp = (-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 (r <= 4.2e-112) {
tmp = t_0;
} else if (r <= 1.55e+162) {
tmp = t_0 + ((-0.375 * ((r * r) * (w * w))) - 1.5);
} else if ((r <= 2e+177) || (!(r <= 2.7e+205) && (r <= 6.2e+235))) {
tmp = -1.5 + t_0;
} else {
tmp = -0.375 * ((r * w) * (r * w));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 4.2e-112: tmp = t_0 elif r <= 1.55e+162: tmp = t_0 + ((-0.375 * ((r * r) * (w * w))) - 1.5) elif (r <= 2e+177) or (not (r <= 2.7e+205) and (r <= 6.2e+235)): tmp = -1.5 + t_0 else: tmp = -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 (r <= 4.2e-112) tmp = t_0; elseif (r <= 1.55e+162) tmp = Float64(t_0 + Float64(Float64(-0.375 * Float64(Float64(r * r) * Float64(w * w))) - 1.5)); elseif ((r <= 2e+177) || (!(r <= 2.7e+205) && (r <= 6.2e+235))) tmp = Float64(-1.5 + t_0); else tmp = 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 (r <= 4.2e-112) tmp = t_0; elseif (r <= 1.55e+162) tmp = t_0 + ((-0.375 * ((r * r) * (w * w))) - 1.5); elseif ((r <= 2e+177) || (~((r <= 2.7e+205)) && (r <= 6.2e+235))) tmp = -1.5 + t_0; else tmp = -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[r, 4.2e-112], t$95$0, If[LessEqual[r, 1.55e+162], N[(t$95$0 + N[(N[(-0.375 * N[(N[(r * r), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[r, 2e+177], And[N[Not[LessEqual[r, 2.7e+205]], $MachinePrecision], LessEqual[r, 6.2e+235]]], N[(-1.5 + t$95$0), $MachinePrecision], N[(-0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 4.2 \cdot 10^{-112}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;r \leq 1.55 \cdot 10^{+162}:\\
\;\;\;\;t_0 + \left(-0.375 \cdot \left(\left(r \cdot r\right) \cdot \left(w \cdot w\right)\right) - 1.5\right)\\
\mathbf{elif}\;r \leq 2 \cdot 10^{+177} \lor \neg \left(r \leq 2.7 \cdot 10^{+205}\right) \land r \leq 6.2 \cdot 10^{+235}:\\
\;\;\;\;-1.5 + t_0\\
\mathbf{else}:\\
\;\;\;\;-0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\\
\end{array}
\end{array}
if r < 4.2000000000000001e-112Initial program 87.0%
sub-neg87.0%
+-commutative87.0%
associate--l+87.0%
associate-/l*88.0%
distribute-neg-frac88.0%
associate-/r/88.0%
fma-def88.0%
sub-neg88.0%
Simplified81.4%
fma-udef81.4%
unswap-sqr99.8%
pow299.8%
div-inv99.8%
fma-def99.8%
pow299.8%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in r around 0 61.6%
unpow261.6%
Simplified61.6%
if 4.2000000000000001e-112 < r < 1.55e162Initial program 89.7%
sub-neg89.7%
+-commutative89.7%
associate--l+89.7%
associate-/l*97.9%
distribute-neg-frac97.9%
associate-/r/97.8%
fma-def97.8%
sub-neg97.8%
Simplified95.7%
Taylor expanded in v around 0 87.3%
associate--l+87.3%
associate-*r/87.3%
metadata-eval87.3%
unpow287.3%
*-commutative87.3%
unpow287.3%
unpow287.3%
Simplified87.3%
if 1.55e162 < r < 2e177 or 2.70000000000000012e205 < r < 6.20000000000000022e235Initial program 59.5%
sub-neg59.5%
+-commutative59.5%
associate--l+59.5%
associate-/l*86.7%
distribute-neg-frac86.7%
associate-/r/86.7%
fma-def86.7%
sub-neg86.7%
Simplified15.6%
Taylor expanded in r around 0 45.7%
sub-neg45.7%
associate-*r/45.7%
metadata-eval45.7%
unpow245.7%
metadata-eval45.7%
Simplified45.7%
if 2e177 < r < 2.70000000000000012e205 or 6.20000000000000022e235 < r Initial program 81.1%
sub-neg81.1%
+-commutative81.1%
associate--l+81.1%
associate-/l*81.0%
distribute-neg-frac81.0%
associate-/r/81.1%
fma-def81.1%
sub-neg81.1%
Simplified65.5%
Taylor expanded in r around inf 65.5%
associate-/l*65.5%
*-commutative65.5%
unpow265.5%
unpow265.5%
*-commutative65.5%
fma-neg65.5%
metadata-eval65.5%
Simplified65.5%
Taylor expanded in v around 0 65.5%
*-commutative65.5%
unpow265.5%
unpow265.5%
swap-sqr86.9%
unpow286.9%
Simplified86.9%
unpow286.9%
Applied egg-rr86.9%
Final simplification67.8%
(FPCore (v w r)
:precision binary64
(if (or (<= r 135000.0)
(and (not (<= r 5.8e+84))
(or (<= r 2.2e+98) (and (not (<= r 2.7e+205)) (<= r 6.2e+235)))))
(+ -1.5 (/ 2.0 (* r r)))
(* -0.375 (* (* r w) (* r w)))))
double code(double v, double w, double r) {
double tmp;
if ((r <= 135000.0) || (!(r <= 5.8e+84) && ((r <= 2.2e+98) || (!(r <= 2.7e+205) && (r <= 6.2e+235))))) {
tmp = -1.5 + (2.0 / (r * r));
} else {
tmp = -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) :: tmp
if ((r <= 135000.0d0) .or. (.not. (r <= 5.8d+84)) .and. (r <= 2.2d+98) .or. (.not. (r <= 2.7d+205)) .and. (r <= 6.2d+235)) then
tmp = (-1.5d0) + (2.0d0 / (r * r))
else
tmp = (-0.375d0) * ((r * w) * (r * w))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if ((r <= 135000.0) || (!(r <= 5.8e+84) && ((r <= 2.2e+98) || (!(r <= 2.7e+205) && (r <= 6.2e+235))))) {
tmp = -1.5 + (2.0 / (r * r));
} else {
tmp = -0.375 * ((r * w) * (r * w));
}
return tmp;
}
def code(v, w, r): tmp = 0 if (r <= 135000.0) or (not (r <= 5.8e+84) and ((r <= 2.2e+98) or (not (r <= 2.7e+205) and (r <= 6.2e+235)))): tmp = -1.5 + (2.0 / (r * r)) else: tmp = -0.375 * ((r * w) * (r * w)) return tmp
function code(v, w, r) tmp = 0.0 if ((r <= 135000.0) || (!(r <= 5.8e+84) && ((r <= 2.2e+98) || (!(r <= 2.7e+205) && (r <= 6.2e+235))))) tmp = Float64(-1.5 + Float64(2.0 / Float64(r * r))); else tmp = Float64(-0.375 * Float64(Float64(r * w) * Float64(r * w))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if ((r <= 135000.0) || (~((r <= 5.8e+84)) && ((r <= 2.2e+98) || (~((r <= 2.7e+205)) && (r <= 6.2e+235))))) tmp = -1.5 + (2.0 / (r * r)); else tmp = -0.375 * ((r * w) * (r * w)); end tmp_2 = tmp; end
code[v_, w_, r_] := If[Or[LessEqual[r, 135000.0], And[N[Not[LessEqual[r, 5.8e+84]], $MachinePrecision], Or[LessEqual[r, 2.2e+98], And[N[Not[LessEqual[r, 2.7e+205]], $MachinePrecision], LessEqual[r, 6.2e+235]]]]], N[(-1.5 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 135000 \lor \neg \left(r \leq 5.8 \cdot 10^{+84}\right) \land \left(r \leq 2.2 \cdot 10^{+98} \lor \neg \left(r \leq 2.7 \cdot 10^{+205}\right) \land r \leq 6.2 \cdot 10^{+235}\right):\\
\;\;\;\;-1.5 + \frac{2}{r \cdot r}\\
\mathbf{else}:\\
\;\;\;\;-0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\\
\end{array}
\end{array}
if r < 135000 or 5.79999999999999977e84 < r < 2.20000000000000009e98 or 2.70000000000000012e205 < r < 6.20000000000000022e235Initial program 85.9%
sub-neg85.9%
+-commutative85.9%
associate--l+85.9%
associate-/l*88.6%
distribute-neg-frac88.6%
associate-/r/88.6%
fma-def88.6%
sub-neg88.6%
Simplified81.4%
Taylor expanded in r around 0 71.1%
sub-neg71.1%
associate-*r/71.1%
metadata-eval71.1%
unpow271.1%
metadata-eval71.1%
Simplified71.1%
if 135000 < r < 5.79999999999999977e84 or 2.20000000000000009e98 < r < 2.70000000000000012e205 or 6.20000000000000022e235 < r Initial program 87.8%
sub-neg87.8%
+-commutative87.8%
associate--l+87.8%
associate-/l*91.9%
distribute-neg-frac91.9%
associate-/r/91.9%
fma-def91.9%
sub-neg91.9%
Simplified79.0%
Taylor expanded in r around inf 59.2%
associate-/l*61.2%
*-commutative61.2%
unpow261.2%
unpow261.2%
*-commutative61.2%
fma-neg61.2%
metadata-eval61.2%
Simplified61.2%
Taylor expanded in v around 0 60.0%
*-commutative60.0%
unpow260.0%
unpow260.0%
swap-sqr69.7%
unpow269.7%
Simplified69.7%
unpow269.7%
Applied egg-rr69.7%
Final simplification70.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ -1.5 (/ 2.0 (* r r)))))
(if (<= r 120000.0)
t_0
(if (<= r 5.6e+84)
(/ w (/ -2.6666666666666665 (* r (* r w))))
(if (or (<= r 5.9e+99) (and (not (<= r 2.7e+205)) (<= r 6.2e+235)))
t_0
(* -0.375 (* (* r w) (* r w))))))))
double code(double v, double w, double r) {
double t_0 = -1.5 + (2.0 / (r * r));
double tmp;
if (r <= 120000.0) {
tmp = t_0;
} else if (r <= 5.6e+84) {
tmp = w / (-2.6666666666666665 / (r * (r * w)));
} else if ((r <= 5.9e+99) || (!(r <= 2.7e+205) && (r <= 6.2e+235))) {
tmp = t_0;
} else {
tmp = -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 = (-1.5d0) + (2.0d0 / (r * r))
if (r <= 120000.0d0) then
tmp = t_0
else if (r <= 5.6d+84) then
tmp = w / ((-2.6666666666666665d0) / (r * (r * w)))
else if ((r <= 5.9d+99) .or. (.not. (r <= 2.7d+205)) .and. (r <= 6.2d+235)) then
tmp = t_0
else
tmp = (-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 = -1.5 + (2.0 / (r * r));
double tmp;
if (r <= 120000.0) {
tmp = t_0;
} else if (r <= 5.6e+84) {
tmp = w / (-2.6666666666666665 / (r * (r * w)));
} else if ((r <= 5.9e+99) || (!(r <= 2.7e+205) && (r <= 6.2e+235))) {
tmp = t_0;
} else {
tmp = -0.375 * ((r * w) * (r * w));
}
return tmp;
}
def code(v, w, r): t_0 = -1.5 + (2.0 / (r * r)) tmp = 0 if r <= 120000.0: tmp = t_0 elif r <= 5.6e+84: tmp = w / (-2.6666666666666665 / (r * (r * w))) elif (r <= 5.9e+99) or (not (r <= 2.7e+205) and (r <= 6.2e+235)): tmp = t_0 else: tmp = -0.375 * ((r * w) * (r * w)) return tmp
function code(v, w, r) t_0 = Float64(-1.5 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if (r <= 120000.0) tmp = t_0; elseif (r <= 5.6e+84) tmp = Float64(w / Float64(-2.6666666666666665 / Float64(r * Float64(r * w)))); elseif ((r <= 5.9e+99) || (!(r <= 2.7e+205) && (r <= 6.2e+235))) tmp = t_0; else tmp = Float64(-0.375 * Float64(Float64(r * w) * Float64(r * w))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = -1.5 + (2.0 / (r * r)); tmp = 0.0; if (r <= 120000.0) tmp = t_0; elseif (r <= 5.6e+84) tmp = w / (-2.6666666666666665 / (r * (r * w))); elseif ((r <= 5.9e+99) || (~((r <= 2.7e+205)) && (r <= 6.2e+235))) tmp = t_0; else tmp = -0.375 * ((r * w) * (r * w)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(-1.5 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 120000.0], t$95$0, If[LessEqual[r, 5.6e+84], N[(w / N[(-2.6666666666666665 / N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[r, 5.9e+99], And[N[Not[LessEqual[r, 2.7e+205]], $MachinePrecision], LessEqual[r, 6.2e+235]]], t$95$0, N[(-0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1.5 + \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 120000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;r \leq 5.6 \cdot 10^{+84}:\\
\;\;\;\;\frac{w}{\frac{-2.6666666666666665}{r \cdot \left(r \cdot w\right)}}\\
\mathbf{elif}\;r \leq 5.9 \cdot 10^{+99} \lor \neg \left(r \leq 2.7 \cdot 10^{+205}\right) \land r \leq 6.2 \cdot 10^{+235}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\\
\end{array}
\end{array}
if r < 1.2e5 or 5.59999999999999963e84 < r < 5.8999999999999999e99 or 2.70000000000000012e205 < r < 6.20000000000000022e235Initial program 85.9%
sub-neg85.9%
+-commutative85.9%
associate--l+85.9%
associate-/l*88.6%
distribute-neg-frac88.6%
associate-/r/88.6%
fma-def88.6%
sub-neg88.6%
Simplified81.4%
Taylor expanded in r around 0 71.1%
sub-neg71.1%
associate-*r/71.1%
metadata-eval71.1%
unpow271.1%
metadata-eval71.1%
Simplified71.1%
if 1.2e5 < r < 5.59999999999999963e84Initial program 91.7%
sub-neg91.7%
+-commutative91.7%
associate--l+91.7%
associate-/l*99.7%
distribute-neg-frac99.7%
associate-/r/99.6%
fma-def99.6%
sub-neg99.6%
Simplified99.9%
Taylor expanded in r around inf 71.0%
associate-/l*79.0%
*-commutative79.0%
unpow279.0%
unpow279.0%
*-commutative79.0%
fma-neg79.0%
metadata-eval79.0%
Simplified79.0%
associate-/l*78.8%
div-inv79.0%
Applied egg-rr79.0%
associate-*r/78.8%
*-rgt-identity78.8%
associate-/l/78.6%
associate-*l*78.7%
associate-*r*78.6%
Simplified78.6%
Taylor expanded in v around 0 72.2%
unpow272.2%
associate-*r*72.2%
*-commutative72.2%
associate-*l*72.2%
Simplified72.2%
if 5.8999999999999999e99 < r < 2.70000000000000012e205 or 6.20000000000000022e235 < r Initial program 86.5%
sub-neg86.5%
+-commutative86.5%
associate--l+86.5%
associate-/l*89.2%
distribute-neg-frac89.2%
associate-/r/89.2%
fma-def89.2%
sub-neg89.2%
Simplified71.8%
Taylor expanded in r around inf 55.1%
associate-/l*55.1%
*-commutative55.1%
unpow255.1%
unpow255.1%
*-commutative55.1%
fma-neg55.1%
metadata-eval55.1%
Simplified55.1%
Taylor expanded in v around 0 55.7%
*-commutative55.7%
unpow255.7%
unpow255.7%
swap-sqr68.9%
unpow268.9%
Simplified68.9%
unpow268.9%
Applied egg-rr68.9%
Final simplification70.9%
(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 86.3%
sub-neg86.3%
+-commutative86.3%
associate--l+86.3%
associate-/l*89.2%
distribute-neg-frac89.2%
associate-/r/89.2%
fma-def89.2%
sub-neg89.2%
Simplified81.0%
Taylor expanded in r around 0 62.6%
sub-neg62.6%
associate-*r/62.6%
metadata-eval62.6%
unpow262.6%
metadata-eval62.6%
Simplified62.6%
Final simplification62.6%
(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 86.3%
sub-neg86.3%
+-commutative86.3%
associate--l+86.3%
associate-/l*89.2%
distribute-neg-frac89.2%
associate-/r/89.2%
fma-def89.2%
sub-neg89.2%
Simplified81.0%
fma-udef81.0%
unswap-sqr99.7%
pow299.7%
div-inv99.7%
fma-def99.7%
pow299.7%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 48.2%
unpow248.2%
Simplified48.2%
Final simplification48.2%
herbie shell --seed 2023257
(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))