
(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 7 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 (* (* (* r w) (/ w (/ (- 1.0 v) r))) (fma v -0.25 0.375)))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (((r * w) * (w / ((1.0 - v) / r))) * fma(v, -0.25, 0.375)));
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(w / Float64(Float64(1.0 - v) / r))) * fma(v, -0.25, 0.375)))) end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(w / N[(N[(1.0 - v), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(v * -0.25 + 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \frac{w}{\frac{1 - v}{r}}\right) \cdot \mathsf{fma}\left(v, -0.25, 0.375\right)\right)
\end{array}
Initial program 85.3%
Simplified97.6%
div-inv97.6%
associate-*r*99.8%
associate-*l*99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
*-commutative99.8%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<=
(+
(+ 3.0 t_0)
(/ (* (* r (* r (* w w))) (* 0.125 (- (* 2.0 v) 3.0))) (- 1.0 v)))
3.0)
(+
-4.5
(+
3.0
(- t_0 (* (* r w) (/ (* r (* w (+ 0.375 (* v -0.25)))) (- 1.0 v))))))
(+ -1.5 (+ t_0 (* (* (* r w) (* r w)) -0.375))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (((3.0 + t_0) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= 3.0) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * (w * (0.375 + (v * -0.25)))) / (1.0 - v)))));
} else {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -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 (((3.0d0 + t_0) + (((r * (r * (w * w))) * (0.125d0 * ((2.0d0 * v) - 3.0d0))) / (1.0d0 - v))) <= 3.0d0) then
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * ((r * (w * (0.375d0 + (v * (-0.25d0))))) / (1.0d0 - v)))))
else
tmp = (-1.5d0) + (t_0 + (((r * w) * (r * w)) * (-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 (((3.0 + t_0) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= 3.0) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * (w * (0.375 + (v * -0.25)))) / (1.0 - v)))));
} else {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.375));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if ((3.0 + t_0) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= 3.0: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * (w * (0.375 + (v * -0.25)))) / (1.0 - v))))) else: tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.375)) 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(r * Float64(r * Float64(w * w))) * Float64(0.125 * Float64(Float64(2.0 * v) - 3.0))) / Float64(1.0 - v))) <= 3.0) tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(Float64(r * Float64(w * Float64(0.375 + Float64(v * -0.25)))) / Float64(1.0 - v)))))); else tmp = Float64(-1.5 + Float64(t_0 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -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 + t_0) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= 3.0) tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * (w * (0.375 + (v * -0.25)))) / (1.0 - v))))); else tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.375)); 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[(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], 3.0], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(N[(r * N[(w * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(t$95$0 + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;\left(3 + t_0\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 3:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \frac{r \cdot \left(w \cdot \left(0.375 + v \cdot -0.25\right)\right)}{1 - v}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(t_0 + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\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))) < 3Initial program 89.2%
Simplified92.7%
associate-/r/92.8%
associate-*r*82.8%
swap-sqr99.8%
associate-*r*99.7%
+-commutative99.7%
distribute-rgt-in99.7%
*-commutative99.7%
associate-*l*99.7%
metadata-eval99.7%
metadata-eval99.7%
fma-udef99.7%
Applied egg-rr99.7%
Taylor expanded in r around 0 98.0%
if 3 < (-.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 79.5%
Simplified79.5%
Taylor expanded in v around 0 79.5%
*-commutative79.5%
unpow279.5%
unpow279.5%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification98.7%
(FPCore (v w r)
:precision binary64
(+
-4.5
(+
3.0
(-
(/ 2.0 (* r r))
(/
(* 0.125 (+ 3.0 (* v -2.0)))
(* (/ (- 1.0 v) (* r w)) (/ 1.0 (* r w))))))))
double code(double v, double w, double r) {
return -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 - v) / (r * w)) * (1.0 / (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 = (-4.5d0) + (3.0d0 + ((2.0d0 / (r * r)) - ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) / (((1.0d0 - v) / (r * w)) * (1.0d0 / (r * w))))))
end function
public static double code(double v, double w, double r) {
return -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 - v) / (r * w)) * (1.0 / (r * w))))));
}
def code(v, w, r): return -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 - v) / (r * w)) * (1.0 / (r * w))))))
function code(v, w, r) return Float64(-4.5 + Float64(3.0 + Float64(Float64(2.0 / Float64(r * r)) - Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) / Float64(Float64(Float64(1.0 - v) / Float64(r * w)) * Float64(1.0 / Float64(r * w))))))) end
function tmp = code(v, w, r) tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 - v) / (r * w)) * (1.0 / (r * w)))))); end
code[v_, w_, r_] := N[(-4.5 + N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4.5 + \left(3 + \left(\frac{2}{r \cdot r} - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{\frac{1 - v}{r \cdot w} \cdot \frac{1}{r \cdot w}}\right)\right)
\end{array}
Initial program 85.3%
Simplified87.4%
associate-*r*97.5%
*-commutative97.5%
*-un-lft-identity97.5%
associate-*r*99.8%
times-frac99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(+
(+
3.0
(-
(/ 2.0 (* r r))
(/
(* 0.125 (+ 3.0 (* v -2.0)))
(* (/ (/ 1.0 r) w) (/ (- 1.0 v) (* r w))))))
-4.5))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 / r) / w) * ((1.0 - v) / (r * w)))))) + -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 + (v * (-2.0d0)))) / (((1.0d0 / r) / w) * ((1.0d0 - v) / (r * w)))))) + (-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 + (v * -2.0))) / (((1.0 / r) / w) * ((1.0 - v) / (r * w)))))) + -4.5;
}
def code(v, w, r): return (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 / r) / w) * ((1.0 - v) / (r * w)))))) + -4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(Float64(2.0 / Float64(r * r)) - Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) / Float64(Float64(Float64(1.0 / r) / w) * Float64(Float64(1.0 - v) / Float64(r * w)))))) + -4.5) end
function tmp = code(v, w, r) tmp = (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 / r) / w) * ((1.0 - v) / (r * w)))))) + -4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(1.0 / r), $MachinePrecision] / w), $MachinePrecision] * N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \left(\frac{2}{r \cdot r} - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{\frac{\frac{1}{r}}{w} \cdot \frac{1 - v}{r \cdot w}}\right)\right) + -4.5
\end{array}
Initial program 85.3%
Simplified87.4%
associate-*r*97.5%
*-commutative97.5%
*-un-lft-identity97.5%
associate-*r*99.8%
times-frac99.8%
Applied egg-rr99.8%
inv-pow99.8%
unpow-prod-down99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Simplified99.8%
Taylor expanded in r around 0 99.8%
associate-/r*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -1.06e+64) (not (<= v 0.4)))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* (* r w) 0.25)))))
(+ -1.5 (+ t_0 (* (* (* r w) (* r w)) -0.375))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -1.06e+64) || !(v <= 0.4)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * w) * 0.25))));
} else {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -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 <= (-1.06d+64)) .or. (.not. (v <= 0.4d0))) then
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * ((r * w) * 0.25d0))))
else
tmp = (-1.5d0) + (t_0 + (((r * w) * (r * w)) * (-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 <= -1.06e+64) || !(v <= 0.4)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * w) * 0.25))));
} else {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.375));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -1.06e+64) or not (v <= 0.4): tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * w) * 0.25)))) else: tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.375)) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -1.06e+64) || !(v <= 0.4)) tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(Float64(r * w) * 0.25))))); else tmp = Float64(-1.5 + Float64(t_0 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.375))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -1.06e+64) || ~((v <= 0.4))) tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * w) * 0.25)))); else tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.375)); 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, -1.06e+64], N[Not[LessEqual[v, 0.4]], $MachinePrecision]], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(t$95$0 + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.06 \cdot 10^{+64} \lor \neg \left(v \leq 0.4\right):\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot 0.25\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(t_0 + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\right)\\
\end{array}
\end{array}
if v < -1.06e64 or 0.40000000000000002 < v Initial program 83.6%
Simplified87.9%
associate-/r/87.9%
associate-*r*83.5%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.8%
if -1.06e64 < v < 0.40000000000000002Initial program 86.9%
Simplified86.9%
Taylor expanded in v around 0 78.9%
*-commutative78.9%
unpow278.9%
unpow278.9%
swap-sqr99.3%
unpow299.3%
Simplified99.3%
unpow299.3%
Applied egg-rr99.3%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -1.2e+64) (not (<= v 0.02)))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* (* r w) 0.25)))))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* w (* r 0.375)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -1.2e+64) || !(v <= 0.02)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * w) * 0.25))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (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 <= (-1.2d+64)) .or. (.not. (v <= 0.02d0))) then
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * ((r * w) * 0.25d0))))
else
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (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 <= -1.2e+64) || !(v <= 0.02)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * w) * 0.25))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -1.2e+64) or not (v <= 0.02): tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * w) * 0.25)))) else: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -1.2e+64) || !(v <= 0.02)) tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(Float64(r * w) * 0.25))))); else tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * 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 <= -1.2e+64) || ~((v <= 0.02))) tmp = -4.5 + (3.0 + (t_0 - ((r * w) * ((r * w) * 0.25)))); else tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))); 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, -1.2e+64], N[Not[LessEqual[v, 0.02]], $MachinePrecision]], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.2 \cdot 10^{+64} \lor \neg \left(v \leq 0.02\right):\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot 0.25\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\right)\\
\end{array}
\end{array}
if v < -1.2e64 or 0.0200000000000000004 < v Initial program 83.6%
Simplified87.9%
associate-/r/87.9%
associate-*r*83.5%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.8%
if -1.2e64 < v < 0.0200000000000000004Initial program 86.9%
Simplified86.9%
associate-/r/86.9%
associate-*r*79.4%
swap-sqr99.9%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.3%
*-commutative99.3%
associate-*r*99.3%
Simplified99.3%
Taylor expanded in w around 0 99.3%
*-commutative99.3%
associate-*r*99.3%
*-commutative99.3%
associate-*l*99.4%
Simplified99.4%
Final simplification99.6%
(FPCore (v w r) :precision binary64 (+ -1.5 (+ (/ 2.0 (* r r)) (* (* (* r w) (* r w)) -0.375))))
double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
}
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) + ((2.0d0 / (r * r)) + (((r * w) * (r * w)) * (-0.375d0)))
end function
public static double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
}
def code(v, w, r): return -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375))
function code(v, w, r) return Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.375))) end
function tmp = code(v, w, r) tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)); end
code[v_, w_, r_] := N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1.5 + \left(\frac{2}{r \cdot r} + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\right)
\end{array}
Initial program 85.3%
Simplified87.4%
Taylor expanded in v around 0 78.4%
*-commutative78.4%
unpow278.4%
unpow278.4%
swap-sqr94.6%
unpow294.6%
Simplified94.6%
unpow294.6%
Applied egg-rr94.6%
Final simplification94.6%
herbie shell --seed 2023337
(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))