
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
\end{array}
(FPCore (v w r) :precision binary64 (+ (- 3.0 (fma (/ (pow (* w r) 2.0) (- 1.0 v)) (* 0.125 (fma -2.0 v 3.0)) 4.5)) (/ 2.0 (* r r))))
double code(double v, double w, double r) {
return (3.0 - fma((pow((w * r), 2.0) / (1.0 - v)), (0.125 * fma(-2.0, v, 3.0)), 4.5)) + (2.0 / (r * r));
}
function code(v, w, r) return Float64(Float64(3.0 - fma(Float64((Float64(w * r) ^ 2.0) / Float64(1.0 - v)), Float64(0.125 * fma(-2.0, v, 3.0)), 4.5)) + Float64(2.0 / Float64(r * r))) end
code[v_, w_, r_] := N[(N[(3.0 - N[(N[(N[Power[N[(w * r), $MachinePrecision], 2.0], $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(0.125 * N[(-2.0 * v + 3.0), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision] + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 - \mathsf{fma}\left(\frac{{\left(w \cdot r\right)}^{2}}{1 - v}, 0.125 \cdot \mathsf{fma}\left(-2, v, 3\right), 4.5\right)\right) + \frac{2}{r \cdot r}
\end{array}
Initial program 83.9%
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%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<=
(-
(+ 3.0 t_0)
(/ (* (* (- 3.0 (* v 2.0)) 0.125) (* (* (* w w) r) r)) (- 1.0 v)))
-2.0)
(* (* (* -0.375 (* r r)) w) w)
(- t_0 1.5))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (((3.0 + t_0) - ((((3.0 - (v * 2.0)) * 0.125) * (((w * w) * r) * r)) / (1.0 - v))) <= -2.0) {
tmp = ((-0.375 * (r * r)) * w) * w;
} 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) :: tmp
t_0 = 2.0d0 / (r * r)
if (((3.0d0 + t_0) - ((((3.0d0 - (v * 2.0d0)) * 0.125d0) * (((w * w) * r) * r)) / (1.0d0 - v))) <= (-2.0d0)) then
tmp = (((-0.375d0) * (r * r)) * w) * w
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 tmp;
if (((3.0 + t_0) - ((((3.0 - (v * 2.0)) * 0.125) * (((w * w) * r) * r)) / (1.0 - v))) <= -2.0) {
tmp = ((-0.375 * (r * r)) * w) * w;
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if ((3.0 + t_0) - ((((3.0 - (v * 2.0)) * 0.125) * (((w * w) * r) * r)) / (1.0 - v))) <= -2.0: tmp = ((-0.375 * (r * r)) * w) * w else: tmp = t_0 - 1.5 return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(Float64(3.0 - Float64(v * 2.0)) * 0.125) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) <= -2.0) tmp = Float64(Float64(Float64(-0.375 * Float64(r * r)) * w) * w); else tmp = Float64(t_0 - 1.5); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (((3.0 + t_0) - ((((3.0 - (v * 2.0)) * 0.125) * (((w * w) * r) * r)) / (1.0 - v))) <= -2.0) tmp = ((-0.375 * (r * r)) * w) * w; 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]}, If[LessEqual[N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(N[(3.0 - N[(v * 2.0), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2.0], N[(N[(N[(-0.375 * N[(r * r), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * w), $MachinePrecision], N[(t$95$0 - 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;\left(3 + t\_0\right) - \frac{\left(\left(3 - v \cdot 2\right) \cdot 0.125\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} \leq -2:\\
\;\;\;\;\left(\left(-0.375 \cdot \left(r \cdot r\right)\right) \cdot w\right) \cdot w\\
\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))) < -2Initial program 84.8%
Taylor expanded in v around 0
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
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-fma.f64N/A
Applied rewrites81.8%
Taylor expanded in r around inf
Applied rewrites81.8%
if -2 < (-.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 83.1%
Taylor expanded in w around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f6494.6
Applied rewrites94.6%
Final simplification88.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 4.9e+16)
(+
(-
3.0
(fma (* (* (* (fma v -2.0 3.0) 0.125) r) w) (/ (* w r) (- 1.0 v)) 4.5))
t_0)
(-
(-
(+ 3.0 t_0)
(* (/ r (- 1.0 v)) (* (* (* 0.125 (fma -2.0 v 3.0)) w) (* w r))))
4.5))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 4.9e+16) {
tmp = (3.0 - fma((((fma(v, -2.0, 3.0) * 0.125) * r) * w), ((w * r) / (1.0 - v)), 4.5)) + t_0;
} else {
tmp = ((3.0 + t_0) - ((r / (1.0 - v)) * (((0.125 * fma(-2.0, v, 3.0)) * w) * (w * r)))) - 4.5;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 4.9e+16) tmp = Float64(Float64(3.0 - fma(Float64(Float64(Float64(fma(v, -2.0, 3.0) * 0.125) * r) * w), Float64(Float64(w * r) / Float64(1.0 - v)), 4.5)) + t_0); else tmp = Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(r / Float64(1.0 - v)) * Float64(Float64(Float64(0.125 * fma(-2.0, v, 3.0)) * w) * Float64(w * r)))) - 4.5); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 4.9e+16], N[(N[(3.0 - N[(N[(N[(N[(N[(v * -2.0 + 3.0), $MachinePrecision] * 0.125), $MachinePrecision] * r), $MachinePrecision] * w), $MachinePrecision] * N[(N[(w * r), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(0.125 * N[(-2.0 * v + 3.0), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 4.9 \cdot 10^{+16}:\\
\;\;\;\;\left(3 - \mathsf{fma}\left(\left(\left(\mathsf{fma}\left(v, -2, 3\right) \cdot 0.125\right) \cdot r\right) \cdot w, \frac{w \cdot r}{1 - v}, 4.5\right)\right) + t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(3 + t\_0\right) - \frac{r}{1 - v} \cdot \left(\left(\left(0.125 \cdot \mathsf{fma}\left(-2, v, 3\right)\right) \cdot w\right) \cdot \left(w \cdot r\right)\right)\right) - 4.5\\
\end{array}
\end{array}
if r < 4.9e16Initial program 81.9%
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 rewrites93.6%
if 4.9e16 < r Initial program 89.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites99.8%
Final simplification95.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= v -21000000.0)
(+ (fma (* (* (* w r) w) r) (- (/ 0.125 v) 0.25) -1.5) t_0)
(-
(- (+ 3.0 t_0) (/ (* (* (* w r) (* w r)) (fma -0.25 v 0.375)) (- 1.0 v)))
4.5))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (v <= -21000000.0) {
tmp = fma((((w * r) * w) * r), ((0.125 / v) - 0.25), -1.5) + t_0;
} else {
tmp = ((3.0 + t_0) - ((((w * r) * (w * r)) * fma(-0.25, v, 0.375)) / (1.0 - v))) - 4.5;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (v <= -21000000.0) tmp = Float64(fma(Float64(Float64(Float64(w * r) * w) * r), Float64(Float64(0.125 / v) - 0.25), -1.5) + t_0); else tmp = Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(Float64(w * r) * Float64(w * r)) * fma(-0.25, v, 0.375)) / Float64(1.0 - v))) - 4.5); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -21000000.0], N[(N[(N[(N[(N[(w * r), $MachinePrecision] * w), $MachinePrecision] * r), $MachinePrecision] * N[(N[(0.125 / v), $MachinePrecision] - 0.25), $MachinePrecision] + -1.5), $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] * N[(-0.25 * v + 0.375), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -21000000:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(w \cdot r\right) \cdot w\right) \cdot r, \frac{0.125}{v} - 0.25, -1.5\right) + t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(3 + t\_0\right) - \frac{\left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right) \cdot \mathsf{fma}\left(-0.25, v, 0.375\right)}{1 - v}\right) - 4.5\\
\end{array}
\end{array}
if v < -2.1e7Initial program 78.5%
Taylor expanded in v around inf
Applied rewrites90.0%
Applied rewrites98.2%
if -2.1e7 < v Initial program 85.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6497.8
Applied rewrites97.8%
Taylor expanded in v around 0
+-commutativeN/A
lower-fma.f6497.8
Applied rewrites97.8%
Final simplification97.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r)))
(t_1 (+ (fma (* (* (* w r) w) r) (- (/ 0.125 v) 0.25) -1.5) t_0)))
(if (<= v -300.0)
t_1
(if (<= v 2.6e+33) (fma -0.375 (* (* w r) (* w r)) (- t_0 1.5)) t_1))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = fma((((w * r) * w) * r), ((0.125 / v) - 0.25), -1.5) + t_0;
double tmp;
if (v <= -300.0) {
tmp = t_1;
} else if (v <= 2.6e+33) {
tmp = fma(-0.375, ((w * r) * (w * r)), (t_0 - 1.5));
} else {
tmp = t_1;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(fma(Float64(Float64(Float64(w * r) * w) * r), Float64(Float64(0.125 / v) - 0.25), -1.5) + t_0) tmp = 0.0 if (v <= -300.0) tmp = t_1; elseif (v <= 2.6e+33) tmp = fma(-0.375, Float64(Float64(w * r) * Float64(w * r)), Float64(t_0 - 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[(N[(N[(w * r), $MachinePrecision] * w), $MachinePrecision] * r), $MachinePrecision] * N[(N[(0.125 / v), $MachinePrecision] - 0.25), $MachinePrecision] + -1.5), $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[v, -300.0], t$95$1, If[LessEqual[v, 2.6e+33], N[(-0.375 * N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 - 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(\left(w \cdot r\right) \cdot w\right) \cdot r, \frac{0.125}{v} - 0.25, -1.5\right) + t\_0\\
\mathbf{if}\;v \leq -300:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;v \leq 2.6 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(-0.375, \left(w \cdot r\right) \cdot \left(w \cdot r\right), t\_0 - 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if v < -300 or 2.5999999999999997e33 < v Initial program 82.0%
Taylor expanded in v around inf
Applied rewrites90.9%
Applied rewrites98.0%
if -300 < v < 2.5999999999999997e33Initial program 85.2%
Taylor expanded in v around 0
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
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-fma.f64N/A
Applied rewrites85.2%
Applied rewrites98.7%
Final simplification98.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r)))
(t_1 (+ (fma (* (* (* w r) r) -0.25) w -1.5) t_0)))
(if (<= v -1e+22)
t_1
(if (<= v 3.1e-27) (fma -0.375 (* (* w r) (* w r)) (- t_0 1.5)) t_1))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = fma((((w * r) * r) * -0.25), w, -1.5) + t_0;
double tmp;
if (v <= -1e+22) {
tmp = t_1;
} else if (v <= 3.1e-27) {
tmp = fma(-0.375, ((w * r) * (w * r)), (t_0 - 1.5));
} else {
tmp = t_1;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(fma(Float64(Float64(Float64(w * r) * r) * -0.25), w, -1.5) + t_0) tmp = 0.0 if (v <= -1e+22) tmp = t_1; elseif (v <= 3.1e-27) tmp = fma(-0.375, Float64(Float64(w * r) * Float64(w * r)), Float64(t_0 - 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[(N[(N[(w * r), $MachinePrecision] * r), $MachinePrecision] * -0.25), $MachinePrecision] * w + -1.5), $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[v, -1e+22], t$95$1, If[LessEqual[v, 3.1e-27], N[(-0.375 * N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 - 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(\left(w \cdot r\right) \cdot r\right) \cdot -0.25, w, -1.5\right) + t\_0\\
\mathbf{if}\;v \leq -1 \cdot 10^{+22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;v \leq 3.1 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(-0.375, \left(w \cdot r\right) \cdot \left(w \cdot r\right), t\_0 - 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if v < -1e22 or 3.0999999999999998e-27 < v Initial program 83.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 inf
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.5
Applied rewrites87.5%
Applied rewrites96.4%
if -1e22 < v < 3.0999999999999998e-27Initial program 84.2%
Taylor expanded in v around 0
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
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-fma.f64N/A
Applied rewrites84.3%
Applied rewrites98.7%
Final simplification97.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (- (/ 2.0 (* r r)) 1.5)))
(if (<= v -1.32e+22)
(fma -0.25 (* (* (* w w) r) r) t_0)
(fma -0.375 (* (* w r) (* w r)) t_0))))
double code(double v, double w, double r) {
double t_0 = (2.0 / (r * r)) - 1.5;
double tmp;
if (v <= -1.32e+22) {
tmp = fma(-0.25, (((w * w) * r) * r), t_0);
} else {
tmp = fma(-0.375, ((w * r) * (w * r)), t_0);
}
return tmp;
}
function code(v, w, r) t_0 = Float64(Float64(2.0 / Float64(r * r)) - 1.5) tmp = 0.0 if (v <= -1.32e+22) tmp = fma(-0.25, Float64(Float64(Float64(w * w) * r) * r), t_0); else tmp = fma(-0.375, Float64(Float64(w * r) * Float64(w * r)), t_0); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]}, If[LessEqual[v, -1.32e+22], N[(-0.25 * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision] + t$95$0), $MachinePrecision], N[(-0.375 * N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r} - 1.5\\
\mathbf{if}\;v \leq -1.32 \cdot 10^{+22}:\\
\;\;\;\;\mathsf{fma}\left(-0.25, \left(\left(w \cdot w\right) \cdot r\right) \cdot r, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.375, \left(w \cdot r\right) \cdot \left(w \cdot r\right), t\_0\right)\\
\end{array}
\end{array}
if v < -1.32e22Initial program 79.6%
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
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-fma.f64N/A
Applied rewrites90.8%
if -1.32e22 < v Initial program 84.9%
Taylor expanded in v around 0
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
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-fma.f64N/A
Applied rewrites84.0%
Applied rewrites95.5%
Final simplification94.6%
(FPCore (v w r) :precision binary64 (fma -0.375 (* (* w r) (* w r)) (- (/ 2.0 (* r r)) 1.5)))
double code(double v, double w, double r) {
return fma(-0.375, ((w * r) * (w * r)), ((2.0 / (r * r)) - 1.5));
}
function code(v, w, r) return fma(-0.375, Float64(Float64(w * r) * Float64(w * r)), Float64(Float64(2.0 / Float64(r * r)) - 1.5)) end
code[v_, w_, r_] := N[(-0.375 * N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.375, \left(w \cdot r\right) \cdot \left(w \cdot r\right), \frac{2}{r \cdot r} - 1.5\right)
\end{array}
Initial program 83.9%
Taylor expanded in v around 0
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
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-fma.f64N/A
Applied rewrites82.5%
Applied rewrites92.7%
Final simplification92.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 83.9%
Taylor expanded in w around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f6453.6
Applied rewrites53.6%
(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 83.9%
Taylor expanded in r around 0
lower-/.f64N/A
unpow2N/A
lower-*.f6439.3
Applied rewrites39.3%
herbie shell --seed 2024256
(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))