
(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 13 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 (* v -0.25)) (/ (+ v -1.0) (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + ((0.375 + (v * -0.25)) / ((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 + (v * (-0.25d0))) / ((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 + (v * -0.25)) / ((v + -1.0) / ((r * w) * (r * w)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 + ((0.375 + (v * -0.25)) / ((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(v * -0.25)) / 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 + (v * -0.25)) / ((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[(v * -0.25), $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 + v \cdot -0.25}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right)
\end{array}
Initial program 87.7%
Simplified89.1%
fma-undefine89.1%
*-commutative89.1%
+-commutative89.1%
associate-*r/89.5%
*-commutative89.5%
associate-/l*89.5%
clear-num89.5%
un-div-inv89.5%
distribute-rgt-in89.5%
metadata-eval89.5%
*-commutative89.5%
associate-*l*89.5%
metadata-eval89.5%
associate-*r*85.2%
pow285.2%
pow285.2%
pow-prod-down99.8%
*-commutative99.8%
Applied egg-rr99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* 0.125 (+ 3.0 (* v -2.0)))) (t_1 (/ 2.0 (* r r))))
(if (<= r 6.5e-117)
(- (+ t_1 3.0) 4.5)
(if (<= r 26500000000000.0)
(+ t_1 (- -1.5 (* 0.375 (* r (* (* w w) (/ r (- 1.0 v)))))))
(if (or (<= r 7.6e+140) (not (<= r 3.4e+262)))
(- 3.0 (- 4.5 (* t_0 (* w (* r (* w (/ r v)))))))
(- 3.0 (+ 4.5 (* t_0 (* r (* r (* w w)))))))))))
double code(double v, double w, double r) {
double t_0 = 0.125 * (3.0 + (v * -2.0));
double t_1 = 2.0 / (r * r);
double tmp;
if (r <= 6.5e-117) {
tmp = (t_1 + 3.0) - 4.5;
} else if (r <= 26500000000000.0) {
tmp = t_1 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} else if ((r <= 7.6e+140) || !(r <= 3.4e+262)) {
tmp = 3.0 - (4.5 - (t_0 * (w * (r * (w * (r / v))))));
} else {
tmp = 3.0 - (4.5 + (t_0 * (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) :: t_1
real(8) :: tmp
t_0 = 0.125d0 * (3.0d0 + (v * (-2.0d0)))
t_1 = 2.0d0 / (r * r)
if (r <= 6.5d-117) then
tmp = (t_1 + 3.0d0) - 4.5d0
else if (r <= 26500000000000.0d0) then
tmp = t_1 + ((-1.5d0) - (0.375d0 * (r * ((w * w) * (r / (1.0d0 - v))))))
else if ((r <= 7.6d+140) .or. (.not. (r <= 3.4d+262))) then
tmp = 3.0d0 - (4.5d0 - (t_0 * (w * (r * (w * (r / v))))))
else
tmp = 3.0d0 - (4.5d0 + (t_0 * (r * (r * (w * w)))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 0.125 * (3.0 + (v * -2.0));
double t_1 = 2.0 / (r * r);
double tmp;
if (r <= 6.5e-117) {
tmp = (t_1 + 3.0) - 4.5;
} else if (r <= 26500000000000.0) {
tmp = t_1 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} else if ((r <= 7.6e+140) || !(r <= 3.4e+262)) {
tmp = 3.0 - (4.5 - (t_0 * (w * (r * (w * (r / v))))));
} else {
tmp = 3.0 - (4.5 + (t_0 * (r * (r * (w * w)))));
}
return tmp;
}
def code(v, w, r): t_0 = 0.125 * (3.0 + (v * -2.0)) t_1 = 2.0 / (r * r) tmp = 0 if r <= 6.5e-117: tmp = (t_1 + 3.0) - 4.5 elif r <= 26500000000000.0: tmp = t_1 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))) elif (r <= 7.6e+140) or not (r <= 3.4e+262): tmp = 3.0 - (4.5 - (t_0 * (w * (r * (w * (r / v)))))) else: tmp = 3.0 - (4.5 + (t_0 * (r * (r * (w * w))))) return tmp
function code(v, w, r) t_0 = Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 6.5e-117) tmp = Float64(Float64(t_1 + 3.0) - 4.5); elseif (r <= 26500000000000.0) tmp = Float64(t_1 + Float64(-1.5 - Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(1.0 - v))))))); elseif ((r <= 7.6e+140) || !(r <= 3.4e+262)) tmp = Float64(3.0 - Float64(4.5 - Float64(t_0 * Float64(w * Float64(r * Float64(w * Float64(r / v))))))); else tmp = Float64(3.0 - Float64(4.5 + Float64(t_0 * Float64(r * Float64(r * Float64(w * w)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 0.125 * (3.0 + (v * -2.0)); t_1 = 2.0 / (r * r); tmp = 0.0; if (r <= 6.5e-117) tmp = (t_1 + 3.0) - 4.5; elseif (r <= 26500000000000.0) tmp = t_1 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))); elseif ((r <= 7.6e+140) || ~((r <= 3.4e+262))) tmp = 3.0 - (4.5 - (t_0 * (w * (r * (w * (r / v)))))); else tmp = 3.0 - (4.5 + (t_0 * (r * (r * (w * w))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 6.5e-117], N[(N[(t$95$1 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 26500000000000.0], N[(t$95$1 + N[(-1.5 - N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[r, 7.6e+140], N[Not[LessEqual[r, 3.4e+262]], $MachinePrecision]], N[(3.0 - N[(4.5 - N[(t$95$0 * N[(w * N[(r * N[(w * N[(r / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(4.5 + N[(t$95$0 * N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.125 \cdot \left(3 + v \cdot -2\right)\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 6.5 \cdot 10^{-117}:\\
\;\;\;\;\left(t\_1 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 26500000000000:\\
\;\;\;\;t\_1 + \left(-1.5 - 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{1 - v}\right)\right)\right)\\
\mathbf{elif}\;r \leq 7.6 \cdot 10^{+140} \lor \neg \left(r \leq 3.4 \cdot 10^{+262}\right):\\
\;\;\;\;3 - \left(4.5 - t\_0 \cdot \left(w \cdot \left(r \cdot \left(w \cdot \frac{r}{v}\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \left(4.5 + t\_0 \cdot \left(r \cdot \left(r \cdot \left(w \cdot w\right)\right)\right)\right)\\
\end{array}
\end{array}
if r < 6.5000000000000001e-117Initial program 85.6%
Simplified85.0%
Taylor expanded in r around 0 68.7%
if 6.5000000000000001e-117 < r < 2.65e13Initial program 94.9%
Simplified94.9%
Taylor expanded in v around 0 94.9%
if 2.65e13 < r < 7.6000000000000002e140 or 3.4000000000000002e262 < r Initial program 94.9%
associate--l-94.9%
associate-*l*94.8%
sqr-neg94.8%
associate-*l*94.9%
associate-/l*97.4%
fma-define97.4%
Simplified97.4%
Taylor expanded in r around inf 97.4%
associate-/l*97.4%
*-commutative97.4%
associate-*r/97.3%
*-commutative97.3%
associate-*l*99.8%
associate-*l*99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 82.3%
associate-*r/82.3%
mul-1-neg82.3%
*-commutative82.3%
distribute-rgt-neg-in82.3%
associate-/l*82.3%
Simplified82.3%
if 7.6000000000000002e140 < r < 3.4000000000000002e262Initial program 85.2%
associate--l-85.2%
associate-*l*54.9%
sqr-neg54.9%
associate-*l*85.2%
associate-/l*89.1%
fma-define89.1%
Simplified89.1%
Taylor expanded in r around inf 89.1%
Taylor expanded in v around 0 81.0%
Final simplification73.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (/ r (- 1.0 v))))
(if (<= r 7.8e-118)
(- (+ t_0 3.0) 4.5)
(if (<= r 3e+136)
(+ t_0 (- -1.5 (* (+ 0.375 (* v -0.25)) (* r (* (* w w) t_1)))))
(-
3.0
(+ 4.5 (* (* 0.125 (+ 3.0 (* v -2.0))) (* (* r w) (* w t_1)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = r / (1.0 - v);
double tmp;
if (r <= 7.8e-118) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 3e+136) {
tmp = t_0 + (-1.5 - ((0.375 + (v * -0.25)) * (r * ((w * w) * t_1))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_1))));
}
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 / (1.0d0 - v)
if (r <= 7.8d-118) then
tmp = (t_0 + 3.0d0) - 4.5d0
else if (r <= 3d+136) then
tmp = t_0 + ((-1.5d0) - ((0.375d0 + (v * (-0.25d0))) * (r * ((w * w) * t_1))))
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * w) * (w * t_1))))
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 / (1.0 - v);
double tmp;
if (r <= 7.8e-118) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 3e+136) {
tmp = t_0 + (-1.5 - ((0.375 + (v * -0.25)) * (r * ((w * w) * t_1))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_1))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = r / (1.0 - v) tmp = 0 if r <= 7.8e-118: tmp = (t_0 + 3.0) - 4.5 elif r <= 3e+136: tmp = t_0 + (-1.5 - ((0.375 + (v * -0.25)) * (r * ((w * w) * t_1)))) else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_1)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(r / Float64(1.0 - v)) tmp = 0.0 if (r <= 7.8e-118) tmp = Float64(Float64(t_0 + 3.0) - 4.5); elseif (r <= 3e+136) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(0.375 + Float64(v * -0.25)) * Float64(r * Float64(Float64(w * w) * t_1))))); 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 * t_1))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = r / (1.0 - v); tmp = 0.0; if (r <= 7.8e-118) tmp = (t_0 + 3.0) - 4.5; elseif (r <= 3e+136) tmp = t_0 + (-1.5 - ((0.375 + (v * -0.25)) * (r * ((w * w) * t_1)))); else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_1)))); 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[(1.0 - v), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 7.8e-118], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 3e+136], N[(t$95$0 + N[(-1.5 - N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] * N[(r * N[(N[(w * w), $MachinePrecision] * t$95$1), $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 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := \frac{r}{1 - v}\\
\mathbf{if}\;r \leq 7.8 \cdot 10^{-118}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 3 \cdot 10^{+136}:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(0.375 + v \cdot -0.25\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot t\_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 t\_1\right)\right)\right)\\
\end{array}
\end{array}
if r < 7.80000000000000002e-118Initial program 85.6%
Simplified85.0%
Taylor expanded in r around 0 68.7%
if 7.80000000000000002e-118 < r < 2.99999999999999979e136Initial program 97.8%
Simplified97.8%
fma-undefine97.8%
*-commutative97.8%
distribute-rgt-in97.8%
*-commutative97.8%
associate-*l*97.8%
metadata-eval97.8%
metadata-eval97.8%
Applied egg-rr97.8%
if 2.99999999999999979e136 < r Initial program 83.9%
associate--l-83.9%
associate-*l*62.4%
sqr-neg62.4%
associate-*l*83.9%
associate-/l*89.5%
fma-define89.5%
Simplified89.5%
Taylor expanded in r around inf 89.5%
associate-/l*89.4%
*-commutative89.4%
associate-*r/89.4%
associate-*l*99.8%
associate-*r*99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification78.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* r (* (* w w) (/ r (- 1.0 v))))) (t_1 (/ 2.0 (* r r))))
(if (or (<= v -2000.0) (not (<= v 235000000.0)))
(+ t_1 (- -1.5 (* (* v -0.25) 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 / (1.0 - v)));
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -2000.0) || !(v <= 235000000.0)) {
tmp = t_1 + (-1.5 - ((v * -0.25) * 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 / (1.0d0 - v)))
t_1 = 2.0d0 / (r * r)
if ((v <= (-2000.0d0)) .or. (.not. (v <= 235000000.0d0))) then
tmp = t_1 + ((-1.5d0) - ((v * (-0.25d0)) * 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 / (1.0 - v)));
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -2000.0) || !(v <= 235000000.0)) {
tmp = t_1 + (-1.5 - ((v * -0.25) * 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 / (1.0 - v))) t_1 = 2.0 / (r * r) tmp = 0 if (v <= -2000.0) or not (v <= 235000000.0): tmp = t_1 + (-1.5 - ((v * -0.25) * 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(1.0 - v)))) t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -2000.0) || !(v <= 235000000.0)) tmp = Float64(t_1 + Float64(-1.5 - Float64(Float64(v * -0.25) * 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 / (1.0 - v))); t_1 = 2.0 / (r * r); tmp = 0.0; if ((v <= -2000.0) || ~((v <= 235000000.0))) tmp = t_1 + (-1.5 - ((v * -0.25) * 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[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -2000.0], N[Not[LessEqual[v, 235000000.0]], $MachinePrecision]], N[(t$95$1 + N[(-1.5 - N[(N[(v * -0.25), $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}{1 - v}\right)\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2000 \lor \neg \left(v \leq 235000000\right):\\
\;\;\;\;t\_1 + \left(-1.5 - \left(v \cdot -0.25\right) \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \left(-1.5 - 0.375 \cdot t\_0\right)\\
\end{array}
\end{array}
if v < -2e3 or 2.35e8 < v Initial program 88.0%
Simplified91.0%
Taylor expanded in v around inf 90.4%
*-commutative90.4%
Simplified90.4%
if -2e3 < v < 2.35e8Initial program 87.4%
Simplified87.4%
Taylor expanded in v around 0 86.9%
Final simplification88.6%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (/ r (- 1.0 v))))
(if (<= r 2.55e-118)
(- (+ t_0 3.0) 4.5)
(if (<= r 52.0)
(+ t_0 (- -1.5 (* 0.375 (* r (* (* w w) t_1)))))
(-
3.0
(+ 4.5 (* (* 0.125 (+ 3.0 (* v -2.0))) (* (* r w) (* w t_1)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = r / (1.0 - v);
double tmp;
if (r <= 2.55e-118) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 52.0) {
tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * t_1))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_1))));
}
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 / (1.0d0 - v)
if (r <= 2.55d-118) then
tmp = (t_0 + 3.0d0) - 4.5d0
else if (r <= 52.0d0) then
tmp = t_0 + ((-1.5d0) - (0.375d0 * (r * ((w * w) * t_1))))
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * w) * (w * t_1))))
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 / (1.0 - v);
double tmp;
if (r <= 2.55e-118) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 52.0) {
tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * t_1))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_1))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = r / (1.0 - v) tmp = 0 if r <= 2.55e-118: tmp = (t_0 + 3.0) - 4.5 elif r <= 52.0: tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * t_1)))) else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_1)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(r / Float64(1.0 - v)) tmp = 0.0 if (r <= 2.55e-118) tmp = Float64(Float64(t_0 + 3.0) - 4.5); elseif (r <= 52.0) tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(r * Float64(Float64(w * w) * t_1))))); 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 * t_1))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = r / (1.0 - v); tmp = 0.0; if (r <= 2.55e-118) tmp = (t_0 + 3.0) - 4.5; elseif (r <= 52.0) tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * t_1)))); else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_1)))); 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[(1.0 - v), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 2.55e-118], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 52.0], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * t$95$1), $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 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := \frac{r}{1 - v}\\
\mathbf{if}\;r \leq 2.55 \cdot 10^{-118}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 52:\\
\;\;\;\;t\_0 + \left(-1.5 - 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot t\_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 t\_1\right)\right)\right)\\
\end{array}
\end{array}
if r < 2.54999999999999982e-118Initial program 85.6%
Simplified85.0%
Taylor expanded in r around 0 68.7%
if 2.54999999999999982e-118 < r < 52Initial program 94.4%
Simplified94.4%
Taylor expanded in v around 0 94.4%
if 52 < r Initial program 91.4%
associate--l-91.4%
associate-*l*80.0%
sqr-neg80.0%
associate-*l*91.4%
associate-/l*94.4%
fma-define94.4%
Simplified94.4%
Taylor expanded in r around inf 94.4%
associate-/l*94.3%
*-commutative94.3%
associate-*r/94.3%
associate-*l*99.9%
associate-*r*99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification78.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (/ r (- 1.0 v))))
(if (<= r 1e-116)
(- (+ t_0 3.0) 4.5)
(if (<= r 7.6)
(+ t_0 (- -1.5 (* 0.375 (* r (* (* w w) t_1)))))
(-
3.0
(+ 4.5 (* (* 0.125 (+ 3.0 (* v -2.0))) (* w (* r (* w t_1))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = r / (1.0 - v);
double tmp;
if (r <= 1e-116) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 7.6) {
tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * t_1))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * t_1)))));
}
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 / (1.0d0 - v)
if (r <= 1d-116) then
tmp = (t_0 + 3.0d0) - 4.5d0
else if (r <= 7.6d0) then
tmp = t_0 + ((-1.5d0) - (0.375d0 * (r * ((w * w) * t_1))))
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * (w * (r * (w * t_1)))))
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 / (1.0 - v);
double tmp;
if (r <= 1e-116) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 7.6) {
tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * t_1))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * t_1)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = r / (1.0 - v) tmp = 0 if r <= 1e-116: tmp = (t_0 + 3.0) - 4.5 elif r <= 7.6: tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * t_1)))) else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * t_1))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(r / Float64(1.0 - v)) tmp = 0.0 if (r <= 1e-116) tmp = Float64(Float64(t_0 + 3.0) - 4.5); elseif (r <= 7.6) tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(r * Float64(Float64(w * w) * t_1))))); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(w * Float64(r * Float64(w * t_1)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = r / (1.0 - v); tmp = 0.0; if (r <= 1e-116) tmp = (t_0 + 3.0) - 4.5; elseif (r <= 7.6) tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * t_1)))); else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * t_1))))); 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[(1.0 - v), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 1e-116], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 7.6], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * t$95$1), $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[(w * N[(r * N[(w * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := \frac{r}{1 - v}\\
\mathbf{if}\;r \leq 10^{-116}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 7.6:\\
\;\;\;\;t\_0 + \left(-1.5 - 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot t\_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \left(4.5 + \left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(w \cdot \left(r \cdot \left(w \cdot t\_1\right)\right)\right)\right)\\
\end{array}
\end{array}
if r < 9.9999999999999999e-117Initial program 85.6%
Simplified85.0%
Taylor expanded in r around 0 68.7%
if 9.9999999999999999e-117 < r < 7.5999999999999996Initial program 94.4%
Simplified94.4%
Taylor expanded in v around 0 94.4%
if 7.5999999999999996 < r Initial program 91.4%
associate--l-91.4%
associate-*l*80.0%
sqr-neg80.0%
associate-*l*91.4%
associate-/l*94.4%
fma-define94.4%
Simplified94.4%
Taylor expanded in r around inf 94.4%
associate-/l*94.3%
*-commutative94.3%
associate-*r/94.3%
*-commutative94.3%
associate-*l*99.9%
associate-*l*98.4%
Applied egg-rr98.4%
Final simplification78.0%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 1.45e-116)
(- (+ t_0 3.0) 4.5)
(if (<= r 15000000000000.0)
(+ t_0 (- -1.5 (* 0.375 (* r (* (* w w) (/ r (- 1.0 v)))))))
(+
3.0
(- (* (* 0.125 (+ 3.0 (* v -2.0))) (/ (* r (* r (* w w))) v)) 4.5))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 1.45e-116) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 15000000000000.0) {
tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * (r * (w * w))) / v)) - 4.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 <= 1.45d-116) then
tmp = (t_0 + 3.0d0) - 4.5d0
else if (r <= 15000000000000.0d0) then
tmp = t_0 + ((-1.5d0) - (0.375d0 * (r * ((w * w) * (r / (1.0d0 - v))))))
else
tmp = 3.0d0 + (((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * (r * (w * w))) / v)) - 4.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 <= 1.45e-116) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 15000000000000.0) {
tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * (r * (w * w))) / v)) - 4.5);
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 1.45e-116: tmp = (t_0 + 3.0) - 4.5 elif r <= 15000000000000.0: tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))) else: tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * (r * (w * w))) / v)) - 4.5) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 1.45e-116) tmp = Float64(Float64(t_0 + 3.0) - 4.5); elseif (r <= 15000000000000.0) tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(1.0 - v))))))); else tmp = Float64(3.0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(Float64(r * Float64(r * Float64(w * w))) / v)) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 1.45e-116) tmp = (t_0 + 3.0) - 4.5; elseif (r <= 15000000000000.0) tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))); else tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * (r * (w * w))) / v)) - 4.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, 1.45e-116], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 15000000000000.0], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 + N[(N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 1.45 \cdot 10^{-116}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 15000000000000:\\
\;\;\;\;t\_0 + \left(-1.5 - 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{1 - v}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v} - 4.5\right)\\
\end{array}
\end{array}
if r < 1.4499999999999999e-116Initial program 85.6%
Simplified85.0%
Taylor expanded in r around 0 68.7%
if 1.4499999999999999e-116 < r < 1.5e13Initial program 94.9%
Simplified94.9%
Taylor expanded in v around 0 94.9%
if 1.5e13 < r Initial program 91.1%
associate--l-91.1%
associate-*l*79.3%
sqr-neg79.3%
associate-*l*91.1%
associate-/l*94.2%
fma-define94.2%
Simplified94.2%
Taylor expanded in r around inf 94.2%
Taylor expanded in v around inf 76.8%
neg-mul-176.8%
Simplified76.8%
Final simplification72.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 1.24e-116)
(- (+ t_0 3.0) 4.5)
(if (<= r 4e+203)
(+ t_0 (- -1.5 (* 0.375 (* r (* (* w w) (/ r (- 1.0 v)))))))
(- 3.0 (+ 4.5 (* (* 0.125 (+ 3.0 (* v -2.0))) (* (* r w) (* r w)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 1.24e-116) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 4e+203) {
tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((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 <= 1.24d-116) then
tmp = (t_0 + 3.0d0) - 4.5d0
else if (r <= 4d+203) then
tmp = t_0 + ((-1.5d0) - (0.375d0 * (r * ((w * w) * (r / (1.0d0 - v))))))
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((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 <= 1.24e-116) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 4e+203) {
tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (r * w))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 1.24e-116: tmp = (t_0 + 3.0) - 4.5 elif r <= 4e+203: tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))) else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (r * w)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 1.24e-116) tmp = Float64(Float64(t_0 + 3.0) - 4.5); elseif (r <= 4e+203) tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(1.0 - v))))))); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * 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 <= 1.24e-116) tmp = (t_0 + 3.0) - 4.5; elseif (r <= 4e+203) tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))); else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((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, 1.24e-116], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 4e+203], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(1.0 - v), $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[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 1.24 \cdot 10^{-116}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 4 \cdot 10^{+203}:\\
\;\;\;\;t\_0 + \left(-1.5 - 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{1 - v}\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(r \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if r < 1.24000000000000004e-116Initial program 85.6%
Simplified85.0%
Taylor expanded in r around 0 68.7%
if 1.24000000000000004e-116 < r < 4e203Initial program 95.3%
Simplified98.2%
Taylor expanded in v around 0 80.3%
if 4e203 < r Initial program 81.3%
associate--l-81.3%
associate-*l*68.6%
sqr-neg68.6%
associate-*l*81.3%
associate-/l*81.3%
fma-define81.3%
Simplified81.3%
Taylor expanded in r around inf 81.3%
associate-/l*81.3%
*-commutative81.3%
associate-*r/81.3%
associate-*l*99.8%
associate-*r*99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in v around 0 74.6%
Final simplification72.0%
(FPCore (v w r) :precision binary64 (if (<= r 8.5) (- (+ 3.0 (/ (/ 2.0 r) r)) 4.5) (- 3.0 (+ 4.5 (* (* 0.125 (+ 3.0 (* v -2.0))) (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
double tmp;
if (r <= 8.5) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((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 <= 8.5d0) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * w) * (r * w))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 8.5) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (r * w))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 8.5: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (r * w)))) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 8.5) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(Float64(r * w) * Float64(r * w))))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 8.5) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (r * w)))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 8.5], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $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[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 8.5:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\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(r \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if r < 8.5Initial program 86.4%
Simplified85.9%
Taylor expanded in r around 0 70.6%
associate-/r*70.6%
div-inv70.5%
Applied egg-rr70.5%
un-div-inv70.6%
Applied egg-rr70.6%
if 8.5 < r Initial program 91.4%
associate--l-91.4%
associate-*l*80.0%
sqr-neg80.0%
associate-*l*91.4%
associate-/l*94.4%
fma-define94.4%
Simplified94.4%
Taylor expanded in r around inf 94.4%
associate-/l*94.3%
*-commutative94.3%
associate-*r/94.3%
associate-*l*99.9%
associate-*r*99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in v around 0 69.5%
Final simplification70.3%
(FPCore (v w r) :precision binary64 (if (<= r 116.0) (- (+ 3.0 (/ (/ 2.0 r) r)) 4.5) (- 3.0 (+ 4.5 (* (* 0.125 (+ 3.0 (* v -2.0))) (* w (* r (* r w))))))))
double code(double v, double w, double r) {
double tmp;
if (r <= 116.0) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (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 <= 116.0d0) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * (w * (r * (r * w)))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 116.0) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (r * w)))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 116.0: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (r * w))))) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 116.0) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(w * Float64(r * Float64(r * w)))))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 116.0) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (r * w))))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 116.0], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(3.0 - N[(4.5 + N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w * N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 116:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;3 - \left(4.5 + \left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(w \cdot \left(r \cdot \left(r \cdot w\right)\right)\right)\right)\\
\end{array}
\end{array}
if r < 116Initial program 86.4%
Simplified85.9%
Taylor expanded in r around 0 70.6%
associate-/r*70.6%
div-inv70.5%
Applied egg-rr70.5%
un-div-inv70.6%
Applied egg-rr70.6%
if 116 < r Initial program 91.4%
associate--l-91.4%
associate-*l*80.0%
sqr-neg80.0%
associate-*l*91.4%
associate-/l*94.4%
fma-define94.4%
Simplified94.4%
Taylor expanded in r around inf 94.4%
associate-/l*94.3%
*-commutative94.3%
associate-*r/94.3%
*-commutative94.3%
associate-*l*99.9%
associate-*l*98.4%
Applied egg-rr98.4%
Taylor expanded in v around 0 68.2%
Final simplification70.0%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ (/ 2.0 r) r)) 4.5))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - 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)) - 4.5d0
end function
public static double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - 4.5;
}
def code(v, w, r): return (3.0 + ((2.0 / r) / r)) - 4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5) end
function tmp = code(v, w, r) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5
\end{array}
Initial program 87.7%
Simplified84.0%
Taylor expanded in r around 0 61.8%
associate-/r*61.8%
div-inv61.8%
Applied egg-rr61.8%
un-div-inv61.8%
Applied egg-rr61.8%
(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 87.7%
Simplified84.0%
Taylor expanded in r around 0 61.8%
Final simplification61.8%
(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 87.7%
Simplified84.0%
Taylor expanded in r around 0 61.8%
Taylor expanded in r around inf 14.8%
herbie shell --seed 2024137
(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))