
(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 8 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 (/ (+ (* v -0.25) 0.375) (/ (+ v -1.0) (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + (((v * -0.25) + 0.375) / ((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) + (((v * (-0.25d0)) + 0.375d0) / ((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 + (((v * -0.25) + 0.375) / ((v + -1.0) / ((r * w) * (r * w)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 + (((v * -0.25) + 0.375) / ((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(Float64(v * -0.25) + 0.375) / 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 + (((v * -0.25) + 0.375) / ((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[(N[(v * -0.25), $MachinePrecision] + 0.375), $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{v \cdot -0.25 + 0.375}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right)
\end{array}
Initial program 85.1%
Simplified87.7%
fma-undefine87.7%
*-commutative87.7%
+-commutative87.7%
associate-*r/87.7%
*-commutative87.7%
associate-/l*87.7%
clear-num87.7%
un-div-inv87.7%
+-commutative87.7%
distribute-rgt-in87.7%
*-commutative87.7%
associate-*l*87.7%
metadata-eval87.7%
metadata-eval87.7%
associate-*r*81.1%
pow281.1%
pow281.1%
pow-prod-down99.8%
Applied egg-rr99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -0.0001) (not (<= v 9e-24)))
(+ t_0 (+ -1.5 (* (* v -0.25) (* r (* (* w w) (/ r (+ v -1.0)))))))
(+ t_0 (- -1.5 (* 0.375 (* 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 ((v <= -0.0001) || !(v <= 9e-24)) {
tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = t_0 + (-1.5 - (0.375 * (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 ((v <= (-0.0001d0)) .or. (.not. (v <= 9d-24))) then
tmp = t_0 + ((-1.5d0) + ((v * (-0.25d0)) * (r * ((w * w) * (r / (v + (-1.0d0)))))))
else
tmp = t_0 + ((-1.5d0) - (0.375d0 * (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 ((v <= -0.0001) || !(v <= 9e-24)) {
tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = t_0 + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -0.0001) or not (v <= 9e-24): tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / (v + -1.0)))))) else: tmp = t_0 + (-1.5 - (0.375 * (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 ((v <= -0.0001) || !(v <= 9e-24)) tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(v * -0.25) * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(r * Float64(Float64(w * 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 ((v <= -0.0001) || ~((v <= 9e-24))) tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / (v + -1.0)))))); else tmp = t_0 + (-1.5 - (0.375 * (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[Or[LessEqual[v, -0.0001], N[Not[LessEqual[v, 9e-24]], $MachinePrecision]], N[(t$95$0 + N[(-1.5 + N[(N[(v * -0.25), $MachinePrecision] * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -0.0001 \lor \neg \left(v \leq 9 \cdot 10^{-24}\right):\\
\;\;\;\;t\_0 + \left(-1.5 + \left(v \cdot -0.25\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;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)\\
\end{array}
\end{array}
if v < -1.00000000000000005e-4 or 8.9999999999999995e-24 < v Initial program 86.4%
Simplified91.2%
Taylor expanded in v around inf 90.4%
*-commutative90.4%
Simplified90.4%
if -1.00000000000000005e-4 < v < 8.9999999999999995e-24Initial program 83.7%
Simplified83.7%
Taylor expanded in v around 0 83.7%
Final simplification87.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ r (+ v -1.0))))
(if (<= r 1.95e-103)
(- (+ 3.0 (/ (/ 2.0 r) r)) 4.5)
(if (<= r 35000.0)
(+ (/ 2.0 (* r r)) (+ -1.5 (* (* v -0.25) (* r (* (* w w) t_0)))))
(+
3.0
(- (* (* 0.125 (+ 3.0 (* v -2.0))) (* (* r w) (* w t_0))) 4.5))))))
double code(double v, double w, double r) {
double t_0 = r / (v + -1.0);
double tmp;
if (r <= 1.95e-103) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 35000.0) {
tmp = (2.0 / (r * r)) + (-1.5 + ((v * -0.25) * (r * ((w * w) * t_0))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_0))) - 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 = r / (v + (-1.0d0))
if (r <= 1.95d-103) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else if (r <= 35000.0d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) + ((v * (-0.25d0)) * (r * ((w * w) * t_0))))
else
tmp = 3.0d0 + (((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * w) * (w * t_0))) - 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = r / (v + -1.0);
double tmp;
if (r <= 1.95e-103) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 35000.0) {
tmp = (2.0 / (r * r)) + (-1.5 + ((v * -0.25) * (r * ((w * w) * t_0))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_0))) - 4.5);
}
return tmp;
}
def code(v, w, r): t_0 = r / (v + -1.0) tmp = 0 if r <= 1.95e-103: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 elif r <= 35000.0: tmp = (2.0 / (r * r)) + (-1.5 + ((v * -0.25) * (r * ((w * w) * t_0)))) else: tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_0))) - 4.5) return tmp
function code(v, w, r) t_0 = Float64(r / Float64(v + -1.0)) tmp = 0.0 if (r <= 1.95e-103) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); elseif (r <= 35000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(Float64(v * -0.25) * Float64(r * Float64(Float64(w * w) * t_0))))); else tmp = Float64(3.0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(Float64(r * w) * Float64(w * t_0))) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = r / (v + -1.0); tmp = 0.0; if (r <= 1.95e-103) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; elseif (r <= 35000.0) tmp = (2.0 / (r * r)) + (-1.5 + ((v * -0.25) * (r * ((w * w) * t_0)))); else tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * t_0))) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 1.95e-103], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 35000.0], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(N[(v * -0.25), $MachinePrecision] * N[(r * N[(N[(w * w), $MachinePrecision] * t$95$0), $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 * w), $MachinePrecision] * N[(w * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{r}{v + -1}\\
\mathbf{if}\;r \leq 1.95 \cdot 10^{-103}:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\mathbf{elif}\;r \leq 35000:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + \left(v \cdot -0.25\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot t\_0\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \left(w \cdot t\_0\right)\right) - 4.5\right)\\
\end{array}
\end{array}
if r < 1.9500000000000001e-103Initial program 82.4%
Simplified76.9%
Taylor expanded in r around 0 69.8%
associate-/r*69.8%
div-inv69.7%
Applied egg-rr69.7%
associate-*r/69.8%
*-rgt-identity69.8%
Simplified69.8%
if 1.9500000000000001e-103 < r < 35000Initial program 92.7%
Simplified96.2%
Taylor expanded in v around inf 87.8%
*-commutative87.8%
Simplified87.8%
if 35000 < r Initial program 88.9%
Simplified93.2%
Taylor expanded in r around inf 93.2%
associate-/l*93.1%
*-commutative93.1%
associate-*r/93.2%
associate-*l*99.7%
associate-*r*99.7%
Applied egg-rr99.7%
Final simplification79.4%
(FPCore (v w r)
:precision binary64
(if (<= r 3.2e-103)
(- (+ 3.0 (/ (/ 2.0 r) r)) 4.5)
(if (<= r 2050000.0)
(+
(/ 2.0 (* r r))
(- -1.5 (* (* v -0.25) (* r (* (* w w) (/ r (- 1.0 v)))))))
(+
3.0
(-
(* (* 0.125 (+ 3.0 (* v -2.0))) (* w (* r (* w (/ r (+ v -1.0))))))
4.5)))))
double code(double v, double w, double r) {
double tmp;
if (r <= 3.2e-103) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 2050000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - ((v * -0.25) * (r * ((w * w) * (r / (1.0 - v))))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * (r / (v + -1.0)))))) - 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) :: tmp
if (r <= 3.2d-103) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else if (r <= 2050000.0d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) - ((v * (-0.25d0)) * (r * ((w * w) * (r / (1.0d0 - v))))))
else
tmp = 3.0d0 + (((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * (w * (r * (w * (r / (v + (-1.0d0))))))) - 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 3.2e-103) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 2050000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - ((v * -0.25) * (r * ((w * w) * (r / (1.0 - v))))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * (r / (v + -1.0)))))) - 4.5);
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 3.2e-103: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 elif r <= 2050000.0: tmp = (2.0 / (r * r)) + (-1.5 - ((v * -0.25) * (r * ((w * w) * (r / (1.0 - v)))))) else: tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * (r / (v + -1.0)))))) - 4.5) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 3.2e-103) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); elseif (r <= 2050000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(v * -0.25) * 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(w * Float64(r * Float64(w * Float64(r / Float64(v + -1.0)))))) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 3.2e-103) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; elseif (r <= 2050000.0) tmp = (2.0 / (r * r)) + (-1.5 - ((v * -0.25) * (r * ((w * w) * (r / (1.0 - v)))))); else tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * (r / (v + -1.0)))))) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 3.2e-103], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 2050000.0], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(v * -0.25), $MachinePrecision] * 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[(w * N[(r * N[(w * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 3.2 \cdot 10^{-103}:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\mathbf{elif}\;r \leq 2050000:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - \left(v \cdot -0.25\right) \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 \left(w \cdot \left(r \cdot \left(w \cdot \frac{r}{v + -1}\right)\right)\right) - 4.5\right)\\
\end{array}
\end{array}
if r < 3.19999999999999976e-103Initial program 82.4%
Simplified76.9%
Taylor expanded in r around 0 69.8%
associate-/r*69.8%
div-inv69.7%
Applied egg-rr69.7%
associate-*r/69.8%
*-rgt-identity69.8%
Simplified69.8%
if 3.19999999999999976e-103 < r < 2.05e6Initial program 92.7%
Simplified96.2%
Taylor expanded in v around inf 87.8%
*-commutative87.8%
Simplified87.8%
if 2.05e6 < r Initial program 88.9%
Simplified93.2%
Taylor expanded in r around inf 93.2%
associate-/l*93.1%
*-commutative93.1%
associate-*r/93.2%
*-commutative93.2%
associate-*l*99.7%
associate-*l*98.3%
Applied egg-rr98.3%
Final simplification79.0%
(FPCore (v w r)
:precision binary64
(if (<= r 9e-104)
(- (+ 3.0 (/ (/ 2.0 r) r)) 4.5)
(if (<= r 2e+92)
(+ (/ 2.0 (* r r)) (- -1.5 (* 0.375 (* r (* (* w w) (/ r (- 1.0 v)))))))
(- 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 <= 9e-104) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 2e+92) {
tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} 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 <= 9d-104) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else if (r <= 2d+92) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) - (0.375d0 * (r * ((w * w) * (r / (1.0d0 - v))))))
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 <= 9e-104) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 2e+92) {
tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} 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 <= 9e-104: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 elif r <= 2e+92: tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))) 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 <= 9e-104) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); elseif (r <= 2e+92) tmp = Float64(Float64(2.0 / Float64(r * r)) + 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(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 <= 9e-104) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; elseif (r <= 2e+92) tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))); 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, 9e-104], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 2e+92], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + 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[(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 9 \cdot 10^{-104}:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\mathbf{elif}\;r \leq 2 \cdot 10^{+92}:\\
\;\;\;\;\frac{2}{r \cdot r} + \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(\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 < 8.9999999999999995e-104Initial program 82.4%
Simplified76.9%
Taylor expanded in r around 0 69.8%
associate-/r*69.8%
div-inv69.7%
Applied egg-rr69.7%
associate-*r/69.8%
*-rgt-identity69.8%
Simplified69.8%
if 8.9999999999999995e-104 < r < 2.0000000000000001e92Initial program 93.8%
Simplified97.8%
Taylor expanded in v around 0 85.5%
if 2.0000000000000001e92 < r Initial program 86.0%
Simplified90.2%
Taylor expanded in r around inf 90.2%
associate-/l*90.2%
*-commutative90.2%
associate-*r/90.2%
associate-*l*99.7%
associate-*r*99.6%
Applied egg-rr99.6%
Taylor expanded in v around 0 73.3%
Final simplification73.4%
(FPCore (v w r) :precision binary64 (if (<= r 280000.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 <= 280000.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 <= 280000.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 <= 280000.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 <= 280000.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 <= 280000.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 <= 280000.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, 280000.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 280000:\\
\;\;\;\;\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 < 2.8e5Initial program 83.9%
Simplified79.7%
Taylor expanded in r around 0 70.6%
if 2.8e5 < r Initial program 88.9%
Simplified93.2%
Taylor expanded in r around inf 93.2%
associate-/l*93.1%
*-commutative93.1%
associate-*r/93.2%
associate-*l*99.7%
associate-*r*99.7%
Applied egg-rr99.7%
Taylor expanded in v around 0 74.0%
Final simplification71.4%
(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 85.1%
Simplified79.8%
Taylor expanded in r around 0 59.8%
Final simplification59.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 85.1%
Simplified79.8%
Taylor expanded in r around 0 59.8%
Taylor expanded in r around inf 12.6%
herbie shell --seed 2024188
(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))