
(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 (/ 2.0 (* r r))) (- (* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (/ w (/ (+ v -1.0) r)))) 4.5)))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w / ((v + -1.0) / r)))) - 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))) * ((r * w) * (w / ((v + (-1.0d0)) / r)))) - 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))) * ((r * w) * (w / ((v + -1.0) / r)))) - 4.5);
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w / ((v + -1.0) / r)))) - 4.5)
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(r * w) * Float64(w / Float64(Float64(v + -1.0) / r)))) - 4.5)) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w / ((v + -1.0) / r)))) - 4.5); end
code[v_, w_, r_] := 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[(r * w), $MachinePrecision] * N[(w / N[(N[(v + -1.0), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{w}{\frac{v + -1}{r}}\right) - 4.5\right)
\end{array}
Initial program 82.6%
associate--l-82.6%
associate-*l*77.2%
sqr-neg77.2%
associate-*l*82.6%
associate-/l*84.5%
fma-define84.5%
Simplified84.5%
associate-/l*84.4%
*-commutative84.4%
associate-*r/84.1%
associate-*l*95.9%
associate-*r*99.4%
add-sqr-sqrt53.8%
associate-*l*53.8%
add-sqr-sqrt28.9%
sqrt-prod33.8%
sqrt-prod33.8%
sqrt-prod64.3%
*-commutative64.3%
sqrt-prod33.8%
*-commutative33.8%
sqrt-prod33.8%
sqrt-prod28.9%
add-sqr-sqrt53.8%
associate-*r*53.8%
add-sqr-sqrt99.4%
clear-num99.4%
un-div-inv99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 3.0 (/ 2.0 (* r r)))))
(if (<= w 1.4e-140)
(- (- t_0 (* (/ w (/ (- 1.0 v) r)) (* -0.25 (* r (* v w))))) 4.5)
(-
(+ t_0 (* (* w (* r (+ 0.375 (* v -0.25)))) (/ w (/ (+ v -1.0) r))))
4.5))))
double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if (w <= 1.4e-140) {
tmp = (t_0 - ((w / ((1.0 - v) / r)) * (-0.25 * (r * (v * w))))) - 4.5;
} else {
tmp = (t_0 + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.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 = 3.0d0 + (2.0d0 / (r * r))
if (w <= 1.4d-140) then
tmp = (t_0 - ((w / ((1.0d0 - v) / r)) * ((-0.25d0) * (r * (v * w))))) - 4.5d0
else
tmp = (t_0 + ((w * (r * (0.375d0 + (v * (-0.25d0))))) * (w / ((v + (-1.0d0)) / r)))) - 4.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if (w <= 1.4e-140) {
tmp = (t_0 - ((w / ((1.0 - v) / r)) * (-0.25 * (r * (v * w))))) - 4.5;
} else {
tmp = (t_0 + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5;
}
return tmp;
}
def code(v, w, r): t_0 = 3.0 + (2.0 / (r * r)) tmp = 0 if w <= 1.4e-140: tmp = (t_0 - ((w / ((1.0 - v) / r)) * (-0.25 * (r * (v * w))))) - 4.5 else: tmp = (t_0 + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5 return tmp
function code(v, w, r) t_0 = Float64(3.0 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if (w <= 1.4e-140) tmp = Float64(Float64(t_0 - Float64(Float64(w / Float64(Float64(1.0 - v) / r)) * Float64(-0.25 * Float64(r * Float64(v * w))))) - 4.5); else tmp = Float64(Float64(t_0 + Float64(Float64(w * Float64(r * Float64(0.375 + Float64(v * -0.25)))) * Float64(w / Float64(Float64(v + -1.0) / r)))) - 4.5); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 3.0 + (2.0 / (r * r)); tmp = 0.0; if (w <= 1.4e-140) tmp = (t_0 - ((w / ((1.0 - v) / r)) * (-0.25 * (r * (v * w))))) - 4.5; else tmp = (t_0 + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, 1.4e-140], N[(N[(t$95$0 - N[(N[(w / N[(N[(1.0 - v), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] * N[(-0.25 * N[(r * N[(v * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(t$95$0 + N[(N[(w * N[(r * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w / N[(N[(v + -1.0), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;w \leq 1.4 \cdot 10^{-140}:\\
\;\;\;\;\left(t\_0 - \frac{w}{\frac{1 - v}{r}} \cdot \left(-0.25 \cdot \left(r \cdot \left(v \cdot w\right)\right)\right)\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 + \left(w \cdot \left(r \cdot \left(0.375 + v \cdot -0.25\right)\right)\right) \cdot \frac{w}{\frac{v + -1}{r}}\right) - 4.5\\
\end{array}
\end{array}
if w < 1.4000000000000001e-140Initial program 84.7%
associate-/l*86.7%
cancel-sign-sub-inv86.7%
metadata-eval86.7%
+-commutative86.7%
*-commutative86.7%
fma-undefine86.7%
*-commutative86.7%
*-commutative86.7%
associate-/l*86.6%
*-commutative86.6%
associate-*r/86.6%
associate-*r*81.9%
associate-*l*90.0%
associate-*r*91.4%
Applied egg-rr91.4%
Taylor expanded in v around inf 79.1%
*-commutative79.1%
*-commutative79.1%
Simplified79.1%
if 1.4000000000000001e-140 < w Initial program 79.7%
associate-/l*81.5%
cancel-sign-sub-inv81.5%
metadata-eval81.5%
+-commutative81.5%
*-commutative81.5%
fma-undefine81.5%
*-commutative81.5%
*-commutative81.5%
associate-/l*81.4%
*-commutative81.4%
associate-*r/80.6%
associate-*r*80.5%
associate-*l*96.2%
associate-*r*98.1%
Applied egg-rr98.1%
Final simplification87.1%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 3.0 (/ 2.0 (* r r)))))
(if (<= v -2e+75)
(+ t_0 (- (* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (/ (* r w) v))) 4.5))
(-
(+ t_0 (* (* w (* r (+ 0.375 (* v -0.25)))) (/ w (/ (+ v -1.0) r))))
4.5))))
double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if (v <= -2e+75) {
tmp = t_0 + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * ((r * w) / v))) - 4.5);
} else {
tmp = (t_0 + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.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 = 3.0d0 + (2.0d0 / (r * r))
if (v <= (-2d+75)) then
tmp = t_0 + (((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * ((r * w) * ((r * w) / v))) - 4.5d0)
else
tmp = (t_0 + ((w * (r * (0.375d0 + (v * (-0.25d0))))) * (w / ((v + (-1.0d0)) / r)))) - 4.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if (v <= -2e+75) {
tmp = t_0 + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * ((r * w) / v))) - 4.5);
} else {
tmp = (t_0 + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5;
}
return tmp;
}
def code(v, w, r): t_0 = 3.0 + (2.0 / (r * r)) tmp = 0 if v <= -2e+75: tmp = t_0 + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * ((r * w) / v))) - 4.5) else: tmp = (t_0 + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5 return tmp
function code(v, w, r) t_0 = Float64(3.0 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if (v <= -2e+75) tmp = Float64(t_0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(r * w) * Float64(Float64(r * w) / v))) - 4.5)); else tmp = Float64(Float64(t_0 + Float64(Float64(w * Float64(r * Float64(0.375 + Float64(v * -0.25)))) * Float64(w / Float64(Float64(v + -1.0) / r)))) - 4.5); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 3.0 + (2.0 / (r * r)); tmp = 0.0; if (v <= -2e+75) tmp = t_0 + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * ((r * w) / v))) - 4.5); else tmp = (t_0 + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -2e+75], N[(t$95$0 + N[(N[(N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + N[(N[(w * N[(r * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w / N[(N[(v + -1.0), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2 \cdot 10^{+75}:\\
\;\;\;\;t\_0 + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v}\right) - 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 + \left(w \cdot \left(r \cdot \left(0.375 + v \cdot -0.25\right)\right)\right) \cdot \frac{w}{\frac{v + -1}{r}}\right) - 4.5\\
\end{array}
\end{array}
if v < -1.99999999999999985e75Initial program 70.7%
associate--l-70.6%
associate-*l*64.2%
sqr-neg64.2%
associate-*l*70.6%
associate-/l*74.7%
fma-define74.7%
Simplified74.7%
associate-/l*74.6%
*-commutative74.6%
associate-*r/72.5%
associate-*l*89.2%
associate-*r*97.6%
add-sqr-sqrt48.6%
associate-*l*48.7%
add-sqr-sqrt29.7%
sqrt-prod21.4%
sqrt-prod21.4%
sqrt-prod48.7%
*-commutative48.7%
sqrt-prod21.4%
*-commutative21.4%
sqrt-prod21.4%
sqrt-prod29.7%
add-sqr-sqrt48.7%
associate-*r*48.6%
add-sqr-sqrt97.6%
clear-num97.6%
un-div-inv97.7%
Applied egg-rr97.7%
add-sqr-sqrt57.4%
div-inv57.3%
times-frac56.2%
Applied egg-rr56.2%
*-commutative56.2%
frac-times57.3%
add-sqr-sqrt97.6%
Applied egg-rr97.6%
Taylor expanded in v around inf 99.7%
associate-*r/99.7%
mul-1-neg99.7%
distribute-rgt-neg-out99.7%
Simplified99.7%
if -1.99999999999999985e75 < v Initial program 85.3%
associate-/l*86.7%
cancel-sign-sub-inv86.7%
metadata-eval86.7%
+-commutative86.7%
*-commutative86.7%
fma-undefine86.7%
*-commutative86.7%
*-commutative86.7%
associate-/l*86.7%
*-commutative86.7%
associate-*r/86.7%
associate-*r*85.7%
associate-*l*96.2%
associate-*r*98.0%
Applied egg-rr98.0%
Final simplification98.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= w 3.8e-102)
(- (+ (+ 3.0 t_0) (* (* -0.25 (* r (* v w))) (/ w (/ (+ v -1.0) r)))) 4.5)
(+ t_0 (- -1.5 (* 0.375 (* (* r w) (* r w))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (w <= 3.8e-102) {
tmp = ((3.0 + t_0) + ((-0.25 * (r * (v * w))) * (w / ((v + -1.0) / r)))) - 4.5;
} else {
tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w))));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if (w <= 3.8d-102) then
tmp = ((3.0d0 + t_0) + (((-0.25d0) * (r * (v * w))) * (w / ((v + (-1.0d0)) / r)))) - 4.5d0
else
tmp = t_0 + ((-1.5d0) - (0.375d0 * ((r * w) * (r * w))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (w <= 3.8e-102) {
tmp = ((3.0 + t_0) + ((-0.25 * (r * (v * w))) * (w / ((v + -1.0) / r)))) - 4.5;
} else {
tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if w <= 3.8e-102: tmp = ((3.0 + t_0) + ((-0.25 * (r * (v * w))) * (w / ((v + -1.0) / r)))) - 4.5 else: tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (w <= 3.8e-102) tmp = Float64(Float64(Float64(3.0 + t_0) + Float64(Float64(-0.25 * Float64(r * Float64(v * w))) * Float64(w / Float64(Float64(v + -1.0) / r)))) - 4.5); else tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * w) * Float64(r * w))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (w <= 3.8e-102) tmp = ((3.0 + t_0) + ((-0.25 * (r * (v * w))) * (w / ((v + -1.0) / r)))) - 4.5; else tmp = t_0 + (-1.5 - (0.375 * ((r * w) * (r * w)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, 3.8e-102], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] + N[(N[(-0.25 * N[(r * N[(v * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w / N[(N[(v + -1.0), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \leq 3.8 \cdot 10^{-102}:\\
\;\;\;\;\left(\left(3 + t\_0\right) + \left(-0.25 \cdot \left(r \cdot \left(v \cdot w\right)\right)\right) \cdot \frac{w}{\frac{v + -1}{r}}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if w < 3.80000000000000026e-102Initial program 85.0%
associate-/l*86.9%
cancel-sign-sub-inv86.9%
metadata-eval86.9%
+-commutative86.9%
*-commutative86.9%
fma-undefine86.9%
*-commutative86.9%
*-commutative86.9%
associate-/l*86.9%
*-commutative86.9%
associate-*r/86.9%
associate-*r*82.2%
associate-*l*90.2%
associate-*r*91.5%
Applied egg-rr91.5%
Taylor expanded in v around inf 79.5%
*-commutative79.5%
*-commutative79.5%
Simplified79.5%
if 3.80000000000000026e-102 < w Initial program 79.2%
Simplified80.0%
Taylor expanded in v around 0 77.1%
*-commutative77.1%
*-commutative77.1%
unpow277.1%
unpow277.1%
swap-sqr96.1%
unpow296.1%
*-commutative96.1%
Simplified96.1%
*-commutative96.1%
pow296.1%
Applied egg-rr96.1%
Final simplification86.3%
(FPCore (v w r) :precision binary64 (+ (+ 3.0 (/ 2.0 (* r r))) (- (* (* 0.125 (+ 3.0 (* -2.0 v))) (* w (* (* r w) (/ r (+ v -1.0))))) 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 * ((r * w) * (r / (v + -1.0))))) - 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 * ((r * w) * (r / (v + (-1.0d0)))))) - 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 * ((r * w) * (r / (v + -1.0))))) - 4.5);
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * (w * ((r * w) * (r / (v + -1.0))))) - 4.5)
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(w * Float64(Float64(r * w) * Float64(r / Float64(v + -1.0))))) - 4.5)) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * (w * ((r * w) * (r / (v + -1.0))))) - 4.5); end
code[v_, w_, r_] := 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[(w * N[(N[(r * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(w \cdot \left(\left(r \cdot w\right) \cdot \frac{r}{v + -1}\right)\right) - 4.5\right)
\end{array}
Initial program 82.6%
associate--l-82.6%
associate-*l*77.2%
sqr-neg77.2%
associate-*l*82.6%
associate-/l*84.5%
fma-define84.5%
Simplified84.5%
div-inv84.5%
*-commutative84.5%
associate-*r*84.1%
*-commutative84.1%
div-inv84.1%
associate-*l*96.0%
add-sqr-sqrt52.2%
associate-*r*52.2%
add-sqr-sqrt27.3%
sqrt-prod33.8%
sqrt-prod33.8%
*-commutative33.8%
sqrt-prod64.3%
*-commutative64.3%
associate-*l*63.9%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (v w r) :precision binary64 (+ (+ 3.0 (/ 2.0 (* r r))) (- (* (* 0.125 (+ 3.0 (* -2.0 v))) (* w (* r (/ w (/ (+ v -1.0) r))))) 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 * (r * (w / ((v + -1.0) / r))))) - 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 * (r * (w / ((v + (-1.0d0)) / r))))) - 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 * (r * (w / ((v + -1.0) / r))))) - 4.5);
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * (w * (r * (w / ((v + -1.0) / r))))) - 4.5)
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(w * Float64(r * Float64(w / Float64(Float64(v + -1.0) / r))))) - 4.5)) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * (w * (r * (w / ((v + -1.0) / r))))) - 4.5); end
code[v_, w_, r_] := 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[(w * N[(r * N[(w / N[(N[(v + -1.0), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(w \cdot \left(r \cdot \frac{w}{\frac{v + -1}{r}}\right)\right) - 4.5\right)
\end{array}
Initial program 82.6%
associate--l-82.6%
associate-*l*77.2%
sqr-neg77.2%
associate-*l*82.6%
associate-/l*84.5%
fma-define84.5%
Simplified84.5%
associate-/l*84.4%
*-commutative84.4%
associate-*r/84.1%
*-commutative84.1%
associate-*l*95.9%
associate-*l*98.7%
clear-num98.7%
un-div-inv98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* 0.375 (* (* r w) (* r w))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * (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 = (2.0d0 / (r * r)) + ((-1.5d0) - (0.375d0 * ((r * w) * (r * w))))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * (r * w))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * (r * w))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * w) * Float64(r * w))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * ((r * w) * (r * w)))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right)
\end{array}
Initial program 82.6%
Simplified84.1%
Taylor expanded in v around 0 75.8%
*-commutative75.8%
*-commutative75.8%
unpow275.8%
unpow275.8%
swap-sqr93.5%
unpow293.5%
*-commutative93.5%
Simplified93.5%
*-commutative93.5%
pow293.5%
Applied egg-rr93.5%
Final simplification93.5%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) 4.5))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - 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))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - 4.5;
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) - 4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - 4.5) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) - 4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) - 4.5
\end{array}
Initial program 82.6%
Simplified77.8%
Taylor expanded in r around 0 55.7%
Final simplification55.7%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ (/ 2.0 r) r)) 4.5))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - 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)) - 4.5d0
end function
public static double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - 4.5;
}
def code(v, w, r): return (3.0 + ((2.0 / r) / r)) - 4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5) end
function tmp = code(v, w, r) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5
\end{array}
Initial program 82.6%
Simplified77.8%
Taylor expanded in r around 0 55.7%
associate-/r*55.7%
div-inv55.6%
Applied egg-rr55.6%
associate-*r/55.7%
*-rgt-identity55.7%
Simplified55.7%
Final simplification55.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 82.6%
Simplified77.8%
Taylor expanded in r around 0 55.7%
Taylor expanded in r around inf 13.9%
Final simplification13.9%
herbie shell --seed 2024075
(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))