
(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 8 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 (/ (+ (* v -0.25) 0.375) (* (- 1.0 v) (/ (/ (/ -1.0 r) w) (* r w)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + (((v * -0.25) + 0.375) / ((1.0 - 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) + (((v * (-0.25d0)) + 0.375d0) / ((1.0d0 - 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 + (((v * -0.25) + 0.375) / ((1.0 - v) * (((-1.0 / r) / w) / (r * w)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 + (((v * -0.25) + 0.375) / ((1.0 - 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(v * -0.25) + 0.375) / Float64(Float64(1.0 - v) * Float64(Float64(Float64(-1.0 / r) / w) / Float64(r * w)))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 + (((v * -0.25) + 0.375) / ((1.0 - 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[(v * -0.25), $MachinePrecision] + 0.375), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] * N[(N[(N[(-1.0 / r), $MachinePrecision] / w), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 + \frac{v \cdot -0.25 + 0.375}{\left(1 - v\right) \cdot \frac{\frac{\frac{-1}{r}}{w}}{r \cdot w}}\right)
\end{array}
Initial program 84.8%
Simplified87.4%
fma-undefine87.4%
*-commutative87.4%
+-commutative87.4%
associate-*r/87.4%
*-commutative87.4%
associate-/l*87.4%
clear-num87.4%
un-div-inv87.4%
+-commutative87.4%
distribute-rgt-in87.4%
metadata-eval87.4%
*-commutative87.4%
associate-*l*87.4%
metadata-eval87.4%
associate-*r*81.3%
pow281.3%
pow281.3%
pow-prod-down99.8%
Applied egg-rr99.8%
div-inv99.8%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
metadata-eval99.8%
pow-prod-up99.8%
unpow-199.8%
unpow-199.8%
Applied egg-rr99.8%
associate-*l/99.8%
*-lft-identity99.8%
associate-/r*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 3.05e-102)
(- (+ t_0 3.0) 4.5)
(if (<= r 6e-16)
(+ t_0 (+ -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 t_0 = 2.0 / (r * r);
double tmp;
if (r <= 3.05e-102) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 6e-16) {
tmp = t_0 + (-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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if (r <= 3.05d-102) then
tmp = (t_0 + 3.0d0) - 4.5d0
else if (r <= 6d-16) then
tmp = t_0 + ((-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 t_0 = 2.0 / (r * r);
double tmp;
if (r <= 3.05e-102) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 6e-16) {
tmp = t_0 + (-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): t_0 = 2.0 / (r * r) tmp = 0 if r <= 3.05e-102: tmp = (t_0 + 3.0) - 4.5 elif r <= 6e-16: tmp = t_0 + (-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) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 3.05e-102) tmp = Float64(Float64(t_0 + 3.0) - 4.5); elseif (r <= 6e-16) tmp = Float64(t_0 + 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) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 3.05e-102) tmp = (t_0 + 3.0) - 4.5; elseif (r <= 6e-16) tmp = t_0 + (-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_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 3.05e-102], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 6e-16], N[(t$95$0 + 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}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 3.05 \cdot 10^{-102}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 6 \cdot 10^{-16}:\\
\;\;\;\;t\_0 + \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 < 3.0499999999999999e-102Initial program 80.1%
Simplified78.8%
Taylor expanded in r around 0 72.8%
if 3.0499999999999999e-102 < r < 5.99999999999999987e-16Initial program 99.6%
Simplified99.6%
Taylor expanded in v around 0 86.3%
if 5.99999999999999987e-16 < r Initial program 93.7%
Simplified95.1%
associate-/l*95.1%
*-commutative95.1%
associate-*r/95.1%
associate-*l*99.5%
associate-*r*99.8%
Applied egg-rr99.8%
Taylor expanded in r around inf 97.5%
Final simplification80.1%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 1.2e-102)
(- (+ t_0 3.0) 4.5)
(if (<= r 1.25e-16)
(+ t_0 (+ -1.5 (* 0.375 (* r (* (* w w) (/ r (+ v -1.0)))))))
(-
3.0
(+
4.5
(*
(* 0.125 (+ 3.0 (* v -2.0)))
(* w (* r (* w (/ r (- 1.0 v))))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 1.2e-102) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 1.25e-16) {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if (r <= 1.2d-102) then
tmp = (t_0 + 3.0d0) - 4.5d0
else if (r <= 1.25d-16) then
tmp = t_0 + ((-1.5d0) + (0.375d0 * (r * ((w * w) * (r / (v + (-1.0d0)))))))
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) * (w * (r * (w * (r / (1.0d0 - 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 <= 1.2e-102) {
tmp = (t_0 + 3.0) - 4.5;
} else if (r <= 1.25e-16) {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * (r / (1.0 - v)))))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 1.2e-102: tmp = (t_0 + 3.0) - 4.5 elif r <= 1.25e-16: tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))) else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * (r / (1.0 - v))))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 1.2e-102) tmp = Float64(Float64(t_0 + 3.0) - 4.5); elseif (r <= 1.25e-16) tmp = Float64(t_0 + 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(w * Float64(r * Float64(w * Float64(r / Float64(1.0 - v)))))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 1.2e-102) tmp = (t_0 + 3.0) - 4.5; elseif (r <= 1.25e-16) tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))); else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (v * -2.0))) * (w * (r * (w * (r / (1.0 - 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, 1.2e-102], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[r, 1.25e-16], N[(t$95$0 + 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[(w * N[(r * N[(w * N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 1.2 \cdot 10^{-102}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{elif}\;r \leq 1.25 \cdot 10^{-16}:\\
\;\;\;\;t\_0 + \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(w \cdot \left(r \cdot \left(w \cdot \frac{r}{1 - v}\right)\right)\right)\right)\\
\end{array}
\end{array}
if r < 1.2e-102Initial program 80.1%
Simplified78.8%
Taylor expanded in r around 0 72.8%
if 1.2e-102 < r < 1.2500000000000001e-16Initial program 99.6%
Simplified99.6%
Taylor expanded in v around 0 86.3%
if 1.2500000000000001e-16 < r Initial program 93.7%
Simplified95.1%
Taylor expanded in r around inf 92.8%
associate-/l*92.8%
*-commutative92.8%
associate-*r/92.8%
*-commutative92.8%
associate-*l*97.2%
associate-*l*94.7%
Applied egg-rr94.7%
Final simplification79.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 2.1e-102)
(- (+ t_0 3.0) 4.5)
(+ t_0 (+ -1.5 (* 0.375 (* r (* (* w w) (/ r (+ v -1.0))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 2.1e-102) {
tmp = (t_0 + 3.0) - 4.5;
} else {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
}
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 <= 2.1d-102) then
tmp = (t_0 + 3.0d0) - 4.5d0
else
tmp = t_0 + ((-1.5d0) + (0.375d0 * (r * ((w * w) * (r / (v + (-1.0d0)))))))
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 <= 2.1e-102) {
tmp = (t_0 + 3.0) - 4.5;
} else {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 2.1e-102: tmp = (t_0 + 3.0) - 4.5 else: tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 2.1e-102) tmp = Float64(Float64(t_0 + 3.0) - 4.5); else tmp = Float64(t_0 + Float64(-1.5 + Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 2.1e-102) tmp = (t_0 + 3.0) - 4.5; else tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 2.1e-102], N[(N[(t$95$0 + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], N[(t$95$0 + 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 2.1 \cdot 10^{-102}:\\
\;\;\;\;\left(t\_0 + 3\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 + 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\end{array}
\end{array}
if r < 2.1e-102Initial program 80.1%
Simplified78.8%
Taylor expanded in r around 0 72.8%
if 2.1e-102 < r Initial program 94.8%
Simplified95.9%
Taylor expanded in v around 0 79.4%
Final simplification74.9%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (+ -1.5 (/ (+ (* v -0.25) 0.375) (/ (+ v -1.0) (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + (((v * -0.25) + 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) + (((v * (-0.25d0)) + 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 + (((v * -0.25) + 0.375) / ((v + -1.0) / ((r * w) * (r * w)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 + (((v * -0.25) + 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(v * -0.25) + 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 + (((v * -0.25) + 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[(v * -0.25), $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{v \cdot -0.25 + 0.375}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right)
\end{array}
Initial program 84.8%
Simplified87.4%
fma-undefine87.4%
*-commutative87.4%
+-commutative87.4%
associate-*r/87.4%
*-commutative87.4%
associate-/l*87.4%
clear-num87.4%
un-div-inv87.4%
+-commutative87.4%
distribute-rgt-in87.4%
metadata-eval87.4%
*-commutative87.4%
associate-*l*87.4%
metadata-eval87.4%
associate-*r*81.3%
pow281.3%
pow281.3%
pow-prod-down99.8%
Applied egg-rr99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (if (<= r 2000.0) (- (+ (/ 2.0 (* r r)) 3.0) 4.5) (- 3.0 (+ 4.5 (* (* (* r w) (* r w)) (* 0.125 (+ 3.0 (* v -2.0))))))))
double code(double v, double w, double r) {
double tmp;
if (r <= 2000.0) {
tmp = ((2.0 / (r * r)) + 3.0) - 4.5;
} else {
tmp = 3.0 - (4.5 + (((r * w) * (r * w)) * (0.125 * (3.0 + (v * -2.0)))));
}
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 <= 2000.0d0) then
tmp = ((2.0d0 / (r * r)) + 3.0d0) - 4.5d0
else
tmp = 3.0d0 - (4.5d0 + (((r * w) * (r * w)) * (0.125d0 * (3.0d0 + (v * (-2.0d0))))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 2000.0) {
tmp = ((2.0 / (r * r)) + 3.0) - 4.5;
} else {
tmp = 3.0 - (4.5 + (((r * w) * (r * w)) * (0.125 * (3.0 + (v * -2.0)))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 2000.0: tmp = ((2.0 / (r * r)) + 3.0) - 4.5 else: tmp = 3.0 - (4.5 + (((r * w) * (r * w)) * (0.125 * (3.0 + (v * -2.0))))) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 2000.0) tmp = Float64(Float64(Float64(2.0 / Float64(r * r)) + 3.0) - 4.5); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(Float64(r * w) * Float64(r * w)) * Float64(0.125 * Float64(3.0 + Float64(v * -2.0)))))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 2000.0) tmp = ((2.0 / (r * r)) + 3.0) - 4.5; else tmp = 3.0 - (4.5 + (((r * w) * (r * w)) * (0.125 * (3.0 + (v * -2.0))))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 2000.0], N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision] - 4.5), $MachinePrecision], N[(3.0 - N[(4.5 + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 2000:\\
\;\;\;\;\left(\frac{2}{r \cdot r} + 3\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;3 - \left(4.5 + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot \left(0.125 \cdot \left(3 + v \cdot -2\right)\right)\right)\\
\end{array}
\end{array}
if r < 2e3Initial program 82.0%
Simplified80.8%
Taylor expanded in r around 0 72.7%
if 2e3 < r Initial program 93.5%
Simplified94.9%
associate-/l*94.9%
*-commutative94.9%
associate-*r/94.9%
associate-*l*99.5%
associate-*r*99.8%
Applied egg-rr99.8%
Taylor expanded in r around inf 99.8%
Taylor expanded in v around 0 72.4%
Final simplification72.7%
(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 84.8%
Simplified80.6%
Taylor expanded in r around 0 61.8%
Final simplification61.8%
(FPCore (v w r) :precision binary64 -1.5)
double code(double v, double w, double r) {
return -1.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = -1.5d0
end function
public static double code(double v, double w, double r) {
return -1.5;
}
def code(v, w, r): return -1.5
function code(v, w, r) return -1.5 end
function tmp = code(v, w, r) tmp = -1.5; end
code[v_, w_, r_] := -1.5
\begin{array}{l}
\\
-1.5
\end{array}
Initial program 84.8%
Simplified80.6%
Taylor expanded in r around 0 61.8%
Taylor expanded in r around inf 16.4%
herbie shell --seed 2024181
(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))