
(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 (+ (/ 2.0 (* r r)) (+ -1.5 (/ (+ 0.375 (* -0.25 v)) (* (- 1.0 v) (/ (/ (/ -1.0 r) w) (* r w)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((1.0 - v) * (((-1.0 / 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 + ((-0.25d0) * v)) / ((1.0d0 - v) * ((((-1.0d0) / 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 + (-0.25 * v)) / ((1.0 - v) * (((-1.0 / r) / w) / (r * w)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((1.0 - v) * (((-1.0 / r) / w) / (r * w)))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(Float64(0.375 + Float64(-0.25 * v)) / Float64(Float64(1.0 - v) * Float64(Float64(Float64(-1.0 / r) / w) / Float64(r * w)))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((1.0 - v) * (((-1.0 / r) / w) / (r * w))))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(N[(0.375 + N[(-0.25 * v), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] * N[(N[(N[(-1.0 / r), $MachinePrecision] / w), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + -0.25 \cdot v}{\left(1 - v\right) \cdot \frac{\frac{\frac{-1}{r}}{w}}{r \cdot w}}\right)
\end{array}
Initial program 86.5%
Simplified88.2%
fma-undefine88.2%
*-commutative88.2%
+-commutative88.2%
metadata-eval88.2%
cancel-sign-sub-inv88.2%
associate-*r/88.6%
*-commutative88.6%
associate-/l*89.0%
clear-num89.0%
un-div-inv89.0%
Applied egg-rr99.8%
*-un-lft-identity99.8%
div-inv99.8%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
sqr-pow99.8%
metadata-eval99.8%
unpow-199.8%
metadata-eval99.8%
unpow-199.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
associate-/r*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* r (* (* w w) (/ r (+ v -1.0))))) (t_1 (/ 2.0 (* r r))))
(if (or (<= v -2e+22) (not (<= v 1.5)))
(+ t_1 (+ -1.5 (* (* -0.25 v) t_0)))
(+ t_1 (+ -1.5 (* 0.375 t_0))))))
double code(double v, double w, double r) {
double t_0 = r * ((w * w) * (r / (v + -1.0)));
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -2e+22) || !(v <= 1.5)) {
tmp = t_1 + (-1.5 + ((-0.25 * v) * t_0));
} else {
tmp = t_1 + (-1.5 + (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 * w) * (r / (v + (-1.0d0))))
t_1 = 2.0d0 / (r * r)
if ((v <= (-2d+22)) .or. (.not. (v <= 1.5d0))) then
tmp = t_1 + ((-1.5d0) + (((-0.25d0) * v) * t_0))
else
tmp = t_1 + ((-1.5d0) + (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 * w) * (r / (v + -1.0)));
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -2e+22) || !(v <= 1.5)) {
tmp = t_1 + (-1.5 + ((-0.25 * v) * t_0));
} else {
tmp = t_1 + (-1.5 + (0.375 * t_0));
}
return tmp;
}
def code(v, w, r): t_0 = r * ((w * w) * (r / (v + -1.0))) t_1 = 2.0 / (r * r) tmp = 0 if (v <= -2e+22) or not (v <= 1.5): tmp = t_1 + (-1.5 + ((-0.25 * v) * t_0)) else: tmp = t_1 + (-1.5 + (0.375 * t_0)) return tmp
function code(v, w, r) t_0 = Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0)))) t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -2e+22) || !(v <= 1.5)) tmp = Float64(t_1 + Float64(-1.5 + Float64(Float64(-0.25 * v) * t_0))); else tmp = Float64(t_1 + Float64(-1.5 + Float64(0.375 * t_0))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = r * ((w * w) * (r / (v + -1.0))); t_1 = 2.0 / (r * r); tmp = 0.0; if ((v <= -2e+22) || ~((v <= 1.5))) tmp = t_1 + (-1.5 + ((-0.25 * v) * t_0)); else tmp = t_1 + (-1.5 + (0.375 * t_0)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -2e+22], N[Not[LessEqual[v, 1.5]], $MachinePrecision]], N[(t$95$1 + N[(-1.5 + N[(N[(-0.25 * v), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(-1.5 + N[(0.375 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2 \cdot 10^{+22} \lor \neg \left(v \leq 1.5\right):\\
\;\;\;\;t\_1 + \left(-1.5 + \left(-0.25 \cdot v\right) \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \left(-1.5 + 0.375 \cdot t\_0\right)\\
\end{array}
\end{array}
if v < -2e22 or 1.5 < v Initial program 82.7%
Simplified86.3%
Taylor expanded in v around inf 86.3%
*-commutative86.3%
Simplified86.3%
if -2e22 < v < 1.5Initial program 90.2%
Simplified90.2%
Taylor expanded in v around 0 90.2%
Final simplification88.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 6.2e-59)
(- (+ t_0 3.0) 4.5)
(if (<= r 55000000.0)
(+ t_0 (+ -1.5 (* 0.375 (* r (* (* w w) (/ r (+ v -1.0)))))))
(-
3.0
(+
4.5
(*
(* 0.125 (+ 3.0 (* v -2.0)))
(* (* r w) (* w (/ r (- 1.0 v)))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 6.2e-59) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 55000000.0) {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * (r / (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.2d-59) then
tmp = (t_0 + 3.0d0) - 4.5d0
else if (r <= 55000000.0d0) then
tmp = t_0 + ((-1.5d0) + (0.375d0 * (r * ((w * w) * (r / (v + (-1.0d0)))))))
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * w) * (w * (r / (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.2e-59) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 55000000.0) {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * (r / (1.0 - v))))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 6.2e-59: tmp = (t_0 + 3.0) - 4.5 elif r <= 55000000.0: tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))) else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * (r / (1.0 - v)))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 6.2e-59) tmp = Float64(Float64(t_0 + 3.0) - 4.5); elseif (r <= 55000000.0) tmp = Float64(t_0 + Float64(-1.5 + Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(Float64(r * w) * Float64(w * Float64(r / 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.2e-59) tmp = (t_0 + 3.0) - 4.5; elseif (r <= 55000000.0) tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))); else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * (r / (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.2e-59], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 55000000.0], N[(t$95$0 + N[(-1.5 + N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(4.5 + N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(w * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 6.2 \cdot 10^{-59}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 55000000:\\
\;\;\;\;t\_0 + \left(-1.5 + 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \left(4.5 + \left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \left(w \cdot \frac{r}{1 - v}\right)\right)\right)\\
\end{array}
\end{array}
if r < 6.19999999999999998e-59Initial program 84.7%
Simplified80.4%
Taylor expanded in r around 0 69.3%
if 6.19999999999999998e-59 < r < 5.5e7Initial program 84.6%
Simplified84.6%
Taylor expanded in v around 0 84.6%
if 5.5e7 < r Initial program 90.9%
associate--l-90.9%
associate-*l*85.1%
sqr-neg85.1%
associate-*l*90.9%
associate-/l*96.0%
fma-define96.0%
Simplified96.0%
Taylor expanded in r around inf 96.0%
associate-/l*94.7%
*-commutative94.7%
associate-*r/94.7%
associate-*l*97.4%
associate-*r*99.9%
Applied egg-rr99.9%
Final simplification78.6%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 6.2e-59)
(- (+ t_0 3.0) 4.5)
(if (<= r 3.4e+220)
(+ t_0 (+ -1.5 (* 0.375 (* r (* (* w w) (/ r (+ v -1.0)))))))
(- 3.0 (+ 4.5 (* (* 0.125 (+ 3.0 (* 2.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 <= 6.2e-59) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 3.4e+220) {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (2.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 <= 6.2d-59) then
tmp = (t_0 + 3.0d0) - 4.5d0
else if (r <= 3.4d+220) then
tmp = t_0 + ((-1.5d0) + (0.375d0 * (r * ((w * w) * (r / (v + (-1.0d0)))))))
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (2.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 <= 6.2e-59) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 3.4e+220) {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (2.0 * v))) * (r * (r * (w * w)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 6.2e-59: tmp = (t_0 + 3.0) - 4.5 elif r <= 3.4e+220: tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))) else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (2.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 <= 6.2e-59) tmp = Float64(Float64(t_0 + 3.0) - 4.5); elseif (r <= 3.4e+220) tmp = Float64(t_0 + Float64(-1.5 + Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(2.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 <= 6.2e-59) tmp = (t_0 + 3.0) - 4.5; elseif (r <= 3.4e+220) tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))); else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (2.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, 6.2e-59], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 3.4e+220], N[(t$95$0 + N[(-1.5 + N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(4.5 + N[(N[(0.125 * N[(3.0 + N[(2.0 * v), $MachinePrecision]), $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 6.2 \cdot 10^{-59}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 3.4 \cdot 10^{+220}:\\
\;\;\;\;t\_0 + \left(-1.5 + 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \left(4.5 + \left(0.125 \cdot \left(3 + 2 \cdot v\right)\right) \cdot \left(r \cdot \left(r \cdot \left(w \cdot w\right)\right)\right)\right)\\
\end{array}
\end{array}
if r < 6.19999999999999998e-59Initial program 84.7%
Simplified80.4%
Taylor expanded in r around 0 69.3%
if 6.19999999999999998e-59 < r < 3.4e220Initial program 91.8%
Simplified95.8%
Taylor expanded in v around 0 78.6%
if 3.4e220 < r Initial program 82.5%
associate--l-82.5%
associate-*l*81.3%
sqr-neg81.3%
associate-*l*82.5%
associate-/l*82.5%
fma-define82.5%
Simplified82.5%
Taylor expanded in r around inf 82.5%
Taylor expanded in v around 0 57.5%
metadata-eval57.5%
distribute-lft-neg-in57.5%
neg-sub057.5%
add-sqr-sqrt32.5%
sqrt-unprod50.9%
swap-sqr50.9%
metadata-eval50.9%
metadata-eval50.9%
swap-sqr50.9%
sqrt-unprod18.8%
add-sqr-sqrt76.2%
*-commutative76.2%
Applied egg-rr76.2%
neg-sub076.2%
distribute-rgt-neg-in76.2%
metadata-eval76.2%
*-commutative76.2%
Simplified76.2%
Final simplification72.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 6.2e-59)
(- (+ t_0 3.0) 4.5)
(+ t_0 (+ -1.5 (* 0.375 (* r (* (* w w) (/ r (+ v -1.0))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 6.2e-59) {
tmp = (t_0 + 3.0) - 4.5;
} else {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.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) :: tmp
t_0 = 2.0d0 / (r * r)
if (r <= 6.2d-59) then
tmp = (t_0 + 3.0d0) - 4.5d0
else
tmp = t_0 + ((-1.5d0) + (0.375d0 * (r * ((w * w) * (r / (v + (-1.0d0)))))))
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.2e-59) {
tmp = (t_0 + 3.0) - 4.5;
} else {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 6.2e-59: tmp = (t_0 + 3.0) - 4.5 else: tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 6.2e-59) tmp = Float64(Float64(t_0 + 3.0) - 4.5); else tmp = Float64(t_0 + Float64(-1.5 + Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 6.2e-59) tmp = (t_0 + 3.0) - 4.5; else tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))); 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.2e-59], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], N[(t$95$0 + N[(-1.5 + N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 6.2 \cdot 10^{-59}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 + 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\end{array}
\end{array}
if r < 6.19999999999999998e-59Initial program 84.7%
Simplified80.4%
Taylor expanded in r around 0 69.3%
if 6.19999999999999998e-59 < r Initial program 90.0%
Simplified93.3%
Taylor expanded in v around 0 74.5%
Final simplification71.0%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (+ -1.5 (/ (+ 0.375 (* -0.25 v)) (/ (+ v -1.0) (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((v + -1.0) / ((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 + ((-0.25d0) * v)) / ((v + (-1.0d0)) / ((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 + (-0.25 * v)) / ((v + -1.0) / ((r * w) * (r * w)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((v + -1.0) / ((r * w) * (r * w)))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(Float64(0.375 + Float64(-0.25 * v)) / Float64(Float64(v + -1.0) / Float64(Float64(r * w) * Float64(r * w)))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 + ((0.375 + (-0.25 * v)) / ((v + -1.0) / ((r * w) * (r * w))))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(N[(0.375 + N[(-0.25 * v), $MachinePrecision]), $MachinePrecision] / N[(N[(v + -1.0), $MachinePrecision] / N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + -0.25 \cdot v}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right)
\end{array}
Initial program 86.5%
Simplified88.2%
fma-undefine88.2%
*-commutative88.2%
+-commutative88.2%
metadata-eval88.2%
cancel-sign-sub-inv88.2%
associate-*r/88.6%
*-commutative88.6%
associate-/l*89.0%
clear-num89.0%
un-div-inv89.0%
Applied egg-rr99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (if (<= r 13600.0) (- (+ (/ 2.0 (* r r)) 3.0) 4.5) (- 3.0 (+ 4.5 (* (* (* r w) (* r w)) (* 0.125 (+ 3.0 (* v -2.0))))))))
double code(double v, double w, double r) {
double tmp;
if (r <= 13600.0) {
tmp = ((2.0 / (r * r)) + 3.0) - 4.5;
} else {
tmp = 3.0 - (4.5 + (((r * w) * (r * w)) * (0.125 * (3.0 + (v * -2.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) :: tmp
if (r <= 13600.0d0) then
tmp = ((2.0d0 / (r * r)) + 3.0d0) - 4.5d0
else
tmp = 3.0d0 - (4.5d0 + (((r * w) * (r * w)) * (0.125d0 * (3.0d0 + (v * (-2.0d0))))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 13600.0) {
tmp = ((2.0 / (r * r)) + 3.0) - 4.5;
} else {
tmp = 3.0 - (4.5 + (((r * w) * (r * w)) * (0.125 * (3.0 + (v * -2.0)))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 13600.0: tmp = ((2.0 / (r * r)) + 3.0) - 4.5 else: tmp = 3.0 - (4.5 + (((r * w) * (r * w)) * (0.125 * (3.0 + (v * -2.0))))) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 13600.0) tmp = Float64(Float64(Float64(2.0 / Float64(r * r)) + 3.0) - 4.5); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(Float64(r * w) * Float64(r * w)) * Float64(0.125 * Float64(3.0 + Float64(v * -2.0)))))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 13600.0) tmp = ((2.0 / (r * r)) + 3.0) - 4.5; else tmp = 3.0 - (4.5 + (((r * w) * (r * w)) * (0.125 * (3.0 + (v * -2.0))))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 13600.0], N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], N[(3.0 - N[(4.5 + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 13600:\\
\;\;\;\;\left(\frac{2}{r \cdot r} + 3\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;3 - \left(4.5 + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot \left(0.125 \cdot \left(3 + v \cdot -2\right)\right)\right)\\
\end{array}
\end{array}
if r < 13600Initial program 84.6%
Simplified80.5%
Taylor expanded in r around 0 68.3%
if 13600 < r Initial program 91.1%
associate--l-91.1%
associate-*l*85.5%
sqr-neg85.5%
associate-*l*91.1%
associate-/l*96.1%
fma-define96.1%
Simplified96.1%
Taylor expanded in r around inf 96.1%
associate-/l*94.9%
*-commutative94.9%
associate-*r/94.8%
associate-*l*97.4%
associate-*r*99.9%
Applied egg-rr99.9%
Taylor expanded in v around 0 74.7%
Final simplification70.1%
(FPCore (v w r) :precision binary64 (- (+ (/ 2.0 (* r r)) 3.0) 4.5))
double code(double v, double w, double r) {
return ((2.0 / (r * r)) + 3.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 = ((2.0d0 / (r * r)) + 3.0d0) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((2.0 / (r * r)) + 3.0) - 4.5;
}
def code(v, w, r): return ((2.0 / (r * r)) + 3.0) - 4.5
function code(v, w, r) return Float64(Float64(Float64(2.0 / Float64(r * r)) + 3.0) - 4.5) end
function tmp = code(v, w, r) tmp = ((2.0 / (r * r)) + 3.0) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{2}{r \cdot r} + 3\right) - 4.5
\end{array}
Initial program 86.5%
Simplified82.3%
Taylor expanded in r around 0 56.7%
Final simplification56.7%
(FPCore (v w r) :precision binary64 (+ -1.5 (* 2.0 (/ (/ 1.0 r) r))))
double code(double v, double w, double r) {
return -1.5 + (2.0 * ((1.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 * ((1.0d0 / r) / r))
end function
public static double code(double v, double w, double r) {
return -1.5 + (2.0 * ((1.0 / r) / r));
}
def code(v, w, r): return -1.5 + (2.0 * ((1.0 / r) / r))
function code(v, w, r) return Float64(-1.5 + Float64(2.0 * Float64(Float64(1.0 / r) / r))) end
function tmp = code(v, w, r) tmp = -1.5 + (2.0 * ((1.0 / r) / r)); end
code[v_, w_, r_] := N[(-1.5 + N[(2.0 * N[(N[(1.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1.5 + 2 \cdot \frac{\frac{1}{r}}{r}
\end{array}
Initial program 86.5%
Simplified82.3%
Taylor expanded in r around 0 56.7%
associate--l+56.7%
div-inv56.7%
fma-neg56.7%
pow256.7%
pow-flip56.8%
metadata-eval56.8%
metadata-eval56.8%
Applied egg-rr56.8%
+-commutative56.8%
fma-undefine56.8%
associate-+l+56.8%
metadata-eval56.8%
Simplified56.8%
sqr-pow56.6%
metadata-eval56.6%
unpow-156.6%
metadata-eval56.6%
unpow-156.6%
Applied egg-rr56.6%
associate-*l/56.7%
*-lft-identity56.7%
Simplified56.7%
Final simplification56.7%
(FPCore (v w r) :precision binary64 -1.5)
double code(double v, double w, double r) {
return -1.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = -1.5d0
end function
public static double code(double v, double w, double r) {
return -1.5;
}
def code(v, w, r): return -1.5
function code(v, w, r) return -1.5 end
function tmp = code(v, w, r) tmp = -1.5; end
code[v_, w_, r_] := -1.5
\begin{array}{l}
\\
-1.5
\end{array}
Initial program 86.5%
Simplified82.3%
Taylor expanded in r around 0 56.7%
Taylor expanded in r around inf 16.5%
herbie shell --seed 2024146
(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))