
(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 11 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 (+ (- -1.5 (* (* (fma v -2.0 3.0) 0.125) (/ (pow (* w r) 2.0) (- 1.0 v)))) (/ 2.0 (* r r))))
double code(double v, double w, double r) {
return (-1.5 - ((fma(v, -2.0, 3.0) * 0.125) * (pow((w * r), 2.0) / (1.0 - v)))) + (2.0 / (r * r));
}
function code(v, w, r) return Float64(Float64(-1.5 - Float64(Float64(fma(v, -2.0, 3.0) * 0.125) * Float64((Float64(w * r) ^ 2.0) / Float64(1.0 - v)))) + Float64(2.0 / Float64(r * r))) end
code[v_, w_, r_] := N[(N[(-1.5 - N[(N[(N[(v * -2.0 + 3.0), $MachinePrecision] * 0.125), $MachinePrecision] * N[(N[Power[N[(w * r), $MachinePrecision], 2.0], $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-1.5 - \left(\mathsf{fma}\left(v, -2, 3\right) \cdot 0.125\right) \cdot \frac{{\left(w \cdot r\right)}^{2}}{1 - v}\right) + \frac{2}{r \cdot r}
\end{array}
Initial program 85.4%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
Applied rewrites99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (* (* w w) r)))
(if (<=
(- (+ 3.0 t_0) (/ (* (* t_1 r) (* (- 3.0 (* v 2.0)) 0.125)) (- 1.0 v)))
-4e+26)
(* (* -0.375 r) t_1)
(- t_0 1.5))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = (w * w) * r;
double tmp;
if (((3.0 + t_0) - (((t_1 * r) * ((3.0 - (v * 2.0)) * 0.125)) / (1.0 - v))) <= -4e+26) {
tmp = (-0.375 * r) * t_1;
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = (w * w) * r
if (((3.0d0 + t_0) - (((t_1 * r) * ((3.0d0 - (v * 2.0d0)) * 0.125d0)) / (1.0d0 - v))) <= (-4d+26)) then
tmp = ((-0.375d0) * r) * t_1
else
tmp = t_0 - 1.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = (w * w) * r;
double tmp;
if (((3.0 + t_0) - (((t_1 * r) * ((3.0 - (v * 2.0)) * 0.125)) / (1.0 - v))) <= -4e+26) {
tmp = (-0.375 * r) * t_1;
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = (w * w) * r tmp = 0 if ((3.0 + t_0) - (((t_1 * r) * ((3.0 - (v * 2.0)) * 0.125)) / (1.0 - v))) <= -4e+26: tmp = (-0.375 * r) * t_1 else: tmp = t_0 - 1.5 return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(Float64(w * w) * r) tmp = 0.0 if (Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(t_1 * r) * Float64(Float64(3.0 - Float64(v * 2.0)) * 0.125)) / Float64(1.0 - v))) <= -4e+26) tmp = Float64(Float64(-0.375 * r) * t_1); else tmp = Float64(t_0 - 1.5); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = (w * w) * r; tmp = 0.0; if (((3.0 + t_0) - (((t_1 * r) * ((3.0 - (v * 2.0)) * 0.125)) / (1.0 - v))) <= -4e+26) tmp = (-0.375 * r) * t_1; else tmp = t_0 - 1.5; 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[(N[(w * w), $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(t$95$1 * r), $MachinePrecision] * N[(N[(3.0 - N[(v * 2.0), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e+26], N[(N[(-0.375 * r), $MachinePrecision] * t$95$1), $MachinePrecision], N[(t$95$0 - 1.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := \left(w \cdot w\right) \cdot r\\
\mathbf{if}\;\left(3 + t\_0\right) - \frac{\left(t\_1 \cdot r\right) \cdot \left(\left(3 - v \cdot 2\right) \cdot 0.125\right)}{1 - v} \leq -4 \cdot 10^{+26}:\\
\;\;\;\;\left(-0.375 \cdot r\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0 - 1.5\\
\end{array}
\end{array}
if (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) < -4.00000000000000019e26Initial program 90.7%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in v around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
Taylor expanded in w around inf
Applied rewrites77.0%
Applied rewrites85.8%
if -4.00000000000000019e26 < (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) Initial program 82.1%
Taylor expanded in w around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f6495.9
Applied rewrites95.9%
Final simplification92.1%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= (* w w) 5e+276)
(+
(-
3.0
(fma (/ (* (* (* w r) w) r) (- 1.0 v)) (* (fma -2.0 v 3.0) 0.125) 4.5))
t_0)
(- t_0 (fma (* (* 0.375 r) (* w r)) w 1.5)))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((w * w) <= 5e+276) {
tmp = (3.0 - fma(((((w * r) * w) * r) / (1.0 - v)), (fma(-2.0, v, 3.0) * 0.125), 4.5)) + t_0;
} else {
tmp = t_0 - fma(((0.375 * r) * (w * r)), w, 1.5);
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(w * w) <= 5e+276) tmp = Float64(Float64(3.0 - fma(Float64(Float64(Float64(Float64(w * r) * w) * r) / Float64(1.0 - v)), Float64(fma(-2.0, v, 3.0) * 0.125), 4.5)) + t_0); else tmp = Float64(t_0 - fma(Float64(Float64(0.375 * r) * Float64(w * r)), w, 1.5)); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(w * w), $MachinePrecision], 5e+276], N[(N[(3.0 - N[(N[(N[(N[(N[(w * r), $MachinePrecision] * w), $MachinePrecision] * r), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(N[(-2.0 * v + 3.0), $MachinePrecision] * 0.125), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], N[(t$95$0 - N[(N[(N[(0.375 * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] * w + 1.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \cdot w \leq 5 \cdot 10^{+276}:\\
\;\;\;\;\left(3 - \mathsf{fma}\left(\frac{\left(\left(w \cdot r\right) \cdot w\right) \cdot r}{1 - v}, \mathsf{fma}\left(-2, v, 3\right) \cdot 0.125, 4.5\right)\right) + t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(\left(0.375 \cdot r\right) \cdot \left(w \cdot r\right), w, 1.5\right)\\
\end{array}
\end{array}
if (*.f64 w w) < 5.00000000000000001e276Initial program 94.5%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
lift-pow.f64N/A
lift-*.f64N/A
unpow-prod-downN/A
pow2N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
if 5.00000000000000001e276 < (*.f64 w w) Initial program 58.1%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites100.0%
Taylor expanded in v around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 8.5e-39)
(+ (- -1.5 (* (* 0.25 (* w r)) (* w r))) t_0)
(+
(-
3.0
(fma (* (* (* (fma v -2.0 3.0) 0.125) w) (/ r (- 1.0 v))) (* w r) 4.5))
t_0))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 8.5e-39) {
tmp = (-1.5 - ((0.25 * (w * r)) * (w * r))) + t_0;
} else {
tmp = (3.0 - fma((((fma(v, -2.0, 3.0) * 0.125) * w) * (r / (1.0 - v))), (w * r), 4.5)) + t_0;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 8.5e-39) tmp = Float64(Float64(-1.5 - Float64(Float64(0.25 * Float64(w * r)) * Float64(w * r))) + t_0); else tmp = Float64(Float64(3.0 - fma(Float64(Float64(Float64(fma(v, -2.0, 3.0) * 0.125) * w) * Float64(r / Float64(1.0 - v))), Float64(w * r), 4.5)) + t_0); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 8.5e-39], N[(N[(-1.5 - N[(N[(0.25 * N[(w * r), $MachinePrecision]), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[(3.0 - N[(N[(N[(N[(N[(v * -2.0 + 3.0), $MachinePrecision] * 0.125), $MachinePrecision] * w), $MachinePrecision] * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w * r), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 8.5 \cdot 10^{-39}:\\
\;\;\;\;\left(-1.5 - \left(0.25 \cdot \left(w \cdot r\right)\right) \cdot \left(w \cdot r\right)\right) + t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(3 - \mathsf{fma}\left(\left(\left(\mathsf{fma}\left(v, -2, 3\right) \cdot 0.125\right) \cdot w\right) \cdot \frac{r}{1 - v}, w \cdot r, 4.5\right)\right) + t\_0\\
\end{array}
\end{array}
if r < 8.5000000000000005e-39Initial program 82.1%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites89.2%
Taylor expanded in v around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6494.4
Applied rewrites94.4%
lift--.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6494.4
Applied rewrites94.4%
if 8.5000000000000005e-39 < r Initial program 94.2%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites98.5%
Final simplification95.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r)))
(t_1 (+ (- -1.5 (* (* 0.25 (* w r)) (* w r))) t_0)))
(if (<= v -3.7e+30)
t_1
(if (<= v 3e-75) (- t_0 (fma (* (* 0.375 r) w) (* w r) 1.5)) t_1))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = (-1.5 - ((0.25 * (w * r)) * (w * r))) + t_0;
double tmp;
if (v <= -3.7e+30) {
tmp = t_1;
} else if (v <= 3e-75) {
tmp = t_0 - fma(((0.375 * r) * w), (w * r), 1.5);
} else {
tmp = t_1;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(Float64(-1.5 - Float64(Float64(0.25 * Float64(w * r)) * Float64(w * r))) + t_0) tmp = 0.0 if (v <= -3.7e+30) tmp = t_1; elseif (v <= 3e-75) tmp = Float64(t_0 - fma(Float64(Float64(0.375 * r) * w), Float64(w * r), 1.5)); else tmp = t_1; end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-1.5 - N[(N[(0.25 * N[(w * r), $MachinePrecision]), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[v, -3.7e+30], t$95$1, If[LessEqual[v, 3e-75], N[(t$95$0 - N[(N[(N[(0.375 * r), $MachinePrecision] * w), $MachinePrecision] * N[(w * r), $MachinePrecision] + 1.5), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := \left(-1.5 - \left(0.25 \cdot \left(w \cdot r\right)\right) \cdot \left(w \cdot r\right)\right) + t\_0\\
\mathbf{if}\;v \leq -3.7 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;v \leq 3 \cdot 10^{-75}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(\left(0.375 \cdot r\right) \cdot w, w \cdot r, 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if v < -3.70000000000000016e30 or 2.9999999999999999e-75 < v Initial program 82.8%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites84.1%
Taylor expanded in v around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
if -3.70000000000000016e30 < v < 2.9999999999999999e-75Initial program 88.1%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in v around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6486.8
Applied rewrites86.8%
Applied rewrites88.1%
Applied rewrites99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r)))
(t_1 (fma (* (* -0.25 r) (* w r)) w (- t_0 1.5))))
(if (<= v -6e+30)
t_1
(if (<= v 3e-75) (- t_0 (fma (* (* 0.375 r) w) (* w r) 1.5)) t_1))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = fma(((-0.25 * r) * (w * r)), w, (t_0 - 1.5));
double tmp;
if (v <= -6e+30) {
tmp = t_1;
} else if (v <= 3e-75) {
tmp = t_0 - fma(((0.375 * r) * w), (w * r), 1.5);
} else {
tmp = t_1;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = fma(Float64(Float64(-0.25 * r) * Float64(w * r)), w, Float64(t_0 - 1.5)) tmp = 0.0 if (v <= -6e+30) tmp = t_1; elseif (v <= 3e-75) tmp = Float64(t_0 - fma(Float64(Float64(0.375 * r) * w), Float64(w * r), 1.5)); else tmp = t_1; end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-0.25 * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] * w + N[(t$95$0 - 1.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -6e+30], t$95$1, If[LessEqual[v, 3e-75], N[(t$95$0 - N[(N[(N[(0.375 * r), $MachinePrecision] * w), $MachinePrecision] * N[(w * r), $MachinePrecision] + 1.5), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := \mathsf{fma}\left(\left(-0.25 \cdot r\right) \cdot \left(w \cdot r\right), w, t\_0 - 1.5\right)\\
\mathbf{if}\;v \leq -6 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;v \leq 3 \cdot 10^{-75}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(\left(0.375 \cdot r\right) \cdot w, w \cdot r, 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if v < -5.99999999999999956e30 or 2.9999999999999999e-75 < v Initial program 82.8%
Taylor expanded in v around inf
sub-negN/A
+-commutativeN/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
associate-+l+N/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-fma.f64N/A
Applied rewrites91.8%
Applied rewrites97.6%
if -5.99999999999999956e30 < v < 2.9999999999999999e-75Initial program 88.1%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in v around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6486.8
Applied rewrites86.8%
Applied rewrites88.1%
Applied rewrites99.8%
Final simplification98.7%
(FPCore (v w r)
:precision binary64
(if (<= r 12000000.0)
(- (/ 2.0 (* r r)) (fma (* (* 0.375 r) w) (* w r) 1.5))
(-
(fma (* (fma -0.25 v 0.375) (* (/ r (- 1.0 v)) w)) (* (- r) w) 3.0)
4.5)))
double code(double v, double w, double r) {
double tmp;
if (r <= 12000000.0) {
tmp = (2.0 / (r * r)) - fma(((0.375 * r) * w), (w * r), 1.5);
} else {
tmp = fma((fma(-0.25, v, 0.375) * ((r / (1.0 - v)) * w)), (-r * w), 3.0) - 4.5;
}
return tmp;
}
function code(v, w, r) tmp = 0.0 if (r <= 12000000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) - fma(Float64(Float64(0.375 * r) * w), Float64(w * r), 1.5)); else tmp = Float64(fma(Float64(fma(-0.25, v, 0.375) * Float64(Float64(r / Float64(1.0 - v)) * w)), Float64(Float64(-r) * w), 3.0) - 4.5); end return tmp end
code[v_, w_, r_] := If[LessEqual[r, 12000000.0], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.375 * r), $MachinePrecision] * w), $MachinePrecision] * N[(w * r), $MachinePrecision] + 1.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-0.25 * v + 0.375), $MachinePrecision] * N[(N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision] * N[((-r) * w), $MachinePrecision] + 3.0), $MachinePrecision] - 4.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 12000000:\\
\;\;\;\;\frac{2}{r \cdot r} - \mathsf{fma}\left(\left(0.375 \cdot r\right) \cdot w, w \cdot r, 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.25, v, 0.375\right) \cdot \left(\frac{r}{1 - v} \cdot w\right), \left(-r\right) \cdot w, 3\right) - 4.5\\
\end{array}
\end{array}
if r < 1.2e7Initial program 82.5%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in v around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6489.8
Applied rewrites89.8%
Applied rewrites80.0%
Applied rewrites95.0%
if 1.2e7 < r Initial program 93.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites98.4%
Taylor expanded in r around inf
Applied rewrites98.4%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
Applied rewrites99.7%
Final simplification96.2%
(FPCore (v w r) :precision binary64 (if (<= r 1.7e-112) (/ (/ 2.0 r) r) (- (/ 2.0 (* r r)) (fma r (* (* 0.375 r) (* w w)) 1.5))))
double code(double v, double w, double r) {
double tmp;
if (r <= 1.7e-112) {
tmp = (2.0 / r) / r;
} else {
tmp = (2.0 / (r * r)) - fma(r, ((0.375 * r) * (w * w)), 1.5);
}
return tmp;
}
function code(v, w, r) tmp = 0.0 if (r <= 1.7e-112) tmp = Float64(Float64(2.0 / r) / r); else tmp = Float64(Float64(2.0 / Float64(r * r)) - fma(r, Float64(Float64(0.375 * r) * Float64(w * w)), 1.5)); end return tmp end
code[v_, w_, r_] := If[LessEqual[r, 1.7e-112], N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(r * N[(N[(0.375 * r), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision] + 1.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 1.7 \cdot 10^{-112}:\\
\;\;\;\;\frac{\frac{2}{r}}{r}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{r \cdot r} - \mathsf{fma}\left(r, \left(0.375 \cdot r\right) \cdot \left(w \cdot w\right), 1.5\right)\\
\end{array}
\end{array}
if r < 1.6999999999999999e-112Initial program 81.5%
Taylor expanded in r around 0
lower-/.f64N/A
unpow2N/A
lower-*.f6458.9
Applied rewrites58.9%
Applied rewrites58.9%
if 1.6999999999999999e-112 < r Initial program 93.7%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in v around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.3
Applied rewrites79.3%
Applied rewrites93.3%
(FPCore (v w r) :precision binary64 (- (/ 2.0 (* r r)) (fma (* (* 0.375 r) w) (* w r) 1.5)))
double code(double v, double w, double r) {
return (2.0 / (r * r)) - fma(((0.375 * r) * w), (w * r), 1.5);
}
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) - fma(Float64(Float64(0.375 * r) * w), Float64(w * r), 1.5)) end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.375 * r), $MachinePrecision] * w), $MachinePrecision] * N[(w * r), $MachinePrecision] + 1.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} - \mathsf{fma}\left(\left(0.375 \cdot r\right) \cdot w, w \cdot r, 1.5\right)
\end{array}
Initial program 85.4%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in v around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6486.1
Applied rewrites86.1%
Applied rewrites83.3%
Applied rewrites94.7%
(FPCore (v w r) :precision binary64 (- (/ 2.0 (* r r)) 1.5))
double code(double v, double w, double r) {
return (2.0 / (r * r)) - 1.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = (2.0d0 / (r * r)) - 1.5d0
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) - 1.5;
}
def code(v, w, r): return (2.0 / (r * r)) - 1.5
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) - 1.5) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) - 1.5; end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} - 1.5
\end{array}
Initial program 85.4%
Taylor expanded in w around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f6461.5
Applied rewrites61.5%
(FPCore (v w r) :precision binary64 (/ 2.0 (* r r)))
double code(double v, double w, double r) {
return 2.0 / (r * r);
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = 2.0d0 / (r * r)
end function
public static double code(double v, double w, double r) {
return 2.0 / (r * r);
}
def code(v, w, r): return 2.0 / (r * r)
function code(v, w, r) return Float64(2.0 / Float64(r * r)) end
function tmp = code(v, w, r) tmp = 2.0 / (r * r); end
code[v_, w_, r_] := N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r}
\end{array}
Initial program 85.4%
Taylor expanded in r around 0
lower-/.f64N/A
unpow2N/A
lower-*.f6445.6
Applied rewrites45.6%
herbie shell --seed 2024288
(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))