
(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))) (t_1 (- -1.5 (* (* (* w r) (* w r)) 0.25))))
(if (<= v -2e+41)
(+ t_0 t_1)
(if (<= v 1.65e-128)
(-
(+
(+ 3.0 t_0)
(* (* w (* r (+ 0.375 (* v -0.25)))) (/ w (/ (+ v -1.0) r))))
4.5)
(+ (/ (/ 2.0 r) r) t_1)))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = -1.5 - (((w * r) * (w * r)) * 0.25);
double tmp;
if (v <= -2e+41) {
tmp = t_0 + t_1;
} else if (v <= 1.65e-128) {
tmp = ((3.0 + t_0) + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5;
} else {
tmp = ((2.0 / r) / r) + t_1;
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = (-1.5d0) - (((w * r) * (w * r)) * 0.25d0)
if (v <= (-2d+41)) then
tmp = t_0 + t_1
else if (v <= 1.65d-128) then
tmp = ((3.0d0 + t_0) + ((w * (r * (0.375d0 + (v * (-0.25d0))))) * (w / ((v + (-1.0d0)) / r)))) - 4.5d0
else
tmp = ((2.0d0 / r) / r) + t_1
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = -1.5 - (((w * r) * (w * r)) * 0.25);
double tmp;
if (v <= -2e+41) {
tmp = t_0 + t_1;
} else if (v <= 1.65e-128) {
tmp = ((3.0 + t_0) + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5;
} else {
tmp = ((2.0 / r) / r) + t_1;
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = -1.5 - (((w * r) * (w * r)) * 0.25) tmp = 0 if v <= -2e+41: tmp = t_0 + t_1 elif v <= 1.65e-128: tmp = ((3.0 + t_0) + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5 else: tmp = ((2.0 / r) / r) + t_1 return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(-1.5 - Float64(Float64(Float64(w * r) * Float64(w * r)) * 0.25)) tmp = 0.0 if (v <= -2e+41) tmp = Float64(t_0 + t_1); elseif (v <= 1.65e-128) tmp = Float64(Float64(Float64(3.0 + t_0) + Float64(Float64(w * Float64(r * Float64(0.375 + Float64(v * -0.25)))) * Float64(w / Float64(Float64(v + -1.0) / r)))) - 4.5); else tmp = Float64(Float64(Float64(2.0 / r) / r) + t_1); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = -1.5 - (((w * r) * (w * r)) * 0.25); tmp = 0.0; if (v <= -2e+41) tmp = t_0 + t_1; elseif (v <= 1.65e-128) tmp = ((3.0 + t_0) + ((w * (r * (0.375 + (v * -0.25)))) * (w / ((v + -1.0) / r)))) - 4.5; else tmp = ((2.0 / r) / r) + t_1; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.5 - N[(N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -2e+41], N[(t$95$0 + t$95$1), $MachinePrecision], If[LessEqual[v, 1.65e-128], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] + 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], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := -1.5 - \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right) \cdot 0.25\\
\mathbf{if}\;v \leq -2 \cdot 10^{+41}:\\
\;\;\;\;t\_0 + t\_1\\
\mathbf{elif}\;v \leq 1.65 \cdot 10^{-128}:\\
\;\;\;\;\left(\left(3 + t\_0\right) + \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\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + t\_1\\
\end{array}
\end{array}
if v < -2.00000000000000001e41Initial program 84.8%
Simplified90.3%
Taylor expanded in v around inf 83.7%
*-commutative83.7%
*-commutative83.7%
unpow283.7%
unpow283.7%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
if -2.00000000000000001e41 < v < 1.65e-128Initial program 88.1%
associate-/l*88.1%
cancel-sign-sub-inv88.1%
metadata-eval88.1%
+-commutative88.1%
*-commutative88.1%
fma-undefine88.1%
*-commutative88.1%
*-commutative88.1%
associate-/l*88.1%
*-commutative88.1%
associate-*r/88.1%
associate-*r*88.1%
associate-*l*98.0%
associate-*r*99.8%
Applied egg-rr99.8%
if 1.65e-128 < v Initial program 80.3%
Simplified87.8%
Taylor expanded in v around inf 84.9%
*-commutative84.9%
*-commutative84.9%
unpow284.9%
unpow284.9%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
associate-/r*99.8%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 3.0 (/ 2.0 (* r r)))))
(if (<= (* w w) 1e+276)
(+
t_0
(-
(* (* 0.125 (+ 3.0 (* -2.0 v))) (/ (* w (* w r)) (/ (+ v -1.0) r)))
4.5))
(- (- t_0 (* (* w r) (* (* w r) 0.375))) 4.5))))
double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if ((w * w) <= 1e+276) {
tmp = t_0 + (((0.125 * (3.0 + (-2.0 * v))) * ((w * (w * r)) / ((v + -1.0) / r))) - 4.5);
} else {
tmp = (t_0 - ((w * r) * ((w * r) * 0.375))) - 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 * w) <= 1d+276) then
tmp = t_0 + (((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * ((w * (w * r)) / ((v + (-1.0d0)) / r))) - 4.5d0)
else
tmp = (t_0 - ((w * r) * ((w * r) * 0.375d0))) - 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 * w) <= 1e+276) {
tmp = t_0 + (((0.125 * (3.0 + (-2.0 * v))) * ((w * (w * r)) / ((v + -1.0) / r))) - 4.5);
} else {
tmp = (t_0 - ((w * r) * ((w * r) * 0.375))) - 4.5;
}
return tmp;
}
def code(v, w, r): t_0 = 3.0 + (2.0 / (r * r)) tmp = 0 if (w * w) <= 1e+276: tmp = t_0 + (((0.125 * (3.0 + (-2.0 * v))) * ((w * (w * r)) / ((v + -1.0) / r))) - 4.5) else: tmp = (t_0 - ((w * r) * ((w * r) * 0.375))) - 4.5 return tmp
function code(v, w, r) t_0 = Float64(3.0 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if (Float64(w * w) <= 1e+276) tmp = Float64(t_0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(w * Float64(w * r)) / Float64(Float64(v + -1.0) / r))) - 4.5)); else tmp = Float64(Float64(t_0 - Float64(Float64(w * r) * Float64(Float64(w * r) * 0.375))) - 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 * w) <= 1e+276) tmp = t_0 + (((0.125 * (3.0 + (-2.0 * v))) * ((w * (w * r)) / ((v + -1.0) / r))) - 4.5); else tmp = (t_0 - ((w * r) * ((w * r) * 0.375))) - 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[N[(w * w), $MachinePrecision], 1e+276], N[(t$95$0 + N[(N[(N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(w * N[(w * r), $MachinePrecision]), $MachinePrecision] / N[(N[(v + -1.0), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - N[(N[(w * r), $MachinePrecision] * N[(N[(w * r), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;w \cdot w \leq 10^{+276}:\\
\;\;\;\;t\_0 + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \frac{w \cdot \left(w \cdot r\right)}{\frac{v + -1}{r}} - 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 - \left(w \cdot r\right) \cdot \left(\left(w \cdot r\right) \cdot 0.375\right)\right) - 4.5\\
\end{array}
\end{array}
if (*.f64 w w) < 1.0000000000000001e276Initial program 91.5%
associate--l-91.5%
associate-*l*88.5%
sqr-neg88.5%
associate-*l*91.5%
associate-/l*96.9%
fma-define96.9%
Simplified96.9%
associate-/l*96.9%
*-commutative96.9%
associate-*r/96.9%
*-commutative96.9%
associate-*l*99.3%
associate-*l*97.2%
clear-num97.2%
un-div-inv97.2%
Applied egg-rr97.2%
*-commutative97.2%
associate-*l*99.8%
associate-*r/99.8%
*-commutative99.8%
Simplified99.8%
if 1.0000000000000001e276 < (*.f64 w w) Initial program 65.4%
associate-/l*65.4%
cancel-sign-sub-inv65.4%
metadata-eval65.4%
+-commutative65.4%
*-commutative65.4%
fma-undefine65.4%
*-commutative65.4%
*-commutative65.4%
associate-/l*65.4%
*-commutative65.4%
associate-*r/65.4%
associate-*r*65.4%
associate-*l*97.2%
associate-*r*95.6%
Applied egg-rr94.2%
*-commutative94.2%
associate-/r/95.6%
associate-*l*95.6%
Simplified95.6%
Taylor expanded in v around 0 72.3%
Taylor expanded in v around 0 99.6%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (- -1.5 (* (* (* w r) (* w r)) 0.25))))
(if (<= v -1e+43)
(+ t_0 t_1)
(if (<= v 1.65e-128)
(- (- (+ 3.0 t_0) (* (* w r) (* w (* r (+ 0.375 (* v -0.25)))))) 4.5)
(+ (/ (/ 2.0 r) r) t_1)))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = -1.5 - (((w * r) * (w * r)) * 0.25);
double tmp;
if (v <= -1e+43) {
tmp = t_0 + t_1;
} else if (v <= 1.65e-128) {
tmp = ((3.0 + t_0) - ((w * r) * (w * (r * (0.375 + (v * -0.25)))))) - 4.5;
} else {
tmp = ((2.0 / r) / r) + t_1;
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = (-1.5d0) - (((w * r) * (w * r)) * 0.25d0)
if (v <= (-1d+43)) then
tmp = t_0 + t_1
else if (v <= 1.65d-128) then
tmp = ((3.0d0 + t_0) - ((w * r) * (w * (r * (0.375d0 + (v * (-0.25d0))))))) - 4.5d0
else
tmp = ((2.0d0 / r) / r) + t_1
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = -1.5 - (((w * r) * (w * r)) * 0.25);
double tmp;
if (v <= -1e+43) {
tmp = t_0 + t_1;
} else if (v <= 1.65e-128) {
tmp = ((3.0 + t_0) - ((w * r) * (w * (r * (0.375 + (v * -0.25)))))) - 4.5;
} else {
tmp = ((2.0 / r) / r) + t_1;
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = -1.5 - (((w * r) * (w * r)) * 0.25) tmp = 0 if v <= -1e+43: tmp = t_0 + t_1 elif v <= 1.65e-128: tmp = ((3.0 + t_0) - ((w * r) * (w * (r * (0.375 + (v * -0.25)))))) - 4.5 else: tmp = ((2.0 / r) / r) + t_1 return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(-1.5 - Float64(Float64(Float64(w * r) * Float64(w * r)) * 0.25)) tmp = 0.0 if (v <= -1e+43) tmp = Float64(t_0 + t_1); elseif (v <= 1.65e-128) tmp = Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(w * r) * Float64(w * Float64(r * Float64(0.375 + Float64(v * -0.25)))))) - 4.5); else tmp = Float64(Float64(Float64(2.0 / r) / r) + t_1); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = -1.5 - (((w * r) * (w * r)) * 0.25); tmp = 0.0; if (v <= -1e+43) tmp = t_0 + t_1; elseif (v <= 1.65e-128) tmp = ((3.0 + t_0) - ((w * r) * (w * (r * (0.375 + (v * -0.25)))))) - 4.5; else tmp = ((2.0 / r) / r) + t_1; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.5 - N[(N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1e+43], N[(t$95$0 + t$95$1), $MachinePrecision], If[LessEqual[v, 1.65e-128], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(w * r), $MachinePrecision] * N[(w * N[(r * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := -1.5 - \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right) \cdot 0.25\\
\mathbf{if}\;v \leq -1 \cdot 10^{+43}:\\
\;\;\;\;t\_0 + t\_1\\
\mathbf{elif}\;v \leq 1.65 \cdot 10^{-128}:\\
\;\;\;\;\left(\left(3 + t\_0\right) - \left(w \cdot r\right) \cdot \left(w \cdot \left(r \cdot \left(0.375 + v \cdot -0.25\right)\right)\right)\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + t\_1\\
\end{array}
\end{array}
if v < -1.00000000000000001e43Initial program 84.8%
Simplified90.3%
Taylor expanded in v around inf 83.7%
*-commutative83.7%
*-commutative83.7%
unpow283.7%
unpow283.7%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
if -1.00000000000000001e43 < v < 1.65e-128Initial program 88.1%
associate-/l*88.1%
cancel-sign-sub-inv88.1%
metadata-eval88.1%
+-commutative88.1%
*-commutative88.1%
fma-undefine88.1%
*-commutative88.1%
*-commutative88.1%
associate-/l*88.1%
*-commutative88.1%
associate-*r/88.1%
associate-*r*88.1%
associate-*l*98.0%
associate-*r*99.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.5%
if 1.65e-128 < v Initial program 80.3%
Simplified87.8%
Taylor expanded in v around inf 84.9%
*-commutative84.9%
*-commutative84.9%
unpow284.9%
unpow284.9%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
associate-/r*99.8%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(if (<= v 1.5e-128)
(-
(+
(+ 3.0 (/ 2.0 (* r r)))
(* (* (* w r) (+ 0.375 (* v -0.25))) (* r (/ w (+ v -1.0)))))
4.5)
(+ (/ (/ 2.0 r) r) (- -1.5 (* (* (* w r) (* w r)) 0.25)))))
double code(double v, double w, double r) {
double tmp;
if (v <= 1.5e-128) {
tmp = ((3.0 + (2.0 / (r * r))) + (((w * r) * (0.375 + (v * -0.25))) * (r * (w / (v + -1.0))))) - 4.5;
} else {
tmp = ((2.0 / r) / r) + (-1.5 - (((w * r) * (w * r)) * 0.25));
}
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 (v <= 1.5d-128) then
tmp = ((3.0d0 + (2.0d0 / (r * r))) + (((w * r) * (0.375d0 + (v * (-0.25d0)))) * (r * (w / (v + (-1.0d0)))))) - 4.5d0
else
tmp = ((2.0d0 / r) / r) + ((-1.5d0) - (((w * r) * (w * r)) * 0.25d0))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (v <= 1.5e-128) {
tmp = ((3.0 + (2.0 / (r * r))) + (((w * r) * (0.375 + (v * -0.25))) * (r * (w / (v + -1.0))))) - 4.5;
} else {
tmp = ((2.0 / r) / r) + (-1.5 - (((w * r) * (w * r)) * 0.25));
}
return tmp;
}
def code(v, w, r): tmp = 0 if v <= 1.5e-128: tmp = ((3.0 + (2.0 / (r * r))) + (((w * r) * (0.375 + (v * -0.25))) * (r * (w / (v + -1.0))))) - 4.5 else: tmp = ((2.0 / r) / r) + (-1.5 - (((w * r) * (w * r)) * 0.25)) return tmp
function code(v, w, r) tmp = 0.0 if (v <= 1.5e-128) tmp = Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(Float64(w * r) * Float64(0.375 + Float64(v * -0.25))) * Float64(r * Float64(w / Float64(v + -1.0))))) - 4.5); else tmp = Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(Float64(Float64(w * r) * Float64(w * r)) * 0.25))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (v <= 1.5e-128) tmp = ((3.0 + (2.0 / (r * r))) + (((w * r) * (0.375 + (v * -0.25))) * (r * (w / (v + -1.0))))) - 4.5; else tmp = ((2.0 / r) / r) + (-1.5 - (((w * r) * (w * r)) * 0.25)); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[v, 1.5e-128], N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(w * r), $MachinePrecision] * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(r * N[(w / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 1.5 \cdot 10^{-128}:\\
\;\;\;\;\left(\left(3 + \frac{2}{r \cdot r}\right) + \left(\left(w \cdot r\right) \cdot \left(0.375 + v \cdot -0.25\right)\right) \cdot \left(r \cdot \frac{w}{v + -1}\right)\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + \left(-1.5 - \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right) \cdot 0.25\right)\\
\end{array}
\end{array}
if v < 1.49999999999999989e-128Initial program 87.1%
associate-/l*88.8%
cancel-sign-sub-inv88.8%
metadata-eval88.8%
+-commutative88.8%
*-commutative88.8%
fma-undefine88.8%
*-commutative88.8%
*-commutative88.8%
associate-/l*88.8%
*-commutative88.8%
associate-*r/88.8%
associate-*r*85.0%
associate-*l*94.8%
associate-*r*94.8%
Applied egg-rr94.8%
*-commutative94.8%
associate-/r/94.8%
associate-*l*97.9%
Simplified97.9%
if 1.49999999999999989e-128 < v Initial program 80.3%
Simplified87.8%
Taylor expanded in v around inf 84.9%
*-commutative84.9%
*-commutative84.9%
unpow284.9%
unpow284.9%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
associate-/r*99.8%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification98.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (- -1.5 (* (* (* w r) (* w r)) 0.25))))
(if (<= v -4e+40)
(+ t_0 t_1)
(if (<= v 4e-129)
(- (- (+ 3.0 t_0) (* (* w r) (* (* w r) 0.375))) 4.5)
(+ (/ (/ 2.0 r) r) t_1)))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = -1.5 - (((w * r) * (w * r)) * 0.25);
double tmp;
if (v <= -4e+40) {
tmp = t_0 + t_1;
} else if (v <= 4e-129) {
tmp = ((3.0 + t_0) - ((w * r) * ((w * r) * 0.375))) - 4.5;
} else {
tmp = ((2.0 / r) / r) + t_1;
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = (-1.5d0) - (((w * r) * (w * r)) * 0.25d0)
if (v <= (-4d+40)) then
tmp = t_0 + t_1
else if (v <= 4d-129) then
tmp = ((3.0d0 + t_0) - ((w * r) * ((w * r) * 0.375d0))) - 4.5d0
else
tmp = ((2.0d0 / r) / r) + t_1
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = -1.5 - (((w * r) * (w * r)) * 0.25);
double tmp;
if (v <= -4e+40) {
tmp = t_0 + t_1;
} else if (v <= 4e-129) {
tmp = ((3.0 + t_0) - ((w * r) * ((w * r) * 0.375))) - 4.5;
} else {
tmp = ((2.0 / r) / r) + t_1;
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = -1.5 - (((w * r) * (w * r)) * 0.25) tmp = 0 if v <= -4e+40: tmp = t_0 + t_1 elif v <= 4e-129: tmp = ((3.0 + t_0) - ((w * r) * ((w * r) * 0.375))) - 4.5 else: tmp = ((2.0 / r) / r) + t_1 return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(-1.5 - Float64(Float64(Float64(w * r) * Float64(w * r)) * 0.25)) tmp = 0.0 if (v <= -4e+40) tmp = Float64(t_0 + t_1); elseif (v <= 4e-129) tmp = Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(w * r) * Float64(Float64(w * r) * 0.375))) - 4.5); else tmp = Float64(Float64(Float64(2.0 / r) / r) + t_1); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = -1.5 - (((w * r) * (w * r)) * 0.25); tmp = 0.0; if (v <= -4e+40) tmp = t_0 + t_1; elseif (v <= 4e-129) tmp = ((3.0 + t_0) - ((w * r) * ((w * r) * 0.375))) - 4.5; else tmp = ((2.0 / r) / r) + t_1; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.5 - N[(N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -4e+40], N[(t$95$0 + t$95$1), $MachinePrecision], If[LessEqual[v, 4e-129], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(w * r), $MachinePrecision] * N[(N[(w * r), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := -1.5 - \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right) \cdot 0.25\\
\mathbf{if}\;v \leq -4 \cdot 10^{+40}:\\
\;\;\;\;t\_0 + t\_1\\
\mathbf{elif}\;v \leq 4 \cdot 10^{-129}:\\
\;\;\;\;\left(\left(3 + t\_0\right) - \left(w \cdot r\right) \cdot \left(\left(w \cdot r\right) \cdot 0.375\right)\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + t\_1\\
\end{array}
\end{array}
if v < -4.00000000000000012e40Initial program 84.8%
Simplified90.3%
Taylor expanded in v around inf 83.7%
*-commutative83.7%
*-commutative83.7%
unpow283.7%
unpow283.7%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
if -4.00000000000000012e40 < v < 3.9999999999999997e-129Initial program 88.1%
associate-/l*88.1%
cancel-sign-sub-inv88.1%
metadata-eval88.1%
+-commutative88.1%
*-commutative88.1%
fma-undefine88.1%
*-commutative88.1%
*-commutative88.1%
associate-/l*88.1%
*-commutative88.1%
associate-*r/88.1%
associate-*r*88.1%
associate-*l*98.0%
associate-*r*99.8%
Applied egg-rr99.8%
*-commutative99.8%
associate-/r/99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in v around 0 99.5%
Taylor expanded in v around 0 99.5%
if 3.9999999999999997e-129 < v Initial program 80.3%
Simplified87.8%
Taylor expanded in v around inf 84.9%
*-commutative84.9%
*-commutative84.9%
unpow284.9%
unpow284.9%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
associate-/r*99.8%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* (* (* w r) (* w r)) 0.25))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (((w * r) * (w * r)) * 0.25));
}
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) - (((w * r) * (w * r)) * 0.25d0))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (((w * r) * (w * r)) * 0.25));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - (((w * r) * (w * r)) * 0.25))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(w * r) * Float64(w * r)) * 0.25))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - (((w * r) * (w * r)) * 0.25)); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right) \cdot 0.25\right)
\end{array}
Initial program 84.4%
Simplified88.4%
Taylor expanded in v around inf 81.1%
*-commutative81.1%
*-commutative81.1%
unpow281.1%
unpow281.1%
swap-sqr93.9%
unpow293.9%
*-commutative93.9%
Simplified93.9%
unpow293.9%
Applied egg-rr93.9%
Final simplification93.9%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (- -1.5 (* (* (* w r) (* w r)) 0.25))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (((w * r) * (w * r)) * 0.25));
}
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) - (((w * r) * (w * r)) * 0.25d0))
end function
public static double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (((w * r) * (w * r)) * 0.25));
}
def code(v, w, r): return ((2.0 / r) / r) + (-1.5 - (((w * r) * (w * r)) * 0.25))
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(Float64(Float64(w * r) * Float64(w * r)) * 0.25))) end
function tmp = code(v, w, r) tmp = ((2.0 / r) / r) + (-1.5 - (((w * r) * (w * r)) * 0.25)); end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 - \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right) \cdot 0.25\right)
\end{array}
Initial program 84.4%
Simplified88.4%
Taylor expanded in v around inf 81.1%
*-commutative81.1%
*-commutative81.1%
unpow281.1%
unpow281.1%
swap-sqr93.9%
unpow293.9%
*-commutative93.9%
Simplified93.9%
unpow293.9%
Applied egg-rr93.9%
associate-/r*93.9%
div-inv93.8%
Applied egg-rr93.8%
associate-*r/93.9%
*-rgt-identity93.9%
Simplified93.9%
Final simplification93.9%
(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 84.4%
Simplified88.4%
Taylor expanded in v around inf 81.1%
*-commutative81.1%
*-commutative81.1%
unpow281.1%
unpow281.1%
swap-sqr93.9%
unpow293.9%
*-commutative93.9%
Simplified93.9%
unpow293.9%
Applied egg-rr93.9%
Taylor expanded in r around 0 56.6%
Final simplification56.6%
(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(Float64(2.0 / 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[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + -1.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + -1.5
\end{array}
Initial program 84.4%
Simplified88.4%
Taylor expanded in v around inf 81.1%
*-commutative81.1%
*-commutative81.1%
unpow281.1%
unpow281.1%
swap-sqr93.9%
unpow293.9%
*-commutative93.9%
Simplified93.9%
unpow293.9%
Applied egg-rr93.9%
Taylor expanded in r around 0 56.6%
associate-/r*93.9%
div-inv93.8%
Applied egg-rr56.6%
associate-*r/93.9%
*-rgt-identity93.9%
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 84.4%
Simplified83.8%
Taylor expanded in r around 0 56.6%
Taylor expanded in r around inf 12.1%
Final simplification12.1%
herbie shell --seed 2024040
(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))