
(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 (+ (/ 2.0 (* r r)) (+ -1.5 (/ (+ (* -0.25 v) 0.375) (/ (+ v -1.0) (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + (((-0.25 * v) + 0.375) / ((v + -1.0) / ((r * w) * (r * w)))));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = (2.0d0 / (r * r)) + ((-1.5d0) + ((((-0.25d0) * v) + 0.375d0) / ((v + (-1.0d0)) / ((r * w) * (r * w)))))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + (((-0.25 * v) + 0.375) / ((v + -1.0) / ((r * w) * (r * w)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 + (((-0.25 * v) + 0.375) / ((v + -1.0) / ((r * w) * (r * w)))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(Float64(Float64(-0.25 * v) + 0.375) / Float64(Float64(v + -1.0) / Float64(Float64(r * w) * Float64(r * w)))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 + (((-0.25 * v) + 0.375) / ((v + -1.0) / ((r * w) * (r * w))))); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(N[(N[(-0.25 * v), $MachinePrecision] + 0.375), $MachinePrecision] / N[(N[(v + -1.0), $MachinePrecision] / N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 + \frac{-0.25 \cdot v + 0.375}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right)
\end{array}
Initial program 88.9%
Simplified89.6%
fma-undefine89.6%
*-commutative89.6%
+-commutative89.6%
metadata-eval89.6%
cancel-sign-sub-inv89.6%
associate-*r/89.6%
*-commutative89.6%
associate-/l*90.0%
clear-num90.0%
un-div-inv90.0%
Applied egg-rr99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(if (<= r 4.2e-93)
(- (+ 3.0 (/ (/ 2.0 r) r)) 4.5)
(if (<= r 25000000.0)
(+ (/ 2.0 (* r r)) (- -1.5 (* 0.375 (* r (* (* w w) (/ r (- 1.0 v)))))))
(if (<= r 4.6e+91)
(-
(+ 3.0 (* (* w (* r (+ (* -0.25 v) 0.375))) (* w (/ r (+ v -1.0)))))
4.5)
(- (- 3.0 (* (* r w) (* r (* w 0.25)))) 4.5)))))
double code(double v, double w, double r) {
double tmp;
if (r <= 4.2e-93) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 25000000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} else if (r <= 4.6e+91) {
tmp = (3.0 + ((w * (r * ((-0.25 * v) + 0.375))) * (w * (r / (v + -1.0))))) - 4.5;
} else {
tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 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) :: tmp
if (r <= 4.2d-93) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else if (r <= 25000000.0d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) - (0.375d0 * (r * ((w * w) * (r / (1.0d0 - v))))))
else if (r <= 4.6d+91) then
tmp = (3.0d0 + ((w * (r * (((-0.25d0) * v) + 0.375d0))) * (w * (r / (v + (-1.0d0)))))) - 4.5d0
else
tmp = (3.0d0 - ((r * w) * (r * (w * 0.25d0)))) - 4.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 4.2e-93) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 25000000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v))))));
} else if (r <= 4.6e+91) {
tmp = (3.0 + ((w * (r * ((-0.25 * v) + 0.375))) * (w * (r / (v + -1.0))))) - 4.5;
} else {
tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 4.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 4.2e-93: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 elif r <= 25000000.0: tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))) elif r <= 4.6e+91: tmp = (3.0 + ((w * (r * ((-0.25 * v) + 0.375))) * (w * (r / (v + -1.0))))) - 4.5 else: tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 4.5 return tmp
function code(v, w, r) tmp = 0.0 if (r <= 4.2e-93) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); elseif (r <= 25000000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(1.0 - v))))))); elseif (r <= 4.6e+91) tmp = Float64(Float64(3.0 + Float64(Float64(w * Float64(r * Float64(Float64(-0.25 * v) + 0.375))) * Float64(w * Float64(r / Float64(v + -1.0))))) - 4.5); else tmp = Float64(Float64(3.0 - Float64(Float64(r * w) * Float64(r * Float64(w * 0.25)))) - 4.5); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 4.2e-93) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; elseif (r <= 25000000.0) tmp = (2.0 / (r * r)) + (-1.5 - (0.375 * (r * ((w * w) * (r / (1.0 - v)))))); elseif (r <= 4.6e+91) tmp = (3.0 + ((w * (r * ((-0.25 * v) + 0.375))) * (w * (r / (v + -1.0))))) - 4.5; else tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 4.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 4.2e-93], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 25000000.0], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[r, 4.6e+91], N[(N[(3.0 + N[(N[(w * N[(r * N[(N[(-0.25 * v), $MachinePrecision] + 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(3.0 - N[(N[(r * w), $MachinePrecision] * N[(r * N[(w * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 4.2 \cdot 10^{-93}:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\mathbf{elif}\;r \leq 25000000:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{1 - v}\right)\right)\right)\\
\mathbf{elif}\;r \leq 4.6 \cdot 10^{+91}:\\
\;\;\;\;\left(3 + \left(w \cdot \left(r \cdot \left(-0.25 \cdot v + 0.375\right)\right)\right) \cdot \left(w \cdot \frac{r}{v + -1}\right)\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\left(3 - \left(r \cdot w\right) \cdot \left(r \cdot \left(w \cdot 0.25\right)\right)\right) - 4.5\\
\end{array}
\end{array}
if r < 4.2000000000000002e-93Initial program 85.7%
Simplified82.5%
Taylor expanded in r around 0 64.7%
associate-/r*64.8%
div-inv64.7%
Applied egg-rr64.7%
associate-*r/64.8%
*-rgt-identity64.8%
Simplified64.8%
if 4.2000000000000002e-93 < r < 2.5e7Initial program 95.9%
Simplified95.9%
Taylor expanded in v around 0 91.9%
if 2.5e7 < r < 4.59999999999999982e91Initial program 99.7%
Taylor expanded in r around inf 99.7%
associate-/l*99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
+-commutative99.6%
*-commutative99.6%
fma-undefine99.6%
*-commutative99.6%
*-commutative99.6%
associate-/l*96.2%
*-commutative96.2%
associate-*r/96.2%
associate-*r*96.0%
associate-*l*95.9%
associate-*r*96.0%
Applied egg-rr96.0%
if 4.59999999999999982e91 < r Initial program 91.6%
Taylor expanded in r around inf 91.6%
Taylor expanded in v around inf 59.7%
*-commutative59.7%
Simplified59.7%
associate-/l*65.2%
*-commutative65.2%
*-commutative65.2%
*-commutative65.2%
associate-*r*56.7%
swap-sqr67.9%
associate-*r/67.9%
*-commutative67.9%
associate-*r*67.9%
*-commutative67.9%
associate-/l*66.4%
Applied egg-rr66.4%
Taylor expanded in v around inf 92.8%
*-commutative92.8%
associate-*l*92.8%
Simplified92.8%
Final simplification74.3%
(FPCore (v w r)
:precision binary64
(if (<= r 2.1e-92)
(- (+ 3.0 (/ (/ 2.0 r) r)) 4.5)
(if (<= r 24000000.0)
(+ (/ 2.0 (* r r)) (+ -1.5 (* 0.375 (* r (* (* w w) (/ r (+ v -1.0)))))))
(-
3.0
(+
4.5
(* (* 0.125 (+ 3.0 (* v -2.0))) (* (* r w) (* w (/ r (- 1.0 v))))))))))
double code(double v, double w, double r) {
double tmp;
if (r <= 2.1e-92) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 24000000.0) {
tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * (r / (1.0 - 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) :: tmp
if (r <= 2.1d-92) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else if (r <= 24000000.0d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) + (0.375d0 * (r * ((w * w) * (r / (v + (-1.0d0)))))))
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * ((r * w) * (w * (r / (1.0d0 - v))))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 2.1e-92) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 24000000.0) {
tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * (r / (1.0 - v))))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 2.1e-92: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 elif r <= 24000000.0: tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))) else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * (r / (1.0 - v)))))) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 2.1e-92) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); elseif (r <= 24000000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(Float64(r * w) * Float64(w * Float64(r / Float64(1.0 - v))))))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 2.1e-92) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; elseif (r <= 24000000.0) tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))); else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * ((r * w) * (w * (r / (1.0 - v)))))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 2.1e-92], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 24000000.0], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(4.5 + N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(w * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 2.1 \cdot 10^{-92}:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\mathbf{elif}\;r \leq 24000000:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \left(4.5 + \left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \left(w \cdot \frac{r}{1 - v}\right)\right)\right)\\
\end{array}
\end{array}
if r < 2.1e-92Initial program 85.7%
Simplified82.5%
Taylor expanded in r around 0 64.7%
associate-/r*64.8%
div-inv64.7%
Applied egg-rr64.7%
associate-*r/64.8%
*-rgt-identity64.8%
Simplified64.8%
if 2.1e-92 < r < 2.4e7Initial program 95.9%
Simplified95.9%
Taylor expanded in v around 0 91.9%
if 2.4e7 < r Initial program 95.1%
associate--l-95.1%
associate-*l*88.6%
sqr-neg88.6%
associate-*l*95.1%
associate-/l*98.2%
fma-define98.2%
Simplified98.2%
Taylor expanded in r around inf 98.2%
associate-/l*96.7%
*-commutative96.7%
associate-*r/96.7%
associate-*l*98.3%
associate-*r*99.7%
Applied egg-rr99.7%
Final simplification75.6%
(FPCore (v w r)
:precision binary64
(if (<= r 5e-93)
(- (+ 3.0 (/ (/ 2.0 r) r)) 4.5)
(if (<= r 25500000.0)
(+ (/ 2.0 (* r r)) (+ -1.5 (* 0.375 (* r (* (* w w) (/ r (+ v -1.0)))))))
(+
3.0
(-
(* (* 0.125 (+ 3.0 (* v -2.0))) (* w (* r (/ (* r w) (+ v -1.0)))))
4.5)))))
double code(double v, double w, double r) {
double tmp;
if (r <= 5e-93) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 25500000.0) {
tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * (w * (r * ((r * w) / (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) :: tmp
if (r <= 5d-93) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else if (r <= 25500000.0d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) + (0.375d0 * (r * ((w * w) * (r / (v + (-1.0d0)))))))
else
tmp = 3.0d0 + (((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * (w * (r * ((r * w) / (v + (-1.0d0)))))) - 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 5e-93) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 25500000.0) {
tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * (w * (r * ((r * w) / (v + -1.0))))) - 4.5);
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 5e-93: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 elif r <= 25500000.0: tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))) else: tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * (w * (r * ((r * w) / (v + -1.0))))) - 4.5) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 5e-93) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); elseif (r <= 25500000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); else tmp = Float64(3.0 + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) * Float64(w * Float64(r * Float64(Float64(r * w) / Float64(v + -1.0))))) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 5e-93) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; elseif (r <= 25500000.0) tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))); else tmp = 3.0 + (((0.125 * (3.0 + (v * -2.0))) * (w * (r * ((r * w) / (v + -1.0))))) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 5e-93], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 25500000.0], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 + N[(N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w * N[(r * N[(N[(r * w), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 5 \cdot 10^{-93}:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\mathbf{elif}\;r \leq 25500000:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;3 + \left(\left(0.125 \cdot \left(3 + v \cdot -2\right)\right) \cdot \left(w \cdot \left(r \cdot \frac{r \cdot w}{v + -1}\right)\right) - 4.5\right)\\
\end{array}
\end{array}
if r < 4.99999999999999994e-93Initial program 85.7%
Simplified82.5%
Taylor expanded in r around 0 64.7%
associate-/r*64.8%
div-inv64.7%
Applied egg-rr64.7%
associate-*r/64.8%
*-rgt-identity64.8%
Simplified64.8%
if 4.99999999999999994e-93 < r < 2.55e7Initial program 95.9%
Simplified95.9%
Taylor expanded in v around 0 91.9%
if 2.55e7 < r Initial program 95.1%
associate--l-95.1%
associate-*l*88.6%
sqr-neg88.6%
associate-*l*95.1%
associate-/l*98.2%
fma-define98.2%
Simplified98.2%
Taylor expanded in r around inf 98.2%
associate-/l*96.7%
*-commutative96.7%
associate-*r/96.7%
associate-*l*98.3%
associate-*r*99.7%
Applied egg-rr99.7%
pow199.7%
associate-*l*98.3%
associate-*r/98.3%
*-commutative98.3%
associate-*r/97.5%
Applied egg-rr97.5%
unpow197.5%
*-commutative97.5%
associate-*l*96.1%
associate-*r/98.3%
Simplified98.3%
Final simplification75.3%
(FPCore (v w r)
:precision binary64
(if (<= r 1.12e-91)
(- (+ 3.0 (/ (/ 2.0 r) r)) 4.5)
(if (<= r 1.2e+90)
(+ (/ 2.0 (* r r)) (+ -1.5 (* 0.375 (* r (* (* w w) (/ r (+ v -1.0)))))))
(- (- 3.0 (* (* r w) (* r (* w 0.25)))) 4.5))))
double code(double v, double w, double r) {
double tmp;
if (r <= 1.12e-91) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 1.2e+90) {
tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 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) :: tmp
if (r <= 1.12d-91) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else if (r <= 1.2d+90) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) + (0.375d0 * (r * ((w * w) * (r / (v + (-1.0d0)))))))
else
tmp = (3.0d0 - ((r * w) * (r * (w * 0.25d0)))) - 4.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 1.12e-91) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else if (r <= 1.2e+90) {
tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 4.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 1.12e-91: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 elif r <= 1.2e+90: tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))) else: tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 4.5 return tmp
function code(v, w, r) tmp = 0.0 if (r <= 1.12e-91) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); elseif (r <= 1.2e+90) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); else tmp = Float64(Float64(3.0 - Float64(Float64(r * w) * Float64(r * Float64(w * 0.25)))) - 4.5); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 1.12e-91) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; elseif (r <= 1.2e+90) tmp = (2.0 / (r * r)) + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))); else tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 4.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 1.12e-91], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 1.2e+90], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 - N[(N[(r * w), $MachinePrecision] * N[(r * N[(w * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 1.12 \cdot 10^{-91}:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\mathbf{elif}\;r \leq 1.2 \cdot 10^{+90}:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3 - \left(r \cdot w\right) \cdot \left(r \cdot \left(w \cdot 0.25\right)\right)\right) - 4.5\\
\end{array}
\end{array}
if r < 1.12e-91Initial program 85.7%
Simplified82.5%
Taylor expanded in r around 0 64.7%
associate-/r*64.8%
div-inv64.7%
Applied egg-rr64.7%
associate-*r/64.8%
*-rgt-identity64.8%
Simplified64.8%
if 1.12e-91 < r < 1.20000000000000005e90Initial program 97.8%
Simplified96.0%
Taylor expanded in v around 0 88.0%
if 1.20000000000000005e90 < r Initial program 91.6%
Taylor expanded in r around inf 91.6%
Taylor expanded in v around inf 59.7%
*-commutative59.7%
Simplified59.7%
associate-/l*65.2%
*-commutative65.2%
*-commutative65.2%
*-commutative65.2%
associate-*r*56.7%
swap-sqr67.9%
associate-*r/67.9%
*-commutative67.9%
associate-*r*67.9%
*-commutative67.9%
associate-/l*66.4%
Applied egg-rr66.4%
Taylor expanded in v around inf 92.8%
*-commutative92.8%
associate-*l*92.8%
Simplified92.8%
Final simplification73.1%
(FPCore (v w r) :precision binary64 (if (<= r 88.0) (- (+ 3.0 (/ (/ 2.0 r) r)) 4.5) (- (- 3.0 (* (* r w) (* r (* w 0.25)))) 4.5)))
double code(double v, double w, double r) {
double tmp;
if (r <= 88.0) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else {
tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 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) :: tmp
if (r <= 88.0d0) then
tmp = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
else
tmp = (3.0d0 - ((r * w) * (r * (w * 0.25d0)))) - 4.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 88.0) {
tmp = (3.0 + ((2.0 / r) / r)) - 4.5;
} else {
tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 4.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 88.0: tmp = (3.0 + ((2.0 / r) / r)) - 4.5 else: tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 4.5 return tmp
function code(v, w, r) tmp = 0.0 if (r <= 88.0) tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5); else tmp = Float64(Float64(3.0 - Float64(Float64(r * w) * Float64(r * Float64(w * 0.25)))) - 4.5); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 88.0) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; else tmp = (3.0 - ((r * w) * (r * (w * 0.25)))) - 4.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 88.0], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(3.0 - N[(N[(r * w), $MachinePrecision] * N[(r * N[(w * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 88:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\left(3 - \left(r \cdot w\right) \cdot \left(r \cdot \left(w \cdot 0.25\right)\right)\right) - 4.5\\
\end{array}
\end{array}
if r < 88Initial program 86.9%
Simplified84.1%
Taylor expanded in r around 0 66.5%
associate-/r*66.6%
div-inv66.5%
Applied egg-rr66.5%
associate-*r/66.6%
*-rgt-identity66.6%
Simplified66.6%
if 88 < r Initial program 95.3%
Taylor expanded in r around inf 95.1%
Taylor expanded in v around inf 62.3%
*-commutative62.3%
Simplified62.3%
associate-/l*65.3%
*-commutative65.3%
*-commutative65.3%
*-commutative65.3%
associate-*r*60.6%
swap-sqr66.7%
associate-*r/66.7%
*-commutative66.7%
associate-*r*66.7%
*-commutative66.7%
associate-/l*64.5%
Applied egg-rr64.5%
Taylor expanded in v around inf 88.1%
*-commutative88.1%
associate-*l*88.1%
Simplified88.1%
Final simplification71.8%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ (/ 2.0 r) r)) 4.5))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - 4.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = (3.0d0 + ((2.0d0 / r) / r)) - 4.5d0
end function
public static double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - 4.5;
}
def code(v, w, r): return (3.0 + ((2.0 / r) / r)) - 4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5) end
function tmp = code(v, w, r) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5
\end{array}
Initial program 88.9%
Simplified84.9%
Taylor expanded in r around 0 55.5%
associate-/r*55.5%
div-inv55.4%
Applied egg-rr55.4%
associate-*r/55.5%
*-rgt-identity55.5%
Simplified55.5%
(FPCore (v w r) :precision binary64 (- (+ (/ 2.0 (* r r)) 3.0) 4.5))
double code(double v, double w, double r) {
return ((2.0 / (r * r)) + 3.0) - 4.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((2.0d0 / (r * r)) + 3.0d0) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((2.0 / (r * r)) + 3.0) - 4.5;
}
def code(v, w, r): return ((2.0 / (r * r)) + 3.0) - 4.5
function code(v, w, r) return Float64(Float64(Float64(2.0 / Float64(r * r)) + 3.0) - 4.5) end
function tmp = code(v, w, r) tmp = ((2.0 / (r * r)) + 3.0) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{2}{r \cdot r} + 3\right) - 4.5
\end{array}
Initial program 88.9%
Simplified84.9%
Taylor expanded in r around 0 55.5%
Final simplification55.5%
(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 88.9%
Simplified84.9%
Taylor expanded in r around 0 55.5%
Taylor expanded in r around inf 12.5%
herbie shell --seed 2024140
(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))