
(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) (pow (* r w) -2.0))) (fma v -2.0 3.0))) -4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - ((0.125 / ((1.0 - v) * pow((r * w), -2.0))) * fma(v, -2.0, 3.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(Float64(1.0 - v) * (Float64(r * w) ^ -2.0))) * fma(v, -2.0, 3.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[(N[(1.0 - v), $MachinePrecision] * N[Power[N[(r * w), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(v * -2.0 + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{0.125}{\left(1 - v\right) \cdot {\left(r \cdot w\right)}^{-2}} \cdot \mathsf{fma}\left(v, -2, 3\right)\right) + -4.5
\end{array}
Initial program 85.2%
sub-neg85.2%
associate-/l*87.8%
cancel-sign-sub-inv87.8%
metadata-eval87.8%
*-commutative87.8%
*-commutative87.8%
metadata-eval87.8%
Simplified87.8%
div-inv87.8%
+-commutative87.8%
*-commutative87.8%
fma-def87.8%
associate-*r*81.5%
unswap-sqr99.8%
pow299.8%
Applied egg-rr99.8%
expm1-log1p-u98.7%
expm1-udef98.7%
Applied egg-rr94.5%
expm1-def94.5%
expm1-log1p95.3%
times-frac99.8%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ -4.5 (- (+ 3.0 (/ 2.0 (* r r))) (/ (* 0.125 (+ 3.0 (* v -2.0))) (* (- 1.0 v) (/ 1.0 (pow (* r w) 2.0)))))))
double code(double v, double w, double r) {
return -4.5 + ((3.0 + (2.0 / (r * r))) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) * (1.0 / pow((r * w), 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 = (-4.5d0) + ((3.0d0 + (2.0d0 / (r * r))) - ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) / ((1.0d0 - v) * (1.0d0 / ((r * w) ** 2.0d0)))))
end function
public static double code(double v, double w, double r) {
return -4.5 + ((3.0 + (2.0 / (r * r))) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) * (1.0 / Math.pow((r * w), 2.0)))));
}
def code(v, w, r): return -4.5 + ((3.0 + (2.0 / (r * r))) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) * (1.0 / math.pow((r * w), 2.0)))))
function code(v, w, r) return Float64(-4.5 + 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(1.0 / (Float64(r * w) ^ 2.0)))))) end
function tmp = code(v, w, r) tmp = -4.5 + ((3.0 + (2.0 / (r * r))) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 - v) * (1.0 / ((r * w) ^ 2.0))))); end
code[v_, w_, r_] := N[(-4.5 + 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[(1.0 / N[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4.5 + \left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{\left(1 - v\right) \cdot \frac{1}{{\left(r \cdot w\right)}^{2}}}\right)
\end{array}
Initial program 85.2%
sub-neg85.2%
associate-/l*87.8%
cancel-sign-sub-inv87.8%
metadata-eval87.8%
*-commutative87.8%
*-commutative87.8%
metadata-eval87.8%
Simplified87.8%
div-inv87.8%
associate-*r*81.4%
unswap-sqr99.8%
pow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= (* w w) 1e+222)
(+
t_0
(- -1.5 (* (* r (* w (* r w))) (/ (+ 0.375 (* v -0.25)) (- 1.0 v)))))
(+ -4.5 (- (+ 3.0 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 ((w * w) <= 1e+222) {
tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} else {
tmp = -4.5 + ((3.0 + t_0) - (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) <= 1d+222) then
tmp = t_0 + ((-1.5d0) - ((r * (w * (r * w))) * ((0.375d0 + (v * (-0.25d0))) / (1.0d0 - v))))
else
tmp = (-4.5d0) + ((3.0d0 + t_0) - (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) <= 1e+222) {
tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} else {
tmp = -4.5 + ((3.0 + t_0) - (0.375 * ((r * w) * (r * w))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (w * w) <= 1e+222: tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))) else: tmp = -4.5 + ((3.0 + t_0) - (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) <= 1e+222) 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(-4.5 + Float64(Float64(3.0 + t_0) - 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) <= 1e+222) tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))); else tmp = -4.5 + ((3.0 + t_0) - (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], 1e+222], 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[(-4.5 + N[(N[(3.0 + t$95$0), $MachinePrecision] - 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 10^{+222}:\\
\;\;\;\;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}:\\
\;\;\;\;-4.5 + \left(\left(3 + t_0\right) - 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) < 1e222Initial program 90.7%
associate--l-90.7%
+-commutative90.7%
associate--l+90.7%
+-commutative90.7%
associate--r+90.8%
metadata-eval90.8%
associate-*l/94.0%
*-commutative94.0%
*-commutative94.0%
*-commutative94.0%
Simplified94.0%
Taylor expanded in r around 0 94.0%
*-commutative94.0%
unpow294.0%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
if 1e222 < (*.f64 w w) Initial program 73.8%
sub-neg73.8%
associate-/l*75.0%
cancel-sign-sub-inv75.0%
metadata-eval75.0%
*-commutative75.0%
*-commutative75.0%
metadata-eval75.0%
Simplified75.0%
Taylor expanded in v around 0 75.0%
*-commutative75.0%
*-commutative75.0%
unpow275.0%
unpow275.0%
swap-sqr99.0%
unpow299.0%
*-commutative99.0%
Simplified99.0%
*-commutative98.0%
unpow298.0%
Applied egg-rr99.0%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* (* r w) (* r w))) (t_1 (+ 3.0 (/ 2.0 (* r r)))))
(if (or (<= v -8.8e+28) (not (<= v 1.35e-46)))
(+ -4.5 (- t_1 (* t_0 0.25)))
(+ -4.5 (- t_1 (* 0.375 t_0))))))
double code(double v, double w, double r) {
double t_0 = (r * w) * (r * w);
double t_1 = 3.0 + (2.0 / (r * r));
double tmp;
if ((v <= -8.8e+28) || !(v <= 1.35e-46)) {
tmp = -4.5 + (t_1 - (t_0 * 0.25));
} else {
tmp = -4.5 + (t_1 - (0.375 * t_0));
}
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 * w) * (r * w)
t_1 = 3.0d0 + (2.0d0 / (r * r))
if ((v <= (-8.8d+28)) .or. (.not. (v <= 1.35d-46))) then
tmp = (-4.5d0) + (t_1 - (t_0 * 0.25d0))
else
tmp = (-4.5d0) + (t_1 - (0.375d0 * t_0))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = (r * w) * (r * w);
double t_1 = 3.0 + (2.0 / (r * r));
double tmp;
if ((v <= -8.8e+28) || !(v <= 1.35e-46)) {
tmp = -4.5 + (t_1 - (t_0 * 0.25));
} else {
tmp = -4.5 + (t_1 - (0.375 * t_0));
}
return tmp;
}
def code(v, w, r): t_0 = (r * w) * (r * w) t_1 = 3.0 + (2.0 / (r * r)) tmp = 0 if (v <= -8.8e+28) or not (v <= 1.35e-46): tmp = -4.5 + (t_1 - (t_0 * 0.25)) else: tmp = -4.5 + (t_1 - (0.375 * t_0)) return tmp
function code(v, w, r) t_0 = Float64(Float64(r * w) * Float64(r * w)) t_1 = Float64(3.0 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if ((v <= -8.8e+28) || !(v <= 1.35e-46)) tmp = Float64(-4.5 + Float64(t_1 - Float64(t_0 * 0.25))); else tmp = Float64(-4.5 + Float64(t_1 - Float64(0.375 * t_0))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (r * w) * (r * w); t_1 = 3.0 + (2.0 / (r * r)); tmp = 0.0; if ((v <= -8.8e+28) || ~((v <= 1.35e-46))) tmp = -4.5 + (t_1 - (t_0 * 0.25)); else tmp = -4.5 + (t_1 - (0.375 * t_0)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -8.8e+28], N[Not[LessEqual[v, 1.35e-46]], $MachinePrecision]], N[(-4.5 + N[(t$95$1 - N[(t$95$0 * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(t$95$1 - N[(0.375 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(r \cdot w\right) \cdot \left(r \cdot w\right)\\
t_1 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -8.8 \cdot 10^{+28} \lor \neg \left(v \leq 1.35 \cdot 10^{-46}\right):\\
\;\;\;\;-4.5 + \left(t_1 - t_0 \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(t_1 - 0.375 \cdot t_0\right)\\
\end{array}
\end{array}
if v < -8.79999999999999946e28 or 1.35e-46 < v Initial program 84.4%
sub-neg84.4%
associate-/l*89.8%
cancel-sign-sub-inv89.8%
metadata-eval89.8%
*-commutative89.8%
*-commutative89.8%
metadata-eval89.8%
Simplified89.8%
Taylor expanded in v around inf 82.0%
*-commutative82.0%
*-commutative82.0%
unpow282.0%
unpow282.0%
swap-sqr99.4%
unpow299.4%
*-commutative99.4%
Simplified99.4%
*-commutative99.4%
unpow299.4%
Applied egg-rr99.4%
if -8.79999999999999946e28 < v < 1.35e-46Initial program 86.0%
sub-neg86.0%
associate-/l*86.0%
cancel-sign-sub-inv86.0%
metadata-eval86.0%
*-commutative86.0%
*-commutative86.0%
metadata-eval86.0%
Simplified86.0%
Taylor expanded in v around 0 80.9%
*-commutative80.9%
*-commutative80.9%
unpow280.9%
unpow280.9%
swap-sqr99.7%
unpow299.7%
*-commutative99.7%
Simplified99.7%
*-commutative88.4%
unpow288.4%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (v w r) :precision binary64 (if (or (<= r -7.8e-125) (not (<= r 6.5e-102))) (+ (/ 2.0 (* r r)) (- (* (* r r) (* (* w w) -0.375)) 1.5)) (/ (/ 2.0 r) r)))
double code(double v, double w, double r) {
double tmp;
if ((r <= -7.8e-125) || !(r <= 6.5e-102)) {
tmp = (2.0 / (r * r)) + (((r * r) * ((w * w) * -0.375)) - 1.5);
} else {
tmp = (2.0 / 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) :: tmp
if ((r <= (-7.8d-125)) .or. (.not. (r <= 6.5d-102))) then
tmp = (2.0d0 / (r * r)) + (((r * r) * ((w * w) * (-0.375d0))) - 1.5d0)
else
tmp = (2.0d0 / r) / r
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if ((r <= -7.8e-125) || !(r <= 6.5e-102)) {
tmp = (2.0 / (r * r)) + (((r * r) * ((w * w) * -0.375)) - 1.5);
} else {
tmp = (2.0 / r) / r;
}
return tmp;
}
def code(v, w, r): tmp = 0 if (r <= -7.8e-125) or not (r <= 6.5e-102): tmp = (2.0 / (r * r)) + (((r * r) * ((w * w) * -0.375)) - 1.5) else: tmp = (2.0 / r) / r return tmp
function code(v, w, r) tmp = 0.0 if ((r <= -7.8e-125) || !(r <= 6.5e-102)) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(r * r) * Float64(Float64(w * w) * -0.375)) - 1.5)); else tmp = Float64(Float64(2.0 / r) / r); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if ((r <= -7.8e-125) || ~((r <= 6.5e-102))) tmp = (2.0 / (r * r)) + (((r * r) * ((w * w) * -0.375)) - 1.5); else tmp = (2.0 / r) / r; end tmp_2 = tmp; end
code[v_, w_, r_] := If[Or[LessEqual[r, -7.8e-125], N[Not[LessEqual[r, 6.5e-102]], $MachinePrecision]], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * r), $MachinePrecision] * N[(N[(w * w), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq -7.8 \cdot 10^{-125} \lor \neg \left(r \leq 6.5 \cdot 10^{-102}\right):\\
\;\;\;\;\frac{2}{r \cdot r} + \left(\left(r \cdot r\right) \cdot \left(\left(w \cdot w\right) \cdot -0.375\right) - 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r}\\
\end{array}
\end{array}
if r < -7.79999999999999965e-125 or 6.5000000000000003e-102 < r Initial program 89.5%
sub-neg89.5%
+-commutative89.5%
associate--l+89.5%
associate-/l*93.0%
distribute-neg-frac93.0%
associate-/r/93.1%
fma-def93.1%
sub-neg93.1%
Simplified84.4%
Taylor expanded in v around 0 82.2%
associate--l+82.2%
associate-*r/82.2%
metadata-eval82.2%
unpow282.2%
*-commutative82.2%
unpow282.2%
unpow282.2%
Simplified82.2%
Taylor expanded in w around 0 82.2%
associate-*r*82.2%
unpow282.2%
unpow282.2%
Simplified82.2%
if -7.79999999999999965e-125 < r < 6.5000000000000003e-102Initial program 73.5%
sub-neg73.5%
associate-/l*73.5%
cancel-sign-sub-inv73.5%
metadata-eval73.5%
*-commutative73.5%
*-commutative73.5%
metadata-eval73.5%
Simplified73.5%
Taylor expanded in v around inf 73.5%
*-commutative73.5%
*-commutative73.5%
unpow273.5%
unpow273.5%
swap-sqr99.9%
unpow299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in r around 0 99.9%
unpow299.9%
associate-/r*100.0%
Simplified100.0%
Final simplification86.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r -5e-128)
(+ t_0 (- (* (* (* r r) (* w w)) -0.375) 1.5))
(if (<= r 4.1e-101)
(/ (/ 2.0 r) r)
(+ t_0 (- (* (* r r) (* (* w w) -0.375)) 1.5))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= -5e-128) {
tmp = t_0 + ((((r * r) * (w * w)) * -0.375) - 1.5);
} else if (r <= 4.1e-101) {
tmp = (2.0 / r) / r;
} else {
tmp = t_0 + (((r * r) * ((w * w) * -0.375)) - 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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if (r <= (-5d-128)) then
tmp = t_0 + ((((r * r) * (w * w)) * (-0.375d0)) - 1.5d0)
else if (r <= 4.1d-101) then
tmp = (2.0d0 / r) / r
else
tmp = t_0 + (((r * r) * ((w * w) * (-0.375d0))) - 1.5d0)
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 <= -5e-128) {
tmp = t_0 + ((((r * r) * (w * w)) * -0.375) - 1.5);
} else if (r <= 4.1e-101) {
tmp = (2.0 / r) / r;
} else {
tmp = t_0 + (((r * r) * ((w * w) * -0.375)) - 1.5);
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= -5e-128: tmp = t_0 + ((((r * r) * (w * w)) * -0.375) - 1.5) elif r <= 4.1e-101: tmp = (2.0 / r) / r else: tmp = t_0 + (((r * r) * ((w * w) * -0.375)) - 1.5) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= -5e-128) tmp = Float64(t_0 + Float64(Float64(Float64(Float64(r * r) * Float64(w * w)) * -0.375) - 1.5)); elseif (r <= 4.1e-101) tmp = Float64(Float64(2.0 / r) / r); else tmp = Float64(t_0 + Float64(Float64(Float64(r * r) * Float64(Float64(w * w) * -0.375)) - 1.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= -5e-128) tmp = t_0 + ((((r * r) * (w * w)) * -0.375) - 1.5); elseif (r <= 4.1e-101) tmp = (2.0 / r) / r; else tmp = t_0 + (((r * r) * ((w * w) * -0.375)) - 1.5); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, -5e-128], N[(t$95$0 + N[(N[(N[(N[(r * r), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision] - 1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[r, 4.1e-101], N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision], N[(t$95$0 + N[(N[(N[(r * r), $MachinePrecision] * N[(N[(w * w), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq -5 \cdot 10^{-128}:\\
\;\;\;\;t_0 + \left(\left(\left(r \cdot r\right) \cdot \left(w \cdot w\right)\right) \cdot -0.375 - 1.5\right)\\
\mathbf{elif}\;r \leq 4.1 \cdot 10^{-101}:\\
\;\;\;\;\frac{\frac{2}{r}}{r}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(\left(r \cdot r\right) \cdot \left(\left(w \cdot w\right) \cdot -0.375\right) - 1.5\right)\\
\end{array}
\end{array}
if r < -5.0000000000000001e-128Initial program 88.8%
sub-neg88.8%
+-commutative88.8%
associate--l+88.8%
associate-/l*93.6%
distribute-neg-frac93.6%
associate-/r/93.6%
fma-def93.6%
sub-neg93.6%
Simplified81.0%
Taylor expanded in v around 0 78.5%
associate--l+78.5%
associate-*r/78.5%
metadata-eval78.5%
unpow278.5%
*-commutative78.5%
unpow278.5%
unpow278.5%
Simplified78.5%
if -5.0000000000000001e-128 < r < 4.10000000000000026e-101Initial program 73.5%
sub-neg73.5%
associate-/l*73.5%
cancel-sign-sub-inv73.5%
metadata-eval73.5%
*-commutative73.5%
*-commutative73.5%
metadata-eval73.5%
Simplified73.5%
Taylor expanded in v around inf 73.5%
*-commutative73.5%
*-commutative73.5%
unpow273.5%
unpow273.5%
swap-sqr99.9%
unpow299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in r around 0 99.9%
unpow299.9%
associate-/r*100.0%
Simplified100.0%
if 4.10000000000000026e-101 < r Initial program 90.3%
sub-neg90.3%
+-commutative90.3%
associate--l+90.3%
associate-/l*92.4%
distribute-neg-frac92.4%
associate-/r/92.4%
fma-def92.4%
sub-neg92.4%
Simplified88.1%
Taylor expanded in v around 0 86.1%
associate--l+86.1%
associate-*r/86.1%
metadata-eval86.1%
unpow286.1%
*-commutative86.1%
unpow286.1%
unpow286.1%
Simplified86.1%
Taylor expanded in w around 0 86.1%
associate-*r*86.1%
unpow286.1%
unpow286.1%
Simplified86.1%
Final simplification86.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r -7.5e-125)
(+ t_0 (- (* -0.25 (* (* r r) (* w w))) 1.5))
(if (<= r 9.5e-106)
(/ (/ 2.0 r) r)
(+ t_0 (- (* (* r r) (* (* w w) -0.375)) 1.5))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= -7.5e-125) {
tmp = t_0 + ((-0.25 * ((r * r) * (w * w))) - 1.5);
} else if (r <= 9.5e-106) {
tmp = (2.0 / r) / r;
} else {
tmp = t_0 + (((r * r) * ((w * w) * -0.375)) - 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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if (r <= (-7.5d-125)) then
tmp = t_0 + (((-0.25d0) * ((r * r) * (w * w))) - 1.5d0)
else if (r <= 9.5d-106) then
tmp = (2.0d0 / r) / r
else
tmp = t_0 + (((r * r) * ((w * w) * (-0.375d0))) - 1.5d0)
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 <= -7.5e-125) {
tmp = t_0 + ((-0.25 * ((r * r) * (w * w))) - 1.5);
} else if (r <= 9.5e-106) {
tmp = (2.0 / r) / r;
} else {
tmp = t_0 + (((r * r) * ((w * w) * -0.375)) - 1.5);
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= -7.5e-125: tmp = t_0 + ((-0.25 * ((r * r) * (w * w))) - 1.5) elif r <= 9.5e-106: tmp = (2.0 / r) / r else: tmp = t_0 + (((r * r) * ((w * w) * -0.375)) - 1.5) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= -7.5e-125) tmp = Float64(t_0 + Float64(Float64(-0.25 * Float64(Float64(r * r) * Float64(w * w))) - 1.5)); elseif (r <= 9.5e-106) tmp = Float64(Float64(2.0 / r) / r); else tmp = Float64(t_0 + Float64(Float64(Float64(r * r) * Float64(Float64(w * w) * -0.375)) - 1.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= -7.5e-125) tmp = t_0 + ((-0.25 * ((r * r) * (w * w))) - 1.5); elseif (r <= 9.5e-106) tmp = (2.0 / r) / r; else tmp = t_0 + (((r * r) * ((w * w) * -0.375)) - 1.5); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, -7.5e-125], N[(t$95$0 + N[(N[(-0.25 * N[(N[(r * r), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[r, 9.5e-106], N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision], N[(t$95$0 + N[(N[(N[(r * r), $MachinePrecision] * N[(N[(w * w), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq -7.5 \cdot 10^{-125}:\\
\;\;\;\;t_0 + \left(-0.25 \cdot \left(\left(r \cdot r\right) \cdot \left(w \cdot w\right)\right) - 1.5\right)\\
\mathbf{elif}\;r \leq 9.5 \cdot 10^{-106}:\\
\;\;\;\;\frac{\frac{2}{r}}{r}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(\left(r \cdot r\right) \cdot \left(\left(w \cdot w\right) \cdot -0.375\right) - 1.5\right)\\
\end{array}
\end{array}
if r < -7.5e-125Initial program 88.8%
sub-neg88.8%
+-commutative88.8%
associate--l+88.8%
associate-/l*93.6%
distribute-neg-frac93.6%
associate-/r/93.6%
fma-def93.6%
sub-neg93.6%
Simplified81.0%
Taylor expanded in v around inf 80.2%
associate--l+80.2%
associate-*r/80.2%
metadata-eval80.2%
unpow280.2%
*-commutative80.2%
unpow280.2%
unpow280.2%
Simplified80.2%
if -7.5e-125 < r < 9.4999999999999994e-106Initial program 73.5%
sub-neg73.5%
associate-/l*73.5%
cancel-sign-sub-inv73.5%
metadata-eval73.5%
*-commutative73.5%
*-commutative73.5%
metadata-eval73.5%
Simplified73.5%
Taylor expanded in v around inf 73.5%
*-commutative73.5%
*-commutative73.5%
unpow273.5%
unpow273.5%
swap-sqr99.9%
unpow299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in r around 0 99.9%
unpow299.9%
associate-/r*100.0%
Simplified100.0%
if 9.4999999999999994e-106 < r Initial program 90.3%
sub-neg90.3%
+-commutative90.3%
associate--l+90.3%
associate-/l*92.4%
distribute-neg-frac92.4%
associate-/r/92.4%
fma-def92.4%
sub-neg92.4%
Simplified88.1%
Taylor expanded in v around 0 86.1%
associate--l+86.1%
associate-*r/86.1%
metadata-eval86.1%
unpow286.1%
*-commutative86.1%
unpow286.1%
unpow286.1%
Simplified86.1%
Taylor expanded in w around 0 86.1%
associate-*r*86.1%
unpow286.1%
unpow286.1%
Simplified86.1%
Final simplification87.5%
(FPCore (v w r) :precision binary64 (+ -4.5 (- (+ 3.0 (/ 2.0 (* r r))) (* (* (* r w) (* r w)) 0.25))))
double code(double v, double w, double r) {
return -4.5 + ((3.0 + (2.0 / (r * r))) - (((r * w) * (r * w)) * 0.25));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = (-4.5d0) + ((3.0d0 + (2.0d0 / (r * r))) - (((r * w) * (r * w)) * 0.25d0))
end function
public static double code(double v, double w, double r) {
return -4.5 + ((3.0 + (2.0 / (r * r))) - (((r * w) * (r * w)) * 0.25));
}
def code(v, w, r): return -4.5 + ((3.0 + (2.0 / (r * r))) - (((r * w) * (r * w)) * 0.25))
function code(v, w, r) return Float64(-4.5 + Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))) end
function tmp = code(v, w, r) tmp = -4.5 + ((3.0 + (2.0 / (r * r))) - (((r * w) * (r * w)) * 0.25)); end
code[v_, w_, r_] := N[(-4.5 + N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4.5 + \left(\left(3 + \frac{2}{r \cdot r}\right) - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)
\end{array}
Initial program 85.2%
sub-neg85.2%
associate-/l*87.8%
cancel-sign-sub-inv87.8%
metadata-eval87.8%
*-commutative87.8%
*-commutative87.8%
metadata-eval87.8%
Simplified87.8%
Taylor expanded in v around inf 79.4%
*-commutative79.4%
*-commutative79.4%
unpow279.4%
unpow279.4%
swap-sqr93.6%
unpow293.6%
*-commutative93.6%
Simplified93.6%
*-commutative93.6%
unpow293.6%
Applied egg-rr93.6%
Final simplification93.6%
(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.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%
Simplified81.5%
Taylor expanded in r around 0 56.7%
sub-neg56.7%
associate-*r/56.7%
metadata-eval56.7%
unpow256.7%
metadata-eval56.7%
Simplified56.7%
Final simplification56.7%
(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.2%
sub-neg85.2%
associate-/l*87.8%
cancel-sign-sub-inv87.8%
metadata-eval87.8%
*-commutative87.8%
*-commutative87.8%
metadata-eval87.8%
Simplified87.8%
Taylor expanded in v around inf 79.4%
*-commutative79.4%
*-commutative79.4%
unpow279.4%
unpow279.4%
swap-sqr93.6%
unpow293.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in r around 0 42.7%
unpow242.7%
Simplified42.7%
Final simplification42.7%
herbie shell --seed 2023192
(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))