
(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 9 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) (- -1.5 (/ r (/ 4.0 (* w (* r w)))))))
(t_1 (/ 2.0 (* r r))))
(if (<= v -2e-13)
t_0
(if (<= v 7e-65)
(+ t_1 (- -1.5 (* (* r w) (* w (* r 0.375)))))
(if (<= v 1.95e+270) t_0 (+ t_1 -1.5))))))
double code(double v, double w, double r) {
double t_0 = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w)))));
double t_1 = 2.0 / (r * r);
double tmp;
if (v <= -2e-13) {
tmp = t_0;
} else if (v <= 7e-65) {
tmp = t_1 + (-1.5 - ((r * w) * (w * (r * 0.375))));
} else if (v <= 1.95e+270) {
tmp = t_0;
} else {
tmp = t_1 + -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) :: t_1
real(8) :: tmp
t_0 = ((2.0d0 / r) / r) + ((-1.5d0) - (r / (4.0d0 / (w * (r * w)))))
t_1 = 2.0d0 / (r * r)
if (v <= (-2d-13)) then
tmp = t_0
else if (v <= 7d-65) then
tmp = t_1 + ((-1.5d0) - ((r * w) * (w * (r * 0.375d0))))
else if (v <= 1.95d+270) then
tmp = t_0
else
tmp = t_1 + (-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) + (-1.5 - (r / (4.0 / (w * (r * w)))));
double t_1 = 2.0 / (r * r);
double tmp;
if (v <= -2e-13) {
tmp = t_0;
} else if (v <= 7e-65) {
tmp = t_1 + (-1.5 - ((r * w) * (w * (r * 0.375))));
} else if (v <= 1.95e+270) {
tmp = t_0;
} else {
tmp = t_1 + -1.5;
}
return tmp;
}
def code(v, w, r): t_0 = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w))))) t_1 = 2.0 / (r * r) tmp = 0 if v <= -2e-13: tmp = t_0 elif v <= 7e-65: tmp = t_1 + (-1.5 - ((r * w) * (w * (r * 0.375)))) elif v <= 1.95e+270: tmp = t_0 else: tmp = t_1 + -1.5 return tmp
function code(v, w, r) t_0 = Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(r / Float64(4.0 / Float64(w * Float64(r * w)))))) t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (v <= -2e-13) tmp = t_0; elseif (v <= 7e-65) tmp = Float64(t_1 + Float64(-1.5 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.375))))); elseif (v <= 1.95e+270) tmp = t_0; else tmp = Float64(t_1 + -1.5); end return tmp end
function tmp_2 = code(v, w, r) t_0 = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w))))); t_1 = 2.0 / (r * r); tmp = 0.0; if (v <= -2e-13) tmp = t_0; elseif (v <= 7e-65) tmp = t_1 + (-1.5 - ((r * w) * (w * (r * 0.375)))); elseif (v <= 1.95e+270) tmp = t_0; else tmp = t_1 + -1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(r / N[(4.0 / N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -2e-13], t$95$0, If[LessEqual[v, 7e-65], N[(t$95$1 + N[(-1.5 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 1.95e+270], t$95$0, N[(t$95$1 + -1.5), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{2}{r}}{r} + \left(-1.5 - \frac{r}{\frac{4}{w \cdot \left(r \cdot w\right)}}\right)\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2 \cdot 10^{-13}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;v \leq 7 \cdot 10^{-65}:\\
\;\;\;\;t_1 + \left(-1.5 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\\
\mathbf{elif}\;v \leq 1.95 \cdot 10^{+270}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1 + -1.5\\
\end{array}
\end{array}
if v < -2.0000000000000001e-13 or 7.00000000000000009e-65 < v < 1.95e270Initial program 85.2%
associate--l-85.2%
+-commutative85.2%
associate--l+85.2%
+-commutative85.2%
associate--r+85.2%
metadata-eval85.2%
associate-*r*84.5%
*-commutative84.5%
associate-/l*86.5%
*-commutative86.5%
Simplified86.5%
Taylor expanded in v around inf 89.9%
unpow289.9%
*-commutative89.9%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/l*99.8%
Simplified99.8%
inv-pow99.8%
associate-/r/99.7%
unpow-prod-down99.8%
inv-pow99.8%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
un-div-inv99.8%
Applied egg-rr99.8%
if -2.0000000000000001e-13 < v < 7.00000000000000009e-65Initial program 84.7%
associate--l-84.7%
+-commutative84.7%
associate--l+84.7%
+-commutative84.7%
associate--r+84.7%
metadata-eval84.7%
associate-*r*84.7%
*-commutative84.7%
associate-/l*84.6%
*-commutative84.6%
Simplified84.6%
Taylor expanded in v around 0 84.6%
unpow284.6%
*-commutative84.6%
associate-*l*95.2%
*-commutative95.2%
Simplified95.2%
associate-/r/95.2%
*-commutative95.2%
associate-*r*99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
if 1.95e270 < v Initial program 66.7%
associate--l-66.7%
+-commutative66.7%
associate--l+66.7%
+-commutative66.7%
associate--r+66.7%
metadata-eval66.7%
associate-*r*66.7%
*-commutative66.7%
associate-/l*66.7%
*-commutative66.7%
Simplified66.7%
Taylor expanded in v around 0 66.7%
unpow266.7%
*-commutative66.7%
associate-*l*88.9%
*-commutative88.9%
Simplified88.9%
associate-/r/88.9%
*-commutative88.9%
associate-*r*100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in r around 0 100.0%
sub-neg100.0%
metadata-eval100.0%
unpow2100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (- (+ 3.0 (/ 2.0 (* r r))) (/ 0.125 (/ (/ (- 1.0 v) (* (* r w) (* r w))) (fma -2.0 v 3.0)))) -4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (0.125 / (((1.0 - v) / ((r * w) * (r * w))) / fma(-2.0, v, 3.0)))) + -4.5;
}
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(0.125 / Float64(Float64(Float64(1.0 - v) / Float64(Float64(r * w) * Float64(r * w))) / fma(-2.0, v, 3.0)))) + -4.5) end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.125 / N[(N[(N[(1.0 - v), $MachinePrecision] / N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-2.0 * v + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{0.125}{\frac{\frac{1 - v}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}{\mathsf{fma}\left(-2, v, 3\right)}}\right) + -4.5
\end{array}
Initial program 84.3%
Simplified83.3%
*-un-lft-identity83.3%
add-sqr-sqrt83.2%
times-frac83.2%
unswap-sqr83.2%
sqrt-prod50.4%
add-sqr-sqrt64.1%
unswap-sqr78.8%
sqrt-prod58.0%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
*-un-lft-identity99.7%
associate-/l*99.7%
frac-times99.7%
*-un-lft-identity99.7%
+-commutative99.7%
fma-def99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 1.0 (* r w))) (t_1 (+ 3.0 (/ 2.0 (* r r)))))
(if (<= v -2.5e-13)
(+ (/ (/ 2.0 r) r) (- -1.5 (/ r (/ 4.0 (* w (* r w))))))
(if (<= v 1.6e-63)
(+ -4.5 (- t_1 (/ (* 0.125 (+ 3.0 (* v -2.0))) (* t_0 t_0))))
(+ -4.5 (- t_1 (* (* (* r w) (* r w)) 0.25)))))))
double code(double v, double w, double r) {
double t_0 = 1.0 / (r * w);
double t_1 = 3.0 + (2.0 / (r * r));
double tmp;
if (v <= -2.5e-13) {
tmp = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w)))));
} else if (v <= 1.6e-63) {
tmp = -4.5 + (t_1 - ((0.125 * (3.0 + (v * -2.0))) / (t_0 * t_0)));
} else {
tmp = -4.5 + (t_1 - (((r * w) * (r * w)) * 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 / (r * w)
t_1 = 3.0d0 + (2.0d0 / (r * r))
if (v <= (-2.5d-13)) then
tmp = ((2.0d0 / r) / r) + ((-1.5d0) - (r / (4.0d0 / (w * (r * w)))))
else if (v <= 1.6d-63) then
tmp = (-4.5d0) + (t_1 - ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) / (t_0 * t_0)))
else
tmp = (-4.5d0) + (t_1 - (((r * w) * (r * w)) * 0.25d0))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 1.0 / (r * w);
double t_1 = 3.0 + (2.0 / (r * r));
double tmp;
if (v <= -2.5e-13) {
tmp = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w)))));
} else if (v <= 1.6e-63) {
tmp = -4.5 + (t_1 - ((0.125 * (3.0 + (v * -2.0))) / (t_0 * t_0)));
} else {
tmp = -4.5 + (t_1 - (((r * w) * (r * w)) * 0.25));
}
return tmp;
}
def code(v, w, r): t_0 = 1.0 / (r * w) t_1 = 3.0 + (2.0 / (r * r)) tmp = 0 if v <= -2.5e-13: tmp = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w))))) elif v <= 1.6e-63: tmp = -4.5 + (t_1 - ((0.125 * (3.0 + (v * -2.0))) / (t_0 * t_0))) else: tmp = -4.5 + (t_1 - (((r * w) * (r * w)) * 0.25)) return tmp
function code(v, w, r) t_0 = Float64(1.0 / Float64(r * w)) t_1 = Float64(3.0 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if (v <= -2.5e-13) tmp = Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(r / Float64(4.0 / Float64(w * Float64(r * w)))))); elseif (v <= 1.6e-63) tmp = Float64(-4.5 + Float64(t_1 - Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) / Float64(t_0 * t_0)))); else tmp = Float64(-4.5 + Float64(t_1 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 1.0 / (r * w); t_1 = 3.0 + (2.0 / (r * r)); tmp = 0.0; if (v <= -2.5e-13) tmp = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w))))); elseif (v <= 1.6e-63) tmp = -4.5 + (t_1 - ((0.125 * (3.0 + (v * -2.0))) / (t_0 * t_0))); else tmp = -4.5 + (t_1 - (((r * w) * (r * w)) * 0.25)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -2.5e-13], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(r / N[(4.0 / N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 1.6e-63], N[(-4.5 + N[(t$95$1 - N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(t$95$1 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{r \cdot w}\\
t_1 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2.5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + \left(-1.5 - \frac{r}{\frac{4}{w \cdot \left(r \cdot w\right)}}\right)\\
\mathbf{elif}\;v \leq 1.6 \cdot 10^{-63}:\\
\;\;\;\;-4.5 + \left(t_1 - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{t_0 \cdot t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(t_1 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\end{array}
\end{array}
if v < -2.49999999999999995e-13Initial program 85.7%
associate--l-85.7%
+-commutative85.7%
associate--l+85.7%
+-commutative85.7%
associate--r+85.7%
metadata-eval85.7%
associate-*r*84.3%
*-commutative84.3%
associate-/l*87.0%
*-commutative87.0%
Simplified87.0%
Taylor expanded in v around inf 94.0%
unpow294.0%
*-commutative94.0%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/l*99.7%
Simplified99.7%
inv-pow99.7%
associate-/r/99.7%
unpow-prod-down99.7%
inv-pow99.7%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
un-div-inv99.8%
Applied egg-rr99.8%
if -2.49999999999999995e-13 < v < 1.59999999999999994e-63Initial program 84.7%
Simplified81.7%
*-un-lft-identity81.7%
add-sqr-sqrt81.6%
times-frac81.6%
unswap-sqr81.7%
sqrt-prod52.9%
add-sqr-sqrt62.2%
unswap-sqr78.6%
sqrt-prod62.7%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
Taylor expanded in v around 0 99.7%
if 1.59999999999999994e-63 < v Initial program 82.7%
Simplified81.2%
Taylor expanded in v around inf 81.2%
*-commutative81.2%
unpow281.2%
unpow281.2%
*-commutative81.2%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(+
-4.5
(-
(+ 3.0 (/ 2.0 (* r r)))
(/
(* 0.125 (+ 3.0 (* v -2.0)))
(* (/ 1.0 (* r w)) (/ (- 1.0 v) (* 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 / (r * w)) * ((1.0 - v) / (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 / (r * w)) * ((1.0d0 - v) / (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 / (r * w)) * ((1.0 - v) / (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 / (r * w)) * ((1.0 - v) / (r * w)))))
function code(v, w, r) return Float64(-4.5 + Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) / Float64(Float64(1.0 / Float64(r * w)) * Float64(Float64(1.0 - v) / 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 / (r * w)) * ((1.0 - v) / (r * w))))); end
code[v_, w_, r_] := N[(-4.5 + N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4.5 + \left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{\frac{1}{r \cdot w} \cdot \frac{1 - v}{r \cdot w}}\right)
\end{array}
Initial program 84.3%
Simplified83.3%
*-un-lft-identity83.3%
add-sqr-sqrt83.2%
times-frac83.2%
unswap-sqr83.2%
sqrt-prod50.4%
add-sqr-sqrt64.1%
unswap-sqr78.8%
sqrt-prod58.0%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -4.5e+69) (and (not (<= v 5e-66)) (<= v 1.2e+187)))
(+ t_0 (- -1.5 (* (/ r 4.0) (* w (* r w)))))
(+ t_0 (- -1.5 (* (* 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 <= -4.5e+69) || (!(v <= 5e-66) && (v <= 1.2e+187))) {
tmp = t_0 + (-1.5 - ((r / 4.0) * (w * (r * w))));
} else {
tmp = t_0 + (-1.5 - ((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 <= (-4.5d+69)) .or. (.not. (v <= 5d-66)) .and. (v <= 1.2d+187)) then
tmp = t_0 + ((-1.5d0) - ((r / 4.0d0) * (w * (r * w))))
else
tmp = t_0 + ((-1.5d0) - ((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 <= -4.5e+69) || (!(v <= 5e-66) && (v <= 1.2e+187))) {
tmp = t_0 + (-1.5 - ((r / 4.0) * (w * (r * w))));
} else {
tmp = t_0 + (-1.5 - ((r * w) * (w * (r * 0.375))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -4.5e+69) or (not (v <= 5e-66) and (v <= 1.2e+187)): tmp = t_0 + (-1.5 - ((r / 4.0) * (w * (r * w)))) else: tmp = t_0 + (-1.5 - ((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 <= -4.5e+69) || (!(v <= 5e-66) && (v <= 1.2e+187))) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(r / 4.0) * Float64(w * Float64(r * w))))); else tmp = Float64(t_0 + Float64(-1.5 - 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 <= -4.5e+69) || (~((v <= 5e-66)) && (v <= 1.2e+187))) tmp = t_0 + (-1.5 - ((r / 4.0) * (w * (r * w)))); else tmp = t_0 + (-1.5 - ((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, -4.5e+69], And[N[Not[LessEqual[v, 5e-66]], $MachinePrecision], LessEqual[v, 1.2e+187]]], N[(t$95$0 + N[(-1.5 - N[(N[(r / 4.0), $MachinePrecision] * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -4.5 \cdot 10^{+69} \lor \neg \left(v \leq 5 \cdot 10^{-66}\right) \land v \leq 1.2 \cdot 10^{+187}:\\
\;\;\;\;t_0 + \left(-1.5 - \frac{r}{4} \cdot \left(w \cdot \left(r \cdot w\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\\
\end{array}
\end{array}
if v < -4.4999999999999999e69 or 4.99999999999999962e-66 < v < 1.19999999999999993e187Initial program 82.1%
associate--l-82.1%
+-commutative82.1%
associate--l+82.1%
+-commutative82.1%
associate--r+82.1%
metadata-eval82.1%
associate-*r*81.1%
*-commutative81.1%
associate-/l*84.0%
*-commutative84.0%
Simplified84.0%
Taylor expanded in v around inf 88.9%
unpow288.9%
*-commutative88.9%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
associate-/r/99.8%
*-commutative99.8%
Applied egg-rr99.8%
if -4.4999999999999999e69 < v < 4.99999999999999962e-66 or 1.19999999999999993e187 < v Initial program 85.7%
associate--l-85.7%
+-commutative85.7%
associate--l+85.7%
+-commutative85.7%
associate--r+85.7%
metadata-eval85.7%
associate-*r*85.7%
*-commutative85.7%
associate-/l*85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in v around 0 85.6%
unpow285.6%
*-commutative85.6%
associate-*l*96.0%
*-commutative96.0%
Simplified96.0%
associate-/r/96.0%
*-commutative96.0%
associate-*r*99.7%
div-inv99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= v -8e-14)
(+ (/ (/ 2.0 r) r) (- -1.5 (/ r (/ 4.0 (* w (* r w))))))
(if (<= v 1.65e-63)
(+ t_0 (- -1.5 (* (* r w) (* w (* r 0.375)))))
(+ -4.5 (- (+ 3.0 t_0) (* (* (* r w) (* r w)) 0.25)))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (v <= -8e-14) {
tmp = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w)))));
} else if (v <= 1.65e-63) {
tmp = t_0 + (-1.5 - ((r * w) * (w * (r * 0.375))));
} else {
tmp = -4.5 + ((3.0 + t_0) - (((r * w) * (r * w)) * 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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if (v <= (-8d-14)) then
tmp = ((2.0d0 / r) / r) + ((-1.5d0) - (r / (4.0d0 / (w * (r * w)))))
else if (v <= 1.65d-63) then
tmp = t_0 + ((-1.5d0) - ((r * w) * (w * (r * 0.375d0))))
else
tmp = (-4.5d0) + ((3.0d0 + t_0) - (((r * w) * (r * w)) * 0.25d0))
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 <= -8e-14) {
tmp = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w)))));
} else if (v <= 1.65e-63) {
tmp = t_0 + (-1.5 - ((r * w) * (w * (r * 0.375))));
} else {
tmp = -4.5 + ((3.0 + t_0) - (((r * w) * (r * w)) * 0.25));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if v <= -8e-14: tmp = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w))))) elif v <= 1.65e-63: tmp = t_0 + (-1.5 - ((r * w) * (w * (r * 0.375)))) else: tmp = -4.5 + ((3.0 + t_0) - (((r * w) * (r * w)) * 0.25)) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (v <= -8e-14) tmp = Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(r / Float64(4.0 / Float64(w * Float64(r * w)))))); elseif (v <= 1.65e-63) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.375))))); else tmp = Float64(-4.5 + Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (v <= -8e-14) tmp = ((2.0 / r) / r) + (-1.5 - (r / (4.0 / (w * (r * w))))); elseif (v <= 1.65e-63) tmp = t_0 + (-1.5 - ((r * w) * (w * (r * 0.375)))); else tmp = -4.5 + ((3.0 + t_0) - (((r * w) * (r * w)) * 0.25)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -8e-14], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(r / N[(4.0 / N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 1.65e-63], N[(t$95$0 + N[(-1.5 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -8 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + \left(-1.5 - \frac{r}{\frac{4}{w \cdot \left(r \cdot w\right)}}\right)\\
\mathbf{elif}\;v \leq 1.65 \cdot 10^{-63}:\\
\;\;\;\;t_0 + \left(-1.5 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(\left(3 + t_0\right) - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\end{array}
\end{array}
if v < -7.99999999999999999e-14Initial program 85.7%
associate--l-85.7%
+-commutative85.7%
associate--l+85.7%
+-commutative85.7%
associate--r+85.7%
metadata-eval85.7%
associate-*r*84.3%
*-commutative84.3%
associate-/l*87.0%
*-commutative87.0%
Simplified87.0%
Taylor expanded in v around inf 94.0%
unpow294.0%
*-commutative94.0%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/l*99.7%
Simplified99.7%
inv-pow99.7%
associate-/r/99.7%
unpow-prod-down99.7%
inv-pow99.7%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
un-div-inv99.8%
Applied egg-rr99.8%
if -7.99999999999999999e-14 < v < 1.64999999999999997e-63Initial program 84.7%
associate--l-84.7%
+-commutative84.7%
associate--l+84.7%
+-commutative84.7%
associate--r+84.7%
metadata-eval84.7%
associate-*r*84.7%
*-commutative84.7%
associate-/l*84.6%
*-commutative84.6%
Simplified84.6%
Taylor expanded in v around 0 84.6%
unpow284.6%
*-commutative84.6%
associate-*l*95.2%
*-commutative95.2%
Simplified95.2%
associate-/r/95.2%
*-commutative95.2%
associate-*r*99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
if 1.64999999999999997e-63 < v Initial program 82.7%
Simplified81.2%
Taylor expanded in v around inf 81.2%
*-commutative81.2%
unpow281.2%
unpow281.2%
*-commutative81.2%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* (* r w) (* w (* r 0.375))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - ((r * w) * (w * (r * 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) * (w * (r * 0.375d0))))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - ((r * w) * (w * (r * 0.375))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - ((r * w) * (w * (r * 0.375))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.375))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - ((r * w) * (w * (r * 0.375)))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)
\end{array}
Initial program 84.3%
associate--l-84.3%
+-commutative84.3%
associate--l+84.3%
+-commutative84.3%
associate--r+84.3%
metadata-eval84.3%
associate-*r*83.9%
*-commutative83.9%
associate-/l*85.0%
*-commutative85.0%
Simplified85.0%
Taylor expanded in v around 0 83.2%
unpow283.2%
*-commutative83.2%
associate-*l*92.6%
*-commutative92.6%
Simplified92.6%
associate-/r/92.6%
*-commutative92.6%
associate-*r*94.9%
div-inv94.9%
metadata-eval94.9%
Applied egg-rr94.9%
Final simplification94.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.3%
associate--l-84.3%
+-commutative84.3%
associate--l+84.3%
+-commutative84.3%
associate--r+84.3%
metadata-eval84.3%
associate-*r*83.9%
*-commutative83.9%
associate-/l*85.0%
*-commutative85.0%
Simplified85.0%
Taylor expanded in v around 0 83.2%
unpow283.2%
*-commutative83.2%
associate-*l*92.6%
*-commutative92.6%
Simplified92.6%
associate-/r/92.6%
*-commutative92.6%
associate-*r*94.9%
div-inv94.9%
metadata-eval94.9%
Applied egg-rr94.9%
Taylor expanded in r around 0 56.6%
sub-neg56.6%
metadata-eval56.6%
unpow256.6%
associate-*r/56.6%
metadata-eval56.6%
Simplified56.6%
Final simplification56.6%
(FPCore (v w r) :precision binary64 (/ 2.0 (* r r)))
double code(double v, double w, double r) {
return 2.0 / (r * r);
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = 2.0d0 / (r * r)
end function
public static double code(double v, double w, double r) {
return 2.0 / (r * r);
}
def code(v, w, r): return 2.0 / (r * r)
function code(v, w, r) return Float64(2.0 / Float64(r * r)) end
function tmp = code(v, w, r) tmp = 2.0 / (r * r); end
code[v_, w_, r_] := N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r}
\end{array}
Initial program 84.3%
associate--l-84.3%
+-commutative84.3%
associate--l+84.3%
+-commutative84.3%
associate--r+84.3%
metadata-eval84.3%
associate-*r*83.9%
*-commutative83.9%
associate-/l*85.0%
*-commutative85.0%
Simplified85.0%
Taylor expanded in v around 0 83.2%
unpow283.2%
*-commutative83.2%
associate-*l*92.6%
*-commutative92.6%
Simplified92.6%
associate-/r/92.6%
*-commutative92.6%
associate-*r*94.9%
div-inv94.9%
metadata-eval94.9%
Applied egg-rr94.9%
Taylor expanded in r around 0 47.8%
unpow247.8%
Simplified47.8%
Final simplification47.8%
herbie shell --seed 2023279
(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))