
(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 9 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
(let* ((t_0 (/ (/ 2.0 r) r)))
(if (or (<= v -8.5e+159) (not (<= v 2.2e-41)))
(+ t_0 (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(+
t_0
(- -1.5 (* (/ w (/ (- 1.0 v) r)) (* r (* w (+ 0.375 (* v -0.25))))))))))
double code(double v, double w, double r) {
double t_0 = (2.0 / r) / r;
double tmp;
if ((v <= -8.5e+159) || !(v <= 2.2e-41)) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (r * (w * (0.375 + (v * -0.25))))));
}
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 <= (-8.5d+159)) .or. (.not. (v <= 2.2d-41))) then
tmp = t_0 + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
else
tmp = t_0 + ((-1.5d0) - ((w / ((1.0d0 - v) / r)) * (r * (w * (0.375d0 + (v * (-0.25d0)))))))
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 <= -8.5e+159) || !(v <= 2.2e-41)) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (r * (w * (0.375 + (v * -0.25))))));
}
return tmp;
}
def code(v, w, r): t_0 = (2.0 / r) / r tmp = 0 if (v <= -8.5e+159) or not (v <= 2.2e-41): tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (r * (w * (0.375 + (v * -0.25)))))) return tmp
function code(v, w, r) t_0 = Float64(Float64(2.0 / r) / r) tmp = 0.0 if ((v <= -8.5e+159) || !(v <= 2.2e-41)) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(w / Float64(Float64(1.0 - v) / r)) * Float64(r * Float64(w * Float64(0.375 + Float64(v * -0.25))))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (2.0 / r) / r; tmp = 0.0; if ((v <= -8.5e+159) || ~((v <= 2.2e-41))) tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (r * (w * (0.375 + (v * -0.25)))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]}, If[Or[LessEqual[v, -8.5e+159], N[Not[LessEqual[v, 2.2e-41]], $MachinePrecision]], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(w / N[(N[(1.0 - v), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] * N[(r * N[(w * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{2}{r}}{r}\\
\mathbf{if}\;v \leq -8.5 \cdot 10^{+159} \lor \neg \left(v \leq 2.2 \cdot 10^{-41}\right):\\
\;\;\;\;t_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - \frac{w}{\frac{1 - v}{r}} \cdot \left(r \cdot \left(w \cdot \left(0.375 + v \cdot -0.25\right)\right)\right)\right)\\
\end{array}
\end{array}
if v < -8.50000000000000076e159 or 2.2e-41 < v Initial program 78.7%
Simplified96.9%
Taylor expanded in v around inf 81.2%
*-commutative81.2%
*-commutative81.2%
unpow281.2%
unpow281.2%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
if -8.50000000000000076e159 < v < 2.2e-41Initial program 84.5%
Simplified97.2%
clear-num97.2%
inv-pow97.2%
associate-*r*99.7%
pow299.7%
*-commutative99.7%
Applied egg-rr99.7%
unpow-199.7%
*-commutative99.7%
Simplified99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
associate-/l/99.7%
associate-/r/99.7%
clear-num99.7%
*-commutative99.7%
associate-/l*99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (+ -1.5 (/ -1.0 (/ (/ (- 1.0 v) (pow (* r w) 2.0)) (fma v -0.25 0.375))))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 + (-1.0 / (((1.0 - v) / pow((r * w), 2.0)) / fma(v, -0.25, 0.375))));
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 + Float64(-1.0 / Float64(Float64(Float64(1.0 - v) / (Float64(r * w) ^ 2.0)) / fma(v, -0.25, 0.375))))) end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 + N[(-1.0 / N[(N[(N[(1.0 - v), $MachinePrecision] / N[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(v * -0.25 + 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 + \frac{-1}{\frac{\frac{1 - v}{{\left(r \cdot w\right)}^{2}}}{\mathsf{fma}\left(v, -0.25, 0.375\right)}}\right)
\end{array}
Initial program 82.1%
Simplified97.1%
clear-num97.1%
inv-pow97.1%
associate-*r*99.7%
pow299.7%
*-commutative99.7%
Applied egg-rr99.7%
unpow-199.7%
*-commutative99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ (/ 2.0 r) r)))
(if (<= (* w w) 4e+231)
(+ t_0 (- -1.5 (/ (fma v -0.25 0.375) (/ (- 1.0 v) (* r (* w (* r w)))))))
(+ t_0 (- -1.5 (* 0.375 (* (* r w) (* r w))))))))
double code(double v, double w, double r) {
double t_0 = (2.0 / r) / r;
double tmp;
if ((w * w) <= 4e+231) {
tmp = t_0 + (-1.5 - (fma(v, -0.25, 0.375) / ((1.0 - v) / (r * (w * (r * w))))));
} else {
tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w))));
}
return tmp;
}
function code(v, w, r) t_0 = Float64(Float64(2.0 / r) / r) tmp = 0.0 if (Float64(w * w) <= 4e+231) tmp = Float64(t_0 + Float64(-1.5 - Float64(fma(v, -0.25, 0.375) / Float64(Float64(1.0 - v) / Float64(r * Float64(w * Float64(r * w))))))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * w) * Float64(r * w))))); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]}, If[LessEqual[N[(w * w), $MachinePrecision], 4e+231], N[(t$95$0 + N[(-1.5 - N[(N[(v * -0.25 + 0.375), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] / N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{2}{r}}{r}\\
\mathbf{if}\;w \cdot w \leq 4 \cdot 10^{+231}:\\
\;\;\;\;t_0 + \left(-1.5 - \frac{\mathsf{fma}\left(v, -0.25, 0.375\right)}{\frac{1 - v}{r \cdot \left(w \cdot \left(r \cdot w\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 w w) < 4.0000000000000002e231Initial program 91.0%
Simplified99.7%
if 4.0000000000000002e231 < (*.f64 w w) Initial program 62.2%
Simplified91.3%
Taylor expanded in v around 0 63.5%
*-commutative63.5%
*-commutative63.5%
unpow263.5%
unpow263.5%
swap-sqr98.9%
unpow298.9%
*-commutative98.9%
Simplified98.9%
unpow298.9%
Applied egg-rr98.9%
Final simplification99.5%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (+ -1.5 (/ -1.0 (/ (/ (/ (- 1.0 v) (* r w)) (* r w)) (fma v -0.25 0.375))))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 + (-1.0 / ((((1.0 - v) / (r * w)) / (r * w)) / fma(v, -0.25, 0.375))));
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 + Float64(-1.0 / Float64(Float64(Float64(Float64(1.0 - v) / Float64(r * w)) / Float64(r * w)) / fma(v, -0.25, 0.375))))) end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 + N[(-1.0 / N[(N[(N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(v * -0.25 + 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 + \frac{-1}{\frac{\frac{\frac{1 - v}{r \cdot w}}{r \cdot w}}{\mathsf{fma}\left(v, -0.25, 0.375\right)}}\right)
\end{array}
Initial program 82.1%
Simplified97.1%
clear-num97.1%
inv-pow97.1%
associate-*r*99.7%
pow299.7%
*-commutative99.7%
Applied egg-rr99.7%
unpow-199.7%
*-commutative99.7%
Simplified99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.8%
Applied egg-rr99.8%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ (/ 2.0 r) r)))
(if (<=
(+
(+ 3.0 (/ 2.0 (* r r)))
(/ (* (* r (* r (* w w))) (* 0.125 (- (* 2.0 v) 3.0))) (- 1.0 v)))
(- INFINITY))
(+ t_0 (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(+
t_0
(-
-1.5
(*
(/ w (/ (- 1.0 v) r))
(+ (* (* r w) (* v -0.25)) (* w (* r 0.375)))))))))
double code(double v, double w, double r) {
double t_0 = (2.0 / r) / r;
double tmp;
if (((3.0 + (2.0 / (r * r))) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= -((double) INFINITY)) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (((r * w) * (v * -0.25)) + (w * (r * 0.375)))));
}
return tmp;
}
public static double code(double v, double w, double r) {
double t_0 = (2.0 / r) / r;
double tmp;
if (((3.0 + (2.0 / (r * r))) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= -Double.POSITIVE_INFINITY) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (((r * w) * (v * -0.25)) + (w * (r * 0.375)))));
}
return tmp;
}
def code(v, w, r): t_0 = (2.0 / r) / r tmp = 0 if ((3.0 + (2.0 / (r * r))) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= -math.inf: tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (((r * w) * (v * -0.25)) + (w * (r * 0.375))))) return tmp
function code(v, w, r) t_0 = Float64(Float64(2.0 / r) / r) tmp = 0.0 if (Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(Float64(r * Float64(r * Float64(w * w))) * Float64(0.125 * Float64(Float64(2.0 * v) - 3.0))) / Float64(1.0 - v))) <= Float64(-Inf)) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(w / Float64(Float64(1.0 - v) / r)) * Float64(Float64(Float64(r * w) * Float64(v * -0.25)) + Float64(w * Float64(r * 0.375)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (2.0 / r) / r; tmp = 0.0; if (((3.0 + (2.0 / (r * r))) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= -Inf) tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (((r * w) * (v * -0.25)) + (w * (r * 0.375))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]}, If[LessEqual[N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.125 * N[(N[(2.0 * v), $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(w / N[(N[(1.0 - v), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(r * w), $MachinePrecision] * N[(v * -0.25), $MachinePrecision]), $MachinePrecision] + N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{2}{r}}{r}\\
\mathbf{if}\;\left(3 + \frac{2}{r \cdot r}\right) + \frac{\left(r \cdot \left(r \cdot \left(w \cdot w\right)\right)\right) \cdot \left(0.125 \cdot \left(2 \cdot v - 3\right)\right)}{1 - v} \leq -\infty:\\
\;\;\;\;t_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - \frac{w}{\frac{1 - v}{r}} \cdot \left(\left(r \cdot w\right) \cdot \left(v \cdot -0.25\right) + w \cdot \left(r \cdot 0.375\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 3 (/.f64 2 (*.f64 r r))) (/.f64 (*.f64 (*.f64 1/8 (-.f64 3 (*.f64 2 v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 1 v))) < -inf.0Initial program 82.2%
Simplified96.1%
Taylor expanded in v around inf 87.2%
*-commutative87.2%
*-commutative87.2%
unpow287.2%
unpow287.2%
swap-sqr98.8%
unpow298.8%
*-commutative98.8%
Simplified98.8%
unpow298.8%
Applied egg-rr98.8%
if -inf.0 < (-.f64 (+.f64 3 (/.f64 2 (*.f64 r r))) (/.f64 (*.f64 (*.f64 1/8 (-.f64 3 (*.f64 2 v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 1 v))) Initial program 82.1%
Simplified97.5%
clear-num97.5%
inv-pow97.5%
associate-*r*99.7%
pow299.7%
*-commutative99.7%
Applied egg-rr99.7%
unpow-199.7%
*-commutative99.7%
Simplified99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
associate-/l/99.1%
associate-/r/99.1%
clear-num99.1%
*-commutative99.1%
associate-/l*99.2%
*-commutative99.2%
Applied egg-rr99.2%
fma-udef99.2%
distribute-lft-in99.2%
*-commutative99.2%
*-commutative99.2%
associate-*l*99.2%
Applied egg-rr99.2%
Final simplification99.1%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ (/ 2.0 r) r)))
(if (or (<= v -10000000000.0) (not (<= v 2.2e-41)))
(+ t_0 (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(+ t_0 (- -1.5 (* (/ w (/ (- 1.0 v) r)) (* w (* r 0.375))))))))
double code(double v, double w, double r) {
double t_0 = (2.0 / r) / r;
double tmp;
if ((v <= -10000000000.0) || !(v <= 2.2e-41)) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (w * (r * 0.375))));
}
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 <= (-10000000000.0d0)) .or. (.not. (v <= 2.2d-41))) then
tmp = t_0 + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
else
tmp = t_0 + ((-1.5d0) - ((w / ((1.0d0 - v) / r)) * (w * (r * 0.375d0))))
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 <= -10000000000.0) || !(v <= 2.2e-41)) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (w * (r * 0.375))));
}
return tmp;
}
def code(v, w, r): t_0 = (2.0 / r) / r tmp = 0 if (v <= -10000000000.0) or not (v <= 2.2e-41): tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (w * (r * 0.375)))) return tmp
function code(v, w, r) t_0 = Float64(Float64(2.0 / r) / r) tmp = 0.0 if ((v <= -10000000000.0) || !(v <= 2.2e-41)) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(w / Float64(Float64(1.0 - v) / r)) * Float64(w * Float64(r * 0.375))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (2.0 / r) / r; tmp = 0.0; if ((v <= -10000000000.0) || ~((v <= 2.2e-41))) tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = t_0 + (-1.5 - ((w / ((1.0 - v) / r)) * (w * (r * 0.375)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]}, If[Or[LessEqual[v, -10000000000.0], N[Not[LessEqual[v, 2.2e-41]], $MachinePrecision]], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(w / N[(N[(1.0 - v), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{2}{r}}{r}\\
\mathbf{if}\;v \leq -10000000000 \lor \neg \left(v \leq 2.2 \cdot 10^{-41}\right):\\
\;\;\;\;t_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - \frac{w}{\frac{1 - v}{r}} \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\\
\end{array}
\end{array}
if v < -1e10 or 2.2e-41 < v Initial program 79.9%
Simplified97.1%
Taylor expanded in v around inf 81.4%
*-commutative81.4%
*-commutative81.4%
unpow281.4%
unpow281.4%
swap-sqr99.7%
unpow299.7%
*-commutative99.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
if -1e10 < v < 2.2e-41Initial program 85.0%
Simplified97.2%
clear-num97.1%
inv-pow97.1%
associate-*r*99.7%
pow299.7%
*-commutative99.7%
Applied egg-rr99.7%
unpow-199.7%
*-commutative99.7%
Simplified99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.7%
Applied egg-rr99.7%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
associate-/l/99.8%
associate-/r/99.8%
clear-num99.8%
*-commutative99.8%
associate-/l*99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ (/ 2.0 r) r)) (t_1 (* (* r w) (* r w))))
(if (<= v -64000000000.0)
(+ t_0 (- -1.5 (* t_1 0.25)))
(if (<= v 2.4e+43)
(+ t_0 (- -1.5 (* 0.375 t_1)))
(+ (/ 1.0 (* r (/ r 2.0))) (- -1.5 (* 0.25 (* r (* w (* r w))))))))))
double code(double v, double w, double r) {
double t_0 = (2.0 / r) / r;
double t_1 = (r * w) * (r * w);
double tmp;
if (v <= -64000000000.0) {
tmp = t_0 + (-1.5 - (t_1 * 0.25));
} else if (v <= 2.4e+43) {
tmp = t_0 + (-1.5 - (0.375 * t_1));
} else {
tmp = (1.0 / (r * (r / 2.0))) + (-1.5 - (0.25 * (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) :: t_1
real(8) :: tmp
t_0 = (2.0d0 / r) / r
t_1 = (r * w) * (r * w)
if (v <= (-64000000000.0d0)) then
tmp = t_0 + ((-1.5d0) - (t_1 * 0.25d0))
else if (v <= 2.4d+43) then
tmp = t_0 + ((-1.5d0) - (0.375d0 * t_1))
else
tmp = (1.0d0 / (r * (r / 2.0d0))) + ((-1.5d0) - (0.25d0 * (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 t_1 = (r * w) * (r * w);
double tmp;
if (v <= -64000000000.0) {
tmp = t_0 + (-1.5 - (t_1 * 0.25));
} else if (v <= 2.4e+43) {
tmp = t_0 + (-1.5 - (0.375 * t_1));
} else {
tmp = (1.0 / (r * (r / 2.0))) + (-1.5 - (0.25 * (r * (w * (r * w)))));
}
return tmp;
}
def code(v, w, r): t_0 = (2.0 / r) / r t_1 = (r * w) * (r * w) tmp = 0 if v <= -64000000000.0: tmp = t_0 + (-1.5 - (t_1 * 0.25)) elif v <= 2.4e+43: tmp = t_0 + (-1.5 - (0.375 * t_1)) else: tmp = (1.0 / (r * (r / 2.0))) + (-1.5 - (0.25 * (r * (w * (r * w))))) return tmp
function code(v, w, r) t_0 = Float64(Float64(2.0 / r) / r) t_1 = Float64(Float64(r * w) * Float64(r * w)) tmp = 0.0 if (v <= -64000000000.0) tmp = Float64(t_0 + Float64(-1.5 - Float64(t_1 * 0.25))); elseif (v <= 2.4e+43) tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * t_1))); else tmp = Float64(Float64(1.0 / Float64(r * Float64(r / 2.0))) + Float64(-1.5 - Float64(0.25 * Float64(r * Float64(w * Float64(r * w)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (2.0 / r) / r; t_1 = (r * w) * (r * w); tmp = 0.0; if (v <= -64000000000.0) tmp = t_0 + (-1.5 - (t_1 * 0.25)); elseif (v <= 2.4e+43) tmp = t_0 + (-1.5 - (0.375 * t_1)); else tmp = (1.0 / (r * (r / 2.0))) + (-1.5 - (0.25 * (r * (w * (r * w))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]}, Block[{t$95$1 = N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -64000000000.0], N[(t$95$0 + N[(-1.5 - N[(t$95$1 * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 2.4e+43], N[(t$95$0 + N[(-1.5 - N[(0.375 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(r * N[(r / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(0.25 * N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{2}{r}}{r}\\
t_1 := \left(r \cdot w\right) \cdot \left(r \cdot w\right)\\
\mathbf{if}\;v \leq -64000000000:\\
\;\;\;\;t_0 + \left(-1.5 - t_1 \cdot 0.25\right)\\
\mathbf{elif}\;v \leq 2.4 \cdot 10^{+43}:\\
\;\;\;\;t_0 + \left(-1.5 - 0.375 \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{r \cdot \frac{r}{2}} + \left(-1.5 - 0.25 \cdot \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right)\right)\\
\end{array}
\end{array}
if v < -6.4e10Initial program 76.5%
Simplified97.3%
Taylor expanded in v around inf 77.0%
*-commutative77.0%
*-commutative77.0%
unpow277.0%
unpow277.0%
swap-sqr99.6%
unpow299.6%
*-commutative99.6%
Simplified99.6%
unpow299.6%
Applied egg-rr99.6%
if -6.4e10 < v < 2.40000000000000023e43Initial program 84.3%
Simplified96.1%
Taylor expanded in v around 0 78.1%
*-commutative78.1%
*-commutative78.1%
unpow278.1%
unpow278.1%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow289.0%
Applied egg-rr99.8%
if 2.40000000000000023e43 < v Initial program 85.4%
Simplified99.7%
Taylor expanded in v around inf 89.1%
*-commutative89.1%
*-commutative89.1%
unpow289.1%
unpow289.1%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
*-commutative99.8%
associate-*r*99.7%
Applied egg-rr99.7%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/r/99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* (* r w) (* r w))) (t_1 (/ (/ 2.0 r) r)))
(if (or (<= v -64000000000.0) (not (<= v 2.2e-41)))
(+ t_1 (- -1.5 (* t_0 0.25)))
(+ t_1 (- -1.5 (* 0.375 t_0))))))
double code(double v, double w, double r) {
double t_0 = (r * w) * (r * w);
double t_1 = (2.0 / r) / r;
double tmp;
if ((v <= -64000000000.0) || !(v <= 2.2e-41)) {
tmp = t_1 + (-1.5 - (t_0 * 0.25));
} 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) * (r * w)
t_1 = (2.0d0 / r) / r
if ((v <= (-64000000000.0d0)) .or. (.not. (v <= 2.2d-41))) then
tmp = t_1 + ((-1.5d0) - (t_0 * 0.25d0))
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) * (r * w);
double t_1 = (2.0 / r) / r;
double tmp;
if ((v <= -64000000000.0) || !(v <= 2.2e-41)) {
tmp = t_1 + (-1.5 - (t_0 * 0.25));
} else {
tmp = t_1 + (-1.5 - (0.375 * t_0));
}
return tmp;
}
def code(v, w, r): t_0 = (r * w) * (r * w) t_1 = (2.0 / r) / r tmp = 0 if (v <= -64000000000.0) or not (v <= 2.2e-41): tmp = t_1 + (-1.5 - (t_0 * 0.25)) else: tmp = t_1 + (-1.5 - (0.375 * t_0)) return tmp
function code(v, w, r) t_0 = Float64(Float64(r * w) * Float64(r * w)) t_1 = Float64(Float64(2.0 / r) / r) tmp = 0.0 if ((v <= -64000000000.0) || !(v <= 2.2e-41)) tmp = Float64(t_1 + Float64(-1.5 - Float64(t_0 * 0.25))); 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) * (r * w); t_1 = (2.0 / r) / r; tmp = 0.0; if ((v <= -64000000000.0) || ~((v <= 2.2e-41))) tmp = t_1 + (-1.5 - (t_0 * 0.25)); else tmp = t_1 + (-1.5 - (0.375 * t_0)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]}, If[Or[LessEqual[v, -64000000000.0], N[Not[LessEqual[v, 2.2e-41]], $MachinePrecision]], N[(t$95$1 + N[(-1.5 - N[(t$95$0 * 0.25), $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 := \left(r \cdot w\right) \cdot \left(r \cdot w\right)\\
t_1 := \frac{\frac{2}{r}}{r}\\
\mathbf{if}\;v \leq -64000000000 \lor \neg \left(v \leq 2.2 \cdot 10^{-41}\right):\\
\;\;\;\;t_1 + \left(-1.5 - t_0 \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 + \left(-1.5 - 0.375 \cdot t_0\right)\\
\end{array}
\end{array}
if v < -6.4e10 or 2.2e-41 < v Initial program 79.6%
Simplified97.0%
Taylor expanded in v around inf 81.1%
*-commutative81.1%
*-commutative81.1%
unpow281.1%
unpow281.1%
swap-sqr99.7%
unpow299.7%
*-commutative99.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
if -6.4e10 < v < 2.2e-41Initial program 85.3%
Simplified97.2%
Taylor expanded in v around 0 78.0%
*-commutative78.0%
*-commutative78.0%
unpow278.0%
unpow278.0%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow287.2%
Applied egg-rr99.8%
Final simplification99.7%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (- -1.5 (* (* (* r w) (* r w)) 0.25))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (((r * w) * (r * w)) * 0.25));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((2.0d0 / r) / r) + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
end function
public static double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (((r * w) * (r * w)) * 0.25));
}
def code(v, w, r): return ((2.0 / r) / r) + (-1.5 - (((r * w) * (r * w)) * 0.25))
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))) end
function tmp = code(v, w, r) tmp = ((2.0 / r) / r) + (-1.5 - (((r * w) * (r * w)) * 0.25)); end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)
\end{array}
Initial program 82.1%
Simplified97.1%
Taylor expanded in v around inf 76.4%
*-commutative76.4%
*-commutative76.4%
unpow276.4%
unpow276.4%
swap-sqr94.2%
unpow294.2%
*-commutative94.2%
Simplified94.2%
unpow294.2%
Applied egg-rr94.2%
Final simplification94.2%
herbie shell --seed 2024024
(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))