
(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
(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)
(+
t_0
(- -1.5 (* (* r (* w (* r w))) (/ (+ 0.375 (* v -0.25)) (- 1.0 v)))))
(+ -1.5 (* 2.0 (pow r -2.0))))))
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 = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} else {
tmp = -1.5 + (2.0 * pow(r, -2.0));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: 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 = t_0 + ((-1.5d0) - ((r * (w * (r * w))) * ((0.375d0 + (v * (-0.25d0))) / (1.0d0 - v))))
else
tmp = (-1.5d0) + (2.0d0 * (r ** (-2.0d0)))
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 = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} else {
tmp = -1.5 + (2.0 * Math.pow(r, -2.0));
}
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 = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))) else: tmp = -1.5 + (2.0 * math.pow(r, -2.0)) 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(t_0 + Float64(-1.5 - Float64(Float64(r * Float64(w * Float64(r * w))) * Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(1.0 - v))))); else tmp = Float64(-1.5 + Float64(2.0 * (r ^ -2.0))); 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 = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))); else tmp = -1.5 + (2.0 * (r ^ -2.0)); 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[(t$95$0 + N[(-1.5 - N[(N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(2.0 * N[Power[r, -2.0], $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:\\
\;\;\;\;t_0 + \left(-1.5 - \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot \frac{0.375 + v \cdot -0.25}{1 - v}\right)\\
\mathbf{else}:\\
\;\;\;\;-1.5 + 2 \cdot {r}^{-2}\\
\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 84.2%
associate--l-84.2%
+-commutative84.2%
associate--l+84.2%
+-commutative84.2%
associate--r+84.2%
metadata-eval84.2%
associate-*l/91.1%
*-commutative91.1%
*-commutative91.1%
*-commutative91.1%
Simplified91.1%
Taylor expanded in r around 0 91.1%
unpow291.1%
associate-*l*99.8%
Simplified99.8%
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 87.7%
sub-neg87.7%
+-commutative87.7%
associate--l+87.7%
associate-/l*87.7%
distribute-neg-frac87.7%
associate-/r/87.7%
fma-def87.7%
sub-neg87.7%
Simplified87.7%
Taylor expanded in r around 0 99.9%
sub-neg99.9%
associate-*r/99.9%
metadata-eval99.9%
unpow299.9%
metadata-eval99.9%
Simplified99.9%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
expm1-log1p-u96.3%
expm1-udef96.3%
add-sqr-sqrt96.3%
div-inv96.3%
pow296.3%
pow-flip96.3%
metadata-eval96.3%
Applied egg-rr96.3%
expm1-def96.3%
expm1-log1p100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (v w r) :precision binary64 (+ (- (+ 3.0 (/ 2.0 (* r r))) (pow (/ (/ (- 1.0 v) (pow (* r w) 2.0)) (* 0.125 (fma -2.0 v 3.0))) -1.0)) -4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - pow((((1.0 - v) / pow((r * w), 2.0)) / (0.125 * fma(-2.0, v, 3.0))), -1.0)) + -4.5;
}
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - (Float64(Float64(Float64(1.0 - v) / (Float64(r * w) ^ 2.0)) / Float64(0.125 * fma(-2.0, v, 3.0))) ^ -1.0)) + -4.5) end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[N[(N[(N[(1.0 - v), $MachinePrecision] / N[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(0.125 * N[(-2.0 * v + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - {\left(\frac{\frac{1 - v}{{\left(r \cdot w\right)}^{2}}}{0.125 \cdot \mathsf{fma}\left(-2, v, 3\right)}\right)}^{-1}\right) + -4.5
\end{array}
Initial program 85.7%
sub-neg85.7%
associate-/l*89.6%
cancel-sign-sub-inv89.6%
metadata-eval89.6%
*-commutative89.6%
*-commutative89.6%
metadata-eval89.6%
Simplified89.6%
Taylor expanded in r around 0 89.6%
unpow289.7%
associate-*l*97.9%
Simplified97.9%
div-inv97.9%
*-commutative97.9%
Applied egg-rr97.9%
clear-num97.9%
inv-pow97.9%
un-div-inv97.9%
associate-*r*99.8%
pow199.8%
pow199.8%
pow-prod-up99.8%
metadata-eval99.8%
+-commutative99.8%
fma-def99.8%
Applied egg-rr99.8%
Final simplification99.8%
(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)
(+
t_0
(- -1.5 (* (* r (* w (* r w))) (/ (+ 0.375 (* v -0.25)) (- 1.0 v)))))
(+ 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) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= 3.0) {
tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} 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) + (((r * (r * (w * w))) * (0.125d0 * ((2.0d0 * v) - 3.0d0))) / (1.0d0 - v))) <= 3.0d0) then
tmp = t_0 + ((-1.5d0) - ((r * (w * (r * w))) * ((0.375d0 + (v * (-0.25d0))) / (1.0d0 - v))))
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) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= 3.0) {
tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v))));
} 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) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= 3.0: tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))) 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(r * Float64(r * Float64(w * w))) * Float64(0.125 * Float64(Float64(2.0 * v) - 3.0))) / Float64(1.0 - v))) <= 3.0) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(r * Float64(w * Float64(r * w))) * Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(1.0 - v))))); 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) + (((r * (r * (w * w))) * (0.125 * ((2.0 * v) - 3.0))) / (1.0 - v))) <= 3.0) tmp = t_0 + (-1.5 - ((r * (w * (r * w))) * ((0.375 + (v * -0.25)) / (1.0 - v)))); 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[(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[(t$95$0 + N[(-1.5 - N[(N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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(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:\\
\;\;\;\;t_0 + \left(-1.5 - \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot \frac{0.375 + v \cdot -0.25}{1 - v}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + -1.5\\
\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 84.2%
associate--l-84.2%
+-commutative84.2%
associate--l+84.2%
+-commutative84.2%
associate--r+84.2%
metadata-eval84.2%
associate-*l/91.1%
*-commutative91.1%
*-commutative91.1%
*-commutative91.1%
Simplified91.1%
Taylor expanded in r around 0 91.1%
unpow291.1%
associate-*l*99.8%
Simplified99.8%
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 87.7%
sub-neg87.7%
+-commutative87.7%
associate--l+87.7%
associate-/l*87.7%
distribute-neg-frac87.7%
associate-/r/87.7%
fma-def87.7%
sub-neg87.7%
Simplified87.7%
Taylor expanded in r around 0 99.9%
sub-neg99.9%
associate-*r/99.9%
metadata-eval99.9%
unpow299.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= (* w w) 0.0) (not (<= (* w w) 2e+295)))
(+ t_0 (- -1.5 (* r (* (* w (* r w)) 0.375))))
(+
t_0
(- -1.5 (* (/ (+ 0.375 (* v -0.25)) (- 1.0 v)) (* r (* r (* w w)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (((w * w) <= 0.0) || !((w * w) <= 2e+295)) {
tmp = t_0 + (-1.5 - (r * ((w * (r * w)) * 0.375)));
} else {
tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * 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) :: tmp
t_0 = 2.0d0 / (r * r)
if (((w * w) <= 0.0d0) .or. (.not. ((w * w) <= 2d+295))) then
tmp = t_0 + ((-1.5d0) - (r * ((w * (r * w)) * 0.375d0)))
else
tmp = t_0 + ((-1.5d0) - (((0.375d0 + (v * (-0.25d0))) / (1.0d0 - v)) * (r * (r * (w * 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 tmp;
if (((w * w) <= 0.0) || !((w * w) <= 2e+295)) {
tmp = t_0 + (-1.5 - (r * ((w * (r * w)) * 0.375)));
} else {
tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if ((w * w) <= 0.0) or not ((w * w) <= 2e+295): tmp = t_0 + (-1.5 - (r * ((w * (r * w)) * 0.375))) else: tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((Float64(w * w) <= 0.0) || !(Float64(w * w) <= 2e+295)) tmp = Float64(t_0 + Float64(-1.5 - Float64(r * Float64(Float64(w * Float64(r * w)) * 0.375)))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(1.0 - v)) * Float64(r * Float64(r * Float64(w * w)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (((w * w) <= 0.0) || ~(((w * w) <= 2e+295))) tmp = t_0 + (-1.5 - (r * ((w * (r * w)) * 0.375))); else tmp = t_0 + (-1.5 - (((0.375 + (v * -0.25)) / (1.0 - v)) * (r * (r * (w * w))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[(w * w), $MachinePrecision], 0.0], N[Not[LessEqual[N[(w * w), $MachinePrecision], 2e+295]], $MachinePrecision]], N[(t$95$0 + N[(-1.5 - N[(r * N[(N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \cdot w \leq 0 \lor \neg \left(w \cdot w \leq 2 \cdot 10^{+295}\right):\\
\;\;\;\;t_0 + \left(-1.5 - r \cdot \left(\left(w \cdot \left(r \cdot w\right)\right) \cdot 0.375\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - \frac{0.375 + v \cdot -0.25}{1 - v} \cdot \left(r \cdot \left(r \cdot \left(w \cdot w\right)\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 w w) < 0.0 or 2e295 < (*.f64 w w) Initial program 80.8%
associate--l-80.8%
+-commutative80.8%
associate--l+80.8%
+-commutative80.8%
associate--r+80.8%
metadata-eval80.8%
associate-*l/80.8%
*-commutative80.8%
*-commutative80.8%
*-commutative80.8%
Simplified80.8%
Taylor expanded in r around 0 80.8%
unpow280.8%
associate-*l*96.2%
Simplified96.2%
Taylor expanded in v around 0 74.1%
unpow274.1%
associate-*r*74.1%
*-commutative74.1%
unpow274.1%
associate-*r*74.1%
*-commutative74.1%
associate-*l*80.8%
Simplified80.8%
Taylor expanded in r around 0 80.8%
unpow280.8%
associate-*l*93.2%
Simplified93.2%
if 0.0 < (*.f64 w w) < 2e295Initial program 90.8%
associate--l-90.8%
+-commutative90.8%
associate--l+90.8%
+-commutative90.8%
associate--r+90.8%
metadata-eval90.8%
associate-*l/99.0%
*-commutative99.0%
*-commutative99.0%
*-commutative99.0%
Simplified99.0%
Final simplification96.0%
(FPCore (v w r)
:precision binary64
(if (or (<= r -4.8e+94)
(not (or (<= r -125.0) (and (not (<= r -1.05e-21)) (<= r 2.8e+51)))))
(* (* w w) (* (* r r) -0.375))
(+ (/ 2.0 (* r r)) -1.5)))
double code(double v, double w, double r) {
double tmp;
if ((r <= -4.8e+94) || !((r <= -125.0) || (!(r <= -1.05e-21) && (r <= 2.8e+51)))) {
tmp = (w * w) * ((r * r) * -0.375);
} else {
tmp = (2.0 / (r * r)) + -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) :: tmp
if ((r <= (-4.8d+94)) .or. (.not. (r <= (-125.0d0)) .or. (.not. (r <= (-1.05d-21))) .and. (r <= 2.8d+51))) then
tmp = (w * w) * ((r * r) * (-0.375d0))
else
tmp = (2.0d0 / (r * r)) + (-1.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if ((r <= -4.8e+94) || !((r <= -125.0) || (!(r <= -1.05e-21) && (r <= 2.8e+51)))) {
tmp = (w * w) * ((r * r) * -0.375);
} else {
tmp = (2.0 / (r * r)) + -1.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if (r <= -4.8e+94) or not ((r <= -125.0) or (not (r <= -1.05e-21) and (r <= 2.8e+51))): tmp = (w * w) * ((r * r) * -0.375) else: tmp = (2.0 / (r * r)) + -1.5 return tmp
function code(v, w, r) tmp = 0.0 if ((r <= -4.8e+94) || !((r <= -125.0) || (!(r <= -1.05e-21) && (r <= 2.8e+51)))) tmp = Float64(Float64(w * w) * Float64(Float64(r * r) * -0.375)); else tmp = Float64(Float64(2.0 / Float64(r * r)) + -1.5); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if ((r <= -4.8e+94) || ~(((r <= -125.0) || (~((r <= -1.05e-21)) && (r <= 2.8e+51))))) tmp = (w * w) * ((r * r) * -0.375); else tmp = (2.0 / (r * r)) + -1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[Or[LessEqual[r, -4.8e+94], N[Not[Or[LessEqual[r, -125.0], And[N[Not[LessEqual[r, -1.05e-21]], $MachinePrecision], LessEqual[r, 2.8e+51]]]], $MachinePrecision]], N[(N[(w * w), $MachinePrecision] * N[(N[(r * r), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq -4.8 \cdot 10^{+94} \lor \neg \left(r \leq -125 \lor \neg \left(r \leq -1.05 \cdot 10^{-21}\right) \land r \leq 2.8 \cdot 10^{+51}\right):\\
\;\;\;\;\left(w \cdot w\right) \cdot \left(\left(r \cdot r\right) \cdot -0.375\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{r \cdot r} + -1.5\\
\end{array}
\end{array}
if r < -4.79999999999999965e94 or -125 < r < -1.05000000000000006e-21 or 2.80000000000000005e51 < r Initial program 85.7%
sub-neg85.7%
associate-/l*92.0%
cancel-sign-sub-inv92.0%
metadata-eval92.0%
*-commutative92.0%
*-commutative92.0%
metadata-eval92.0%
Simplified92.0%
Taylor expanded in v around 0 71.3%
associate-*r*71.4%
*-commutative71.4%
unpow271.4%
unpow271.4%
associate-*r*71.4%
Simplified71.4%
Taylor expanded in r around inf 62.3%
*-commutative62.3%
unpow262.3%
associate-*l*62.3%
unpow262.3%
Simplified62.3%
if -4.79999999999999965e94 < r < -125 or -1.05000000000000006e-21 < r < 2.80000000000000005e51Initial program 85.7%
sub-neg85.7%
+-commutative85.7%
associate--l+85.7%
associate-/l*87.7%
distribute-neg-frac87.7%
associate-/r/87.7%
fma-def87.7%
sub-neg87.7%
Simplified87.7%
Taylor expanded in r around 0 87.9%
sub-neg87.9%
associate-*r/87.9%
metadata-eval87.9%
unpow287.9%
metadata-eval87.9%
Simplified87.9%
Final simplification76.2%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* r (* (* w (* r w)) 0.375)))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (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 = (2.0d0 / (r * r)) + ((-1.5d0) - (r * ((w * (r * w)) * 0.375d0)))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (r * ((w * (r * w)) * 0.375)));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - (r * ((w * (r * w)) * 0.375)))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(r * Float64(Float64(w * Float64(r * w)) * 0.375)))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - (r * ((w * (r * w)) * 0.375))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(r * N[(N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - r \cdot \left(\left(w \cdot \left(r \cdot w\right)\right) \cdot 0.375\right)\right)
\end{array}
Initial program 85.7%
associate--l-85.7%
+-commutative85.7%
associate--l+85.7%
+-commutative85.7%
associate--r+85.7%
metadata-eval85.7%
associate-*l/89.7%
*-commutative89.7%
*-commutative89.7%
*-commutative89.7%
Simplified89.7%
Taylor expanded in r around 0 89.7%
unpow289.7%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in v around 0 78.9%
unpow278.9%
associate-*r*78.9%
*-commutative78.9%
unpow278.9%
associate-*r*78.9%
*-commutative78.9%
associate-*l*84.7%
Simplified84.7%
Taylor expanded in r around 0 84.7%
unpow284.7%
associate-*l*91.0%
Simplified91.0%
Final simplification91.0%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* r (* w (* r (* w 0.375)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (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 = (2.0d0 / (r * r)) + ((-1.5d0) - (r * (w * (r * (w * 0.375d0)))))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (r * (w * (r * (w * 0.375)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - (r * (w * (r * (w * 0.375)))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(r * Float64(w * Float64(r * Float64(w * 0.375)))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - (r * (w * (r * (w * 0.375))))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(r * N[(w * N[(r * N[(w * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - r \cdot \left(w \cdot \left(r \cdot \left(w \cdot 0.375\right)\right)\right)\right)
\end{array}
Initial program 85.7%
associate--l-85.7%
+-commutative85.7%
associate--l+85.7%
+-commutative85.7%
associate--r+85.7%
metadata-eval85.7%
associate-*l/89.7%
*-commutative89.7%
*-commutative89.7%
*-commutative89.7%
Simplified89.7%
Taylor expanded in r around 0 89.7%
unpow289.7%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in v around 0 78.9%
unpow278.9%
associate-*r*78.9%
*-commutative78.9%
unpow278.9%
associate-*r*78.9%
*-commutative78.9%
associate-*l*84.7%
Simplified84.7%
Taylor expanded in r around 0 84.7%
*-commutative84.7%
*-commutative84.7%
unpow284.7%
associate-*r*91.0%
associate-*r*91.1%
*-commutative91.1%
associate-*l*91.0%
*-commutative91.0%
Simplified91.0%
Final simplification91.0%
(FPCore (v w r) :precision binary64 (if (<= r -1.45e-8) -1.5 (if (<= r 4.6e-8) (/ 2.0 (* r r)) -1.5)))
double code(double v, double w, double r) {
double tmp;
if (r <= -1.45e-8) {
tmp = -1.5;
} else if (r <= 4.6e-8) {
tmp = 2.0 / (r * r);
} else {
tmp = -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) :: tmp
if (r <= (-1.45d-8)) then
tmp = -1.5d0
else if (r <= 4.6d-8) then
tmp = 2.0d0 / (r * r)
else
tmp = -1.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= -1.45e-8) {
tmp = -1.5;
} else if (r <= 4.6e-8) {
tmp = 2.0 / (r * r);
} else {
tmp = -1.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= -1.45e-8: tmp = -1.5 elif r <= 4.6e-8: tmp = 2.0 / (r * r) else: tmp = -1.5 return tmp
function code(v, w, r) tmp = 0.0 if (r <= -1.45e-8) tmp = -1.5; elseif (r <= 4.6e-8) tmp = Float64(2.0 / Float64(r * r)); else tmp = -1.5; end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= -1.45e-8) tmp = -1.5; elseif (r <= 4.6e-8) tmp = 2.0 / (r * r); else tmp = -1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, -1.45e-8], -1.5, If[LessEqual[r, 4.6e-8], N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision], -1.5]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq -1.45 \cdot 10^{-8}:\\
\;\;\;\;-1.5\\
\mathbf{elif}\;r \leq 4.6 \cdot 10^{-8}:\\
\;\;\;\;\frac{2}{r \cdot r}\\
\mathbf{else}:\\
\;\;\;\;-1.5\\
\end{array}
\end{array}
if r < -1.4500000000000001e-8 or 4.6000000000000002e-8 < r Initial program 86.2%
sub-neg86.2%
+-commutative86.2%
associate--l+86.2%
associate-/l*93.1%
distribute-neg-frac93.1%
associate-/r/93.1%
fma-def93.1%
sub-neg93.1%
Simplified76.9%
Taylor expanded in r around 0 27.5%
sub-neg27.5%
associate-*r/27.5%
metadata-eval27.5%
unpow227.5%
metadata-eval27.5%
Simplified27.5%
Taylor expanded in r around inf 27.1%
if -1.4500000000000001e-8 < r < 4.6000000000000002e-8Initial program 85.1%
sub-neg85.1%
+-commutative85.1%
associate--l+85.1%
associate-/l*85.8%
distribute-neg-frac85.8%
associate-/r/85.9%
fma-def85.9%
sub-neg85.9%
Simplified85.9%
Taylor expanded in r around 0 89.2%
sub-neg89.2%
associate-*r/89.2%
metadata-eval89.2%
unpow289.2%
metadata-eval89.2%
Simplified89.2%
Taylor expanded in r around 0 89.2%
unpow289.2%
Simplified89.2%
Final simplification56.5%
(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.7%
sub-neg85.7%
+-commutative85.7%
associate--l+85.7%
associate-/l*89.6%
distribute-neg-frac89.6%
associate-/r/89.7%
fma-def89.7%
sub-neg89.7%
Simplified81.2%
Taylor expanded in r around 0 56.7%
sub-neg56.7%
associate-*r/56.7%
metadata-eval56.7%
unpow256.7%
metadata-eval56.7%
Simplified56.7%
Final simplification56.7%
(FPCore (v w r) :precision binary64 -1.5)
double code(double v, double w, double r) {
return -1.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = -1.5d0
end function
public static double code(double v, double w, double r) {
return -1.5;
}
def code(v, w, r): return -1.5
function code(v, w, r) return -1.5 end
function tmp = code(v, w, r) tmp = -1.5; end
code[v_, w_, r_] := -1.5
\begin{array}{l}
\\
-1.5
\end{array}
Initial program 85.7%
sub-neg85.7%
+-commutative85.7%
associate--l+85.7%
associate-/l*89.6%
distribute-neg-frac89.6%
associate-/r/89.7%
fma-def89.7%
sub-neg89.7%
Simplified81.2%
Taylor expanded in r around 0 56.7%
sub-neg56.7%
associate-*r/56.7%
metadata-eval56.7%
unpow256.7%
metadata-eval56.7%
Simplified56.7%
Taylor expanded in r around inf 14.8%
Final simplification14.8%
herbie shell --seed 2023178
(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))