
(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 (/ 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))) * ((r * w) * (w * (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))) * ((r * w) * (w * (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))) * ((r * w) * (w * (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))) * ((r * w) * (w * (r / (1.0 - v))))) + 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(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))) * ((r * w) * (w * (r / (1.0 - v))))) + 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[(r / N[(1.0 - v), $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(\left(r \cdot w\right) \cdot \left(w \cdot \frac{r}{1 - v}\right)\right) + 4.5\right)
\end{array}
Initial program 82.1%
associate--l-82.1%
associate-*l*78.1%
sqr-neg78.1%
associate-*l*82.1%
associate-/l*86.8%
fma-define86.8%
Simplified86.8%
associate-/l*85.9%
*-commutative85.9%
associate-*r/85.5%
associate-*l*95.7%
associate-*r*99.4%
Applied egg-rr99.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* 0.125 (+ 3.0 (* -2.0 v)))) (t_1 (+ 3.0 (/ 2.0 (* r r)))))
(if (<= v -1.85e+18)
(+ t_1 (- (* t_0 (* w (* r (* w (/ r v))))) 4.5))
(if (<= v 3.15e-40)
(- t_1 (+ (* t_0 (* (* r w) (* r w))) 4.5))
(+ t_1 (- (* t_0 (* (* r w) (/ (* r w) v))) 4.5))))))
double code(double v, double w, double r) {
double t_0 = 0.125 * (3.0 + (-2.0 * v));
double t_1 = 3.0 + (2.0 / (r * r));
double tmp;
if (v <= -1.85e+18) {
tmp = t_1 + ((t_0 * (w * (r * (w * (r / v))))) - 4.5);
} else if (v <= 3.15e-40) {
tmp = t_1 - ((t_0 * ((r * w) * (r * w))) + 4.5);
} else {
tmp = t_1 + ((t_0 * ((r * w) * ((r * w) / v))) - 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) :: t_1
real(8) :: tmp
t_0 = 0.125d0 * (3.0d0 + ((-2.0d0) * v))
t_1 = 3.0d0 + (2.0d0 / (r * r))
if (v <= (-1.85d+18)) then
tmp = t_1 + ((t_0 * (w * (r * (w * (r / v))))) - 4.5d0)
else if (v <= 3.15d-40) then
tmp = t_1 - ((t_0 * ((r * w) * (r * w))) + 4.5d0)
else
tmp = t_1 + ((t_0 * ((r * w) * ((r * w) / v))) - 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 0.125 * (3.0 + (-2.0 * v));
double t_1 = 3.0 + (2.0 / (r * r));
double tmp;
if (v <= -1.85e+18) {
tmp = t_1 + ((t_0 * (w * (r * (w * (r / v))))) - 4.5);
} else if (v <= 3.15e-40) {
tmp = t_1 - ((t_0 * ((r * w) * (r * w))) + 4.5);
} else {
tmp = t_1 + ((t_0 * ((r * w) * ((r * w) / v))) - 4.5);
}
return tmp;
}
def code(v, w, r): t_0 = 0.125 * (3.0 + (-2.0 * v)) t_1 = 3.0 + (2.0 / (r * r)) tmp = 0 if v <= -1.85e+18: tmp = t_1 + ((t_0 * (w * (r * (w * (r / v))))) - 4.5) elif v <= 3.15e-40: tmp = t_1 - ((t_0 * ((r * w) * (r * w))) + 4.5) else: tmp = t_1 + ((t_0 * ((r * w) * ((r * w) / v))) - 4.5) return tmp
function code(v, w, r) t_0 = Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) t_1 = Float64(3.0 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if (v <= -1.85e+18) tmp = Float64(t_1 + Float64(Float64(t_0 * Float64(w * Float64(r * Float64(w * Float64(r / v))))) - 4.5)); elseif (v <= 3.15e-40) tmp = Float64(t_1 - Float64(Float64(t_0 * Float64(Float64(r * w) * Float64(r * w))) + 4.5)); else tmp = Float64(t_1 + Float64(Float64(t_0 * Float64(Float64(r * w) * Float64(Float64(r * w) / v))) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 0.125 * (3.0 + (-2.0 * v)); t_1 = 3.0 + (2.0 / (r * r)); tmp = 0.0; if (v <= -1.85e+18) tmp = t_1 + ((t_0 * (w * (r * (w * (r / v))))) - 4.5); elseif (v <= 3.15e-40) tmp = t_1 - ((t_0 * ((r * w) * (r * w))) + 4.5); else tmp = t_1 + ((t_0 * ((r * w) * ((r * w) / v))) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1.85e+18], N[(t$95$1 + N[(N[(t$95$0 * N[(w * N[(r * N[(w * N[(r / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 3.15e-40], N[(t$95$1 - N[(N[(t$95$0 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(t$95$0 * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.125 \cdot \left(3 + -2 \cdot v\right)\\
t_1 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.85 \cdot 10^{+18}:\\
\;\;\;\;t\_1 + \left(t\_0 \cdot \left(w \cdot \left(r \cdot \left(w \cdot \frac{r}{v}\right)\right)\right) - 4.5\right)\\
\mathbf{elif}\;v \leq 3.15 \cdot 10^{-40}:\\
\;\;\;\;t\_1 - \left(t\_0 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) + 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \left(t\_0 \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v}\right) - 4.5\right)\\
\end{array}
\end{array}
if v < -1.85e18Initial program 85.8%
associate--l-85.8%
associate-*l*82.0%
sqr-neg82.0%
associate-*l*85.8%
associate-/l*89.8%
fma-define89.8%
Simplified89.8%
associate-/l*89.9%
*-commutative89.9%
associate-*r/89.9%
*-commutative89.9%
associate-*l*97.4%
associate-*l*99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.8%
associate-*r/99.8%
neg-mul-199.8%
Simplified99.8%
if -1.85e18 < v < 3.1500000000000001e-40Initial program 85.6%
associate--l-85.6%
associate-*l*82.5%
sqr-neg82.5%
associate-*l*85.6%
associate-/l*85.6%
fma-define85.6%
Simplified85.6%
associate-/l*85.6%
*-commutative85.6%
associate-*r/85.6%
associate-*l*96.8%
associate-*r*99.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 98.8%
if 3.1500000000000001e-40 < v Initial program 73.8%
associate--l-73.8%
associate-*l*68.1%
sqr-neg68.1%
associate-*l*73.8%
associate-/l*86.6%
fma-define86.6%
Simplified86.6%
associate-/l*83.5%
*-commutative83.5%
associate-*r/82.2%
associate-*l*92.7%
associate-*r*98.4%
Applied egg-rr98.4%
Taylor expanded in v around inf 99.7%
associate-*r/99.7%
mul-1-neg99.7%
Simplified99.7%
Final simplification99.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 4.2e-92)
(- (+ 3.0 t_0) 4.5)
(if (<= r 1450.0)
(+ t_0 (+ -1.5 (* (* v -0.25) (* r (* (* w w) (/ r v))))))
(+
3.0
(-
(* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (* w (/ r (- v 1.0)))))
4.5))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 4.2e-92) {
tmp = (3.0 + t_0) - 4.5;
} else if (r <= 1450.0) {
tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / v)))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (v - 1.0))))) - 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 = 2.0d0 / (r * r)
if (r <= 4.2d-92) then
tmp = (3.0d0 + t_0) - 4.5d0
else if (r <= 1450.0d0) then
tmp = t_0 + ((-1.5d0) + ((v * (-0.25d0)) * (r * ((w * w) * (r / v)))))
else
tmp = 3.0d0 + (((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * ((r * w) * (w * (r / (v - 1.0d0))))) - 4.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 (r <= 4.2e-92) {
tmp = (3.0 + t_0) - 4.5;
} else if (r <= 1450.0) {
tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / v)))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (v - 1.0))))) - 4.5);
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 4.2e-92: tmp = (3.0 + t_0) - 4.5 elif r <= 1450.0: tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / v))))) else: tmp = 3.0 + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (v - 1.0))))) - 4.5) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 4.2e-92) tmp = Float64(Float64(3.0 + t_0) - 4.5); elseif (r <= 1450.0) tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(v * -0.25) * Float64(r * Float64(Float64(w * w) * Float64(r / v)))))); else tmp = Float64(3.0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(r * w) * Float64(w * Float64(r / Float64(v - 1.0))))) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 4.2e-92) tmp = (3.0 + t_0) - 4.5; elseif (r <= 1450.0) tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / v))))); else tmp = 3.0 + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (v - 1.0))))) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 4.2e-92], N[(N[(3.0 + t$95$0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 1450.0], N[(t$95$0 + N[(-1.5 + N[(N[(v * -0.25), $MachinePrecision] * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 + N[(N[(N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(w * N[(r / N[(v - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 4.2 \cdot 10^{-92}:\\
\;\;\;\;\left(3 + t\_0\right) - 4.5\\
\mathbf{elif}\;r \leq 1450:\\
\;\;\;\;t\_0 + \left(-1.5 + \left(v \cdot -0.25\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \left(w \cdot \frac{r}{v - 1}\right)\right) - 4.5\right)\\
\end{array}
\end{array}
if r < 4.2e-92Initial program 82.5%
Simplified77.6%
Taylor expanded in r around 0 68.6%
if 4.2e-92 < r < 1450Initial program 87.7%
Simplified87.7%
Taylor expanded in v around inf 87.7%
*-commutative87.7%
Simplified87.7%
Taylor expanded in v around inf 87.7%
associate-*r/99.3%
neg-mul-199.3%
Simplified87.7%
if 1450 < r Initial program 79.7%
associate--l-79.7%
associate-*l*75.0%
sqr-neg75.0%
associate-*l*79.7%
associate-/l*92.2%
fma-define92.3%
Simplified92.2%
associate-/l*91.5%
*-commutative91.5%
associate-*r/91.5%
associate-*l*96.8%
associate-*r*99.7%
Applied egg-rr99.7%
Taylor expanded in r around inf 99.7%
Final simplification77.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* 0.125 (+ 3.0 (* -2.0 v)))))
(if (<= r 600.0)
(+ (+ 3.0 (/ 2.0 (* r r))) (- (* t_0 (* w (* r (* w (/ r v))))) 4.5))
(+ 3.0 (- (* t_0 (* (* r w) (* w (/ r (- v 1.0))))) 4.5)))))
double code(double v, double w, double r) {
double t_0 = 0.125 * (3.0 + (-2.0 * v));
double tmp;
if (r <= 600.0) {
tmp = (3.0 + (2.0 / (r * r))) + ((t_0 * (w * (r * (w * (r / v))))) - 4.5);
} else {
tmp = 3.0 + ((t_0 * ((r * w) * (w * (r / (v - 1.0))))) - 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 = 0.125d0 * (3.0d0 + ((-2.0d0) * v))
if (r <= 600.0d0) then
tmp = (3.0d0 + (2.0d0 / (r * r))) + ((t_0 * (w * (r * (w * (r / v))))) - 4.5d0)
else
tmp = 3.0d0 + ((t_0 * ((r * w) * (w * (r / (v - 1.0d0))))) - 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 0.125 * (3.0 + (-2.0 * v));
double tmp;
if (r <= 600.0) {
tmp = (3.0 + (2.0 / (r * r))) + ((t_0 * (w * (r * (w * (r / v))))) - 4.5);
} else {
tmp = 3.0 + ((t_0 * ((r * w) * (w * (r / (v - 1.0))))) - 4.5);
}
return tmp;
}
def code(v, w, r): t_0 = 0.125 * (3.0 + (-2.0 * v)) tmp = 0 if r <= 600.0: tmp = (3.0 + (2.0 / (r * r))) + ((t_0 * (w * (r * (w * (r / v))))) - 4.5) else: tmp = 3.0 + ((t_0 * ((r * w) * (w * (r / (v - 1.0))))) - 4.5) return tmp
function code(v, w, r) t_0 = Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) tmp = 0.0 if (r <= 600.0) tmp = Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(t_0 * Float64(w * Float64(r * Float64(w * Float64(r / v))))) - 4.5)); else tmp = Float64(3.0 + Float64(Float64(t_0 * Float64(Float64(r * w) * Float64(w * Float64(r / Float64(v - 1.0))))) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 0.125 * (3.0 + (-2.0 * v)); tmp = 0.0; if (r <= 600.0) tmp = (3.0 + (2.0 / (r * r))) + ((t_0 * (w * (r * (w * (r / v))))) - 4.5); else tmp = 3.0 + ((t_0 * ((r * w) * (w * (r / (v - 1.0))))) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 600.0], N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * N[(w * N[(r * N[(w * N[(r / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision], N[(3.0 + N[(N[(t$95$0 * N[(N[(r * w), $MachinePrecision] * N[(w * N[(r / N[(v - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.125 \cdot \left(3 + -2 \cdot v\right)\\
\mathbf{if}\;r \leq 600:\\
\;\;\;\;\left(3 + \frac{2}{r \cdot r}\right) + \left(t\_0 \cdot \left(w \cdot \left(r \cdot \left(w \cdot \frac{r}{v}\right)\right)\right) - 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;3 + \left(t\_0 \cdot \left(\left(r \cdot w\right) \cdot \left(w \cdot \frac{r}{v - 1}\right)\right) - 4.5\right)\\
\end{array}
\end{array}
if r < 600Initial program 83.0%
associate--l-83.0%
associate-*l*79.2%
sqr-neg79.2%
associate-*l*83.0%
associate-/l*84.9%
fma-define84.9%
Simplified84.9%
associate-/l*83.9%
*-commutative83.9%
associate-*r/83.4%
*-commutative83.4%
associate-*l*95.3%
associate-*l*98.8%
Applied egg-rr98.8%
Taylor expanded in v around inf 85.9%
associate-*r/85.9%
neg-mul-185.9%
Simplified85.9%
if 600 < r Initial program 79.7%
associate--l-79.7%
associate-*l*75.0%
sqr-neg75.0%
associate-*l*79.7%
associate-/l*92.2%
fma-define92.3%
Simplified92.2%
associate-/l*91.5%
*-commutative91.5%
associate-*r/91.5%
associate-*l*96.8%
associate-*r*99.7%
Applied egg-rr99.7%
Taylor expanded in r around inf 99.7%
Final simplification89.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* 0.125 (+ 3.0 (* -2.0 v)))))
(if (<= r 1.65e-5)
(- (+ 3.0 (/ 2.0 (* r r))) (+ (* t_0 (* w (* r (* r w)))) 4.5))
(- 3.0 (+ (* t_0 (* (* r w) (* w (/ r (- 1.0 v))))) 4.5)))))
double code(double v, double w, double r) {
double t_0 = 0.125 * (3.0 + (-2.0 * v));
double tmp;
if (r <= 1.65e-5) {
tmp = (3.0 + (2.0 / (r * r))) - ((t_0 * (w * (r * (r * w)))) + 4.5);
} else {
tmp = 3.0 - ((t_0 * ((r * w) * (w * (r / (1.0 - v))))) + 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 = 0.125d0 * (3.0d0 + ((-2.0d0) * v))
if (r <= 1.65d-5) then
tmp = (3.0d0 + (2.0d0 / (r * r))) - ((t_0 * (w * (r * (r * w)))) + 4.5d0)
else
tmp = 3.0d0 - ((t_0 * ((r * w) * (w * (r / (1.0d0 - v))))) + 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 0.125 * (3.0 + (-2.0 * v));
double tmp;
if (r <= 1.65e-5) {
tmp = (3.0 + (2.0 / (r * r))) - ((t_0 * (w * (r * (r * w)))) + 4.5);
} else {
tmp = 3.0 - ((t_0 * ((r * w) * (w * (r / (1.0 - v))))) + 4.5);
}
return tmp;
}
def code(v, w, r): t_0 = 0.125 * (3.0 + (-2.0 * v)) tmp = 0 if r <= 1.65e-5: tmp = (3.0 + (2.0 / (r * r))) - ((t_0 * (w * (r * (r * w)))) + 4.5) else: tmp = 3.0 - ((t_0 * ((r * w) * (w * (r / (1.0 - v))))) + 4.5) return tmp
function code(v, w, r) t_0 = Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) tmp = 0.0 if (r <= 1.65e-5) tmp = Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(t_0 * Float64(w * Float64(r * Float64(r * w)))) + 4.5)); else tmp = Float64(3.0 - Float64(Float64(t_0 * Float64(Float64(r * w) * Float64(w * Float64(r / Float64(1.0 - v))))) + 4.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 0.125 * (3.0 + (-2.0 * v)); tmp = 0.0; if (r <= 1.65e-5) tmp = (3.0 + (2.0 / (r * r))) - ((t_0 * (w * (r * (r * w)))) + 4.5); else tmp = 3.0 - ((t_0 * ((r * w) * (w * (r / (1.0 - v))))) + 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 1.65e-5], N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[(w * N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(N[(t$95$0 * N[(N[(r * w), $MachinePrecision] * N[(w * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.125 \cdot \left(3 + -2 \cdot v\right)\\
\mathbf{if}\;r \leq 1.65 \cdot 10^{-5}:\\
\;\;\;\;\left(3 + \frac{2}{r \cdot r}\right) - \left(t\_0 \cdot \left(w \cdot \left(r \cdot \left(r \cdot w\right)\right)\right) + 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \left(t\_0 \cdot \left(\left(r \cdot w\right) \cdot \left(w \cdot \frac{r}{1 - v}\right)\right) + 4.5\right)\\
\end{array}
\end{array}
if r < 1.6500000000000001e-5Initial program 82.9%
associate--l-82.9%
associate-*l*79.1%
sqr-neg79.1%
associate-*l*82.9%
associate-/l*84.8%
fma-define84.8%
Simplified84.8%
associate-/l*83.9%
*-commutative83.9%
associate-*r/83.3%
*-commutative83.3%
associate-*l*95.3%
associate-*l*98.8%
Applied egg-rr98.8%
Taylor expanded in v around 0 84.3%
if 1.6500000000000001e-5 < r Initial program 80.0%
associate--l-80.0%
associate-*l*75.4%
sqr-neg75.4%
associate-*l*80.0%
associate-/l*92.3%
fma-define92.4%
Simplified92.3%
associate-/l*91.6%
*-commutative91.6%
associate-*r/91.6%
associate-*l*96.8%
associate-*r*99.7%
Applied egg-rr99.7%
Taylor expanded in r around inf 99.4%
Final simplification88.3%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) (+ (* (* 0.125 (+ 3.0 (* -2.0 v))) (* w (* r (* w (/ 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 * (r * (w * (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 * (r * (w * (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 * (r * (w * (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 * (r * (w * (r / (1.0 - v)))))) + 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(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 * (r * (w * (r / (1.0 - v)))))) + 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[(r / N[(1.0 - v), $MachinePrecision]), $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 \left(w \cdot \frac{r}{1 - v}\right)\right)\right) + 4.5\right)
\end{array}
Initial program 82.1%
associate--l-82.1%
associate-*l*78.1%
sqr-neg78.1%
associate-*l*82.1%
associate-/l*86.8%
fma-define86.8%
Simplified86.8%
associate-/l*85.9%
*-commutative85.9%
associate-*r/85.5%
*-commutative85.5%
associate-*l*95.7%
associate-*l*98.0%
Applied egg-rr98.0%
Final simplification98.0%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 5.3e-93)
(- (+ 3.0 t_0) 4.5)
(+ t_0 (+ -1.5 (* (* v -0.25) (* r (* (* w w) (/ r v)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 5.3e-93) {
tmp = (3.0 + t_0) - 4.5;
} else {
tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / v)))));
}
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 (r <= 5.3d-93) then
tmp = (3.0d0 + t_0) - 4.5d0
else
tmp = t_0 + ((-1.5d0) + ((v * (-0.25d0)) * (r * ((w * w) * (r / v)))))
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 (r <= 5.3e-93) {
tmp = (3.0 + t_0) - 4.5;
} else {
tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / v)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 5.3e-93: tmp = (3.0 + t_0) - 4.5 else: tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / v))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 5.3e-93) tmp = Float64(Float64(3.0 + t_0) - 4.5); else tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(v * -0.25) * Float64(r * Float64(Float64(w * w) * Float64(r / v)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 5.3e-93) tmp = (3.0 + t_0) - 4.5; else tmp = t_0 + (-1.5 + ((v * -0.25) * (r * ((w * w) * (r / v))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 5.3e-93], N[(N[(3.0 + t$95$0), $MachinePrecision] - 4.5), $MachinePrecision], N[(t$95$0 + N[(-1.5 + N[(N[(v * -0.25), $MachinePrecision] * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 5.3 \cdot 10^{-93}:\\
\;\;\;\;\left(3 + t\_0\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 + \left(v \cdot -0.25\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v}\right)\right)\right)\\
\end{array}
\end{array}
if r < 5.3e-93Initial program 82.5%
Simplified77.6%
Taylor expanded in r around 0 68.6%
if 5.3e-93 < r Initial program 81.3%
Simplified90.8%
Taylor expanded in v around inf 69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in v around inf 84.7%
associate-*r/74.5%
neg-mul-174.5%
Simplified84.7%
Final simplification73.8%
(FPCore (v w r) :precision binary64 (if (<= r 9.5e-6) (- (+ 3.0 (/ 2.0 (* r r))) 4.5) (- (- 1.5) (* (* (* r r) (* w w)) 0.25))))
double code(double v, double w, double r) {
double tmp;
if (r <= 9.5e-6) {
tmp = (3.0 + (2.0 / (r * r))) - 4.5;
} else {
tmp = -1.5 - (((r * r) * (w * 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) :: tmp
if (r <= 9.5d-6) then
tmp = (3.0d0 + (2.0d0 / (r * r))) - 4.5d0
else
tmp = -1.5d0 - (((r * r) * (w * w)) * 0.25d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 9.5e-6) {
tmp = (3.0 + (2.0 / (r * r))) - 4.5;
} else {
tmp = -1.5 - (((r * r) * (w * w)) * 0.25);
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 9.5e-6: tmp = (3.0 + (2.0 / (r * r))) - 4.5 else: tmp = -1.5 - (((r * r) * (w * w)) * 0.25) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 9.5e-6) tmp = Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - 4.5); else tmp = Float64(Float64(-1.5) - Float64(Float64(Float64(r * r) * Float64(w * w)) * 0.25)); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 9.5e-6) tmp = (3.0 + (2.0 / (r * r))) - 4.5; else tmp = -1.5 - (((r * r) * (w * w)) * 0.25); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 9.5e-6], N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[((-1.5) - N[(N[(N[(r * r), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 9.5 \cdot 10^{-6}:\\
\;\;\;\;\left(3 + \frac{2}{r \cdot r}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\left(-1.5\right) - \left(\left(r \cdot r\right) \cdot \left(w \cdot w\right)\right) \cdot 0.25\\
\end{array}
\end{array}
if r < 9.5000000000000005e-6Initial program 82.9%
Simplified78.4%
Taylor expanded in r around 0 69.0%
if 9.5000000000000005e-6 < r Initial program 80.0%
Simplified77.8%
Taylor expanded in r around inf 77.5%
Taylor expanded in v around inf 76.2%
mul-1-neg76.2%
Simplified76.2%
pow276.2%
Applied egg-rr76.2%
pow276.2%
Applied egg-rr76.2%
Final simplification70.9%
(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.1%
Simplified78.2%
Taylor expanded in r around 0 56.2%
(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.1%
Simplified78.2%
Taylor expanded in r around 0 56.2%
Taylor expanded in r around inf 12.5%
herbie shell --seed 2024144
(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))