
(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) (/ (* r w) (+ v -1.0)))) 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) * ((r * w) / (v + -1.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 = (3.0d0 + (2.0d0 / (r * r))) + (((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * ((r * w) * ((r * w) / (v + (-1.0d0))))) - 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) * ((r * w) / (v + -1.0)))) - 4.5);
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * ((r * w) / (v + -1.0)))) - 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(Float64(r * w) / Float64(v + -1.0)))) - 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) * ((r * w) / (v + -1.0)))) - 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[(N[(r * w), $MachinePrecision] / N[(v + -1.0), $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 \frac{r \cdot w}{v + -1}\right) - 4.5\right)
\end{array}
Initial program 80.0%
associate--l-80.0%
associate-*l*75.1%
sqr-neg75.1%
associate-*l*80.0%
associate-/l*84.0%
fma-define84.0%
Simplified84.0%
add-sqr-sqrt84.0%
*-un-lft-identity84.0%
times-frac84.0%
associate-*r*77.7%
sqrt-prod77.7%
sqrt-prod40.2%
add-sqr-sqrt69.8%
sqrt-prod29.0%
add-sqr-sqrt66.0%
associate-*r*58.6%
sqrt-prod58.6%
sqrt-prod30.9%
add-sqr-sqrt69.1%
sqrt-prod44.4%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ (/ 2.0 r) r)) (+ 4.5 (* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (* w (/ r (- 1.0 v))))))))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))));
}
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 + ((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * ((r * w) * (w * (r / (1.0d0 - v))))))
end function
public static double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))));
}
def code(v, w, r): return (3.0 + ((2.0 / r) / r)) - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))))
function code(v, w, r) return Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(r * w) * Float64(w * Float64(r / Float64(1.0 - v))))))) end
function tmp = code(v, w, r) tmp = (3.0 + ((2.0 / r) / r)) - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v)))))); end
code[v_, w_, r_] := N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - N[(4.5 + 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]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{\frac{2}{r}}{r}\right) - \left(4.5 + \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)\right)
\end{array}
Initial program 80.0%
associate--l-80.0%
associate-*l*75.1%
sqr-neg75.1%
associate-*l*80.0%
associate-/l*84.0%
fma-define84.0%
Simplified84.0%
associate-/l*84.0%
*-commutative84.0%
associate-*r/83.9%
associate-*l*95.3%
associate-*r*99.0%
Applied egg-rr99.0%
associate-/r*99.1%
div-inv99.0%
Applied egg-rr99.0%
associate-*r/99.1%
*-rgt-identity99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) (+ 4.5 (* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (* w (/ r (- 1.0 v))))))))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))));
}
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 + ((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * ((r * w) * (w * (r / (1.0d0 - v))))))
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))));
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))))
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(r * w) * Float64(w * Float64(r / Float64(1.0 - v))))))) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v)))))); end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(4.5 + 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]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) - \left(4.5 + \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)\right)
\end{array}
Initial program 80.0%
associate--l-80.0%
associate-*l*75.1%
sqr-neg75.1%
associate-*l*80.0%
associate-/l*84.0%
fma-define84.0%
Simplified84.0%
associate-/l*84.0%
*-commutative84.0%
associate-*r/83.9%
associate-*l*95.3%
associate-*r*99.0%
Applied egg-rr99.0%
Final simplification99.0%
(FPCore (v w r)
:precision binary64
(if (<= r 0.00044)
(+ (/ 2.0 (* r r)) (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(-
3.0
(+
4.5
(* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (* w (/ r (- 1.0 v)))))))))
double code(double v, double w, double r) {
double tmp;
if (r <= 0.00044) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((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 <= 0.00044d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
else
tmp = 3.0d0 - (4.5d0 + ((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * ((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 <= 0.00044) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v))))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 0.00044: tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v)))))) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 0.00044) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(3.0 - Float64(4.5 + Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * 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 <= 0.00044) tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = 3.0 - (4.5 + ((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w * (r / (1.0 - v)))))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 0.00044], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(4.5 + 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]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 0.00044:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \left(4.5 + \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)\right)\\
\end{array}
\end{array}
if r < 4.40000000000000016e-4Initial program 78.5%
Simplified82.1%
Taylor expanded in v around inf 73.5%
*-commutative73.5%
unpow273.5%
unpow273.5%
swap-sqr90.7%
unpow290.7%
Simplified90.7%
unpow290.7%
Applied egg-rr90.7%
if 4.40000000000000016e-4 < r Initial program 86.1%
associate--l-86.1%
associate-*l*74.1%
sqr-neg74.1%
associate-*l*86.1%
associate-/l*91.8%
fma-define91.9%
Simplified91.8%
associate-/l*91.9%
*-commutative91.9%
associate-*r/91.9%
associate-*l*95.7%
associate-*r*99.9%
Applied egg-rr99.9%
Taylor expanded in r around inf 99.9%
Final simplification92.4%
(FPCore (v w r) :precision binary64 (+ (+ 3.0 (/ 2.0 (* r r))) (- (/ (* (* r w) (+ 0.375 (* v -0.25))) (/ (+ v -1.0) (* r w))) 4.5)))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 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))) + ((((r * w) * (0.375d0 + (v * (-0.25d0)))) / ((v + (-1.0d0)) / (r * w))) - 4.5d0)
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 4.5);
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 4.5)
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(Float64(Float64(r * w) * Float64(0.375 + Float64(v * -0.25))) / Float64(Float64(v + -1.0) / Float64(r * w))) - 4.5)) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 4.5); end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(r * w), $MachinePrecision] * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(v + -1.0), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) + \left(\frac{\left(r \cdot w\right) \cdot \left(0.375 + v \cdot -0.25\right)}{\frac{v + -1}{r \cdot w}} - 4.5\right)
\end{array}
Initial program 80.0%
associate--l-80.0%
associate-*l*75.1%
sqr-neg75.1%
associate-*l*80.0%
associate-/l*84.0%
fma-define84.0%
Simplified84.0%
add-sqr-sqrt84.0%
*-un-lft-identity84.0%
times-frac84.0%
associate-*r*77.7%
sqrt-prod77.7%
sqrt-prod40.2%
add-sqr-sqrt69.8%
sqrt-prod29.0%
add-sqr-sqrt66.0%
associate-*r*58.6%
sqrt-prod58.6%
sqrt-prod30.9%
add-sqr-sqrt69.1%
sqrt-prod44.4%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
/-rgt-identity99.4%
associate-*r*97.6%
clear-num97.5%
un-div-inv97.5%
*-commutative97.5%
distribute-rgt-in97.5%
metadata-eval97.5%
*-commutative97.5%
associate-*l*97.5%
metadata-eval97.5%
Applied egg-rr97.5%
Final simplification97.5%
(FPCore (v w r)
:precision binary64
(if (<= r 1800000000.0)
(+ (/ 2.0 (* r r)) (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(-
(+ 3.0 (* (* r (* w (+ 0.375 (* v -0.25)))) (* w (/ r (+ v -1.0)))))
4.5)))
double code(double v, double w, double r) {
double tmp;
if (r <= 1800000000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = (3.0 + ((r * (w * (0.375 + (v * -0.25)))) * (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) :: tmp
if (r <= 1800000000.0d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
else
tmp = (3.0d0 + ((r * (w * (0.375d0 + (v * (-0.25d0))))) * (w * (r / (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 <= 1800000000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = (3.0 + ((r * (w * (0.375 + (v * -0.25)))) * (w * (r / (v + -1.0))))) - 4.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 1800000000.0: tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = (3.0 + ((r * (w * (0.375 + (v * -0.25)))) * (w * (r / (v + -1.0))))) - 4.5 return tmp
function code(v, w, r) tmp = 0.0 if (r <= 1800000000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(Float64(3.0 + Float64(Float64(r * Float64(w * Float64(0.375 + Float64(v * -0.25)))) * Float64(w * Float64(r / Float64(v + -1.0))))) - 4.5); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 1800000000.0) tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = (3.0 + ((r * (w * (0.375 + (v * -0.25)))) * (w * (r / (v + -1.0))))) - 4.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 1800000000.0], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 + N[(N[(r * N[(w * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 1800000000:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3 + \left(r \cdot \left(w \cdot \left(0.375 + v \cdot -0.25\right)\right)\right) \cdot \left(w \cdot \frac{r}{v + -1}\right)\right) - 4.5\\
\end{array}
\end{array}
if r < 1.8e9Initial program 78.3%
Simplified82.2%
Taylor expanded in v around inf 73.4%
*-commutative73.4%
unpow273.4%
unpow273.4%
swap-sqr90.4%
unpow290.4%
Simplified90.4%
unpow290.4%
Applied egg-rr90.4%
if 1.8e9 < r Initial program 87.6%
Taylor expanded in r around inf 87.6%
associate-/l*91.6%
cancel-sign-sub-inv91.6%
metadata-eval91.6%
+-commutative91.6%
*-commutative91.6%
fma-undefine91.6%
*-commutative91.6%
*-commutative91.6%
associate-/l*91.6%
*-commutative91.6%
associate-*r/91.6%
associate-*r*85.4%
associate-*l*89.3%
associate-*r*89.5%
Applied egg-rr89.5%
Taylor expanded in r around 0 99.8%
Final simplification92.1%
(FPCore (v w r)
:precision binary64
(if (<= r 16500000.0)
(+ (/ 2.0 (* r r)) (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(+
3.0
(- (/ (* (* r w) (+ 0.375 (* v -0.25))) (/ (+ v -1.0) (* r w))) 4.5))))
double code(double v, double w, double r) {
double tmp;
if (r <= 16500000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = 3.0 + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 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 <= 16500000.0d0) then
tmp = (2.0d0 / (r * r)) + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
else
tmp = 3.0d0 + ((((r * w) * (0.375d0 + (v * (-0.25d0)))) / ((v + (-1.0d0)) / (r * w))) - 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 16500000.0) {
tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = 3.0 + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 4.5);
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 16500000.0: tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = 3.0 + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 4.5) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 16500000.0) tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(3.0 + Float64(Float64(Float64(Float64(r * w) * Float64(0.375 + Float64(v * -0.25))) / Float64(Float64(v + -1.0) / Float64(r * w))) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 16500000.0) tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = 3.0 + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 16500000.0], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 + N[(N[(N[(N[(r * w), $MachinePrecision] * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(v + -1.0), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 16500000:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;3 + \left(\frac{\left(r \cdot w\right) \cdot \left(0.375 + v \cdot -0.25\right)}{\frac{v + -1}{r \cdot w}} - 4.5\right)\\
\end{array}
\end{array}
if r < 1.65e7Initial program 78.3%
Simplified82.2%
Taylor expanded in v around inf 73.4%
*-commutative73.4%
unpow273.4%
unpow273.4%
swap-sqr90.4%
unpow290.4%
Simplified90.4%
unpow290.4%
Applied egg-rr90.4%
if 1.65e7 < r Initial program 87.6%
associate--l-87.6%
associate-*l*75.1%
sqr-neg75.1%
associate-*l*87.6%
associate-/l*91.6%
fma-define91.6%
Simplified91.6%
add-sqr-sqrt91.5%
*-un-lft-identity91.5%
times-frac91.5%
associate-*r*79.0%
sqrt-prod79.0%
sqrt-prod91.5%
add-sqr-sqrt91.6%
sqrt-prod38.1%
add-sqr-sqrt47.0%
associate-*r*34.5%
sqrt-prod34.5%
sqrt-prod47.0%
add-sqr-sqrt47.0%
sqrt-prod42.5%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
/-rgt-identity99.8%
associate-*r*99.8%
clear-num99.7%
un-div-inv99.8%
*-commutative99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in r around inf 99.8%
Final simplification92.1%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* (* (* r w) (* r w)) 0.25))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = (2.0d0 / (r * r)) + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)
\end{array}
Initial program 80.0%
Simplified83.9%
Taylor expanded in v around inf 73.8%
*-commutative73.8%
unpow273.8%
unpow273.8%
swap-sqr90.2%
unpow290.2%
Simplified90.2%
unpow290.2%
Applied egg-rr90.2%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) -1.5))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + -1.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((2.0d0 / r) / r) + (-1.5d0)
end function
public static double code(double v, double w, double r) {
return ((2.0 / r) / r) + -1.5;
}
def code(v, w, r): return ((2.0 / r) / r) + -1.5
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + -1.5) end
function tmp = code(v, w, r) tmp = ((2.0 / r) / r) + -1.5; end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + -1.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + -1.5
\end{array}
Initial program 80.0%
Simplified77.3%
Taylor expanded in r around 0 59.4%
+-commutative59.4%
associate--l+59.4%
associate-/r*59.4%
div-inv59.3%
div-inv59.3%
unpow-159.3%
metadata-eval59.3%
unpow-159.3%
metadata-eval59.3%
associate-*r*59.3%
sqr-pow59.4%
metadata-eval59.4%
Applied egg-rr59.4%
sqr-pow59.3%
associate-*r*59.3%
metadata-eval59.3%
unpow-159.3%
div-inv59.3%
metadata-eval59.3%
unpow-159.3%
div-inv59.4%
Applied egg-rr59.4%
(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 80.0%
Simplified77.3%
Taylor expanded in r around 0 59.4%
Taylor expanded in r around inf 11.0%
herbie shell --seed 2024136
(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))