
(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 7 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.375 (* v -0.25)) (/ (+ v -1.0) (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + ((0.375 + (v * -0.25)) / ((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.375d0 + (v * (-0.25d0))) / ((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.375 + (v * -0.25)) / ((v + -1.0) / ((r * w) * (r * w)))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 + ((0.375 + (v * -0.25)) / ((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(0.375 + Float64(v * -0.25)) / 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.375 + (v * -0.25)) / ((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[(0.375 + N[(v * -0.25), $MachinePrecision]), $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.375 + v \cdot -0.25}{\frac{v + -1}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}\right)
\end{array}
Initial program 82.1%
Simplified82.9%
fma-undefine82.9%
*-commutative82.9%
+-commutative82.9%
associate-*r/82.8%
*-commutative82.8%
associate-/l*83.6%
clear-num83.6%
un-div-inv83.6%
distribute-rgt-in83.6%
metadata-eval83.6%
*-commutative83.6%
associate-*l*83.6%
metadata-eval83.6%
associate-*r*78.6%
pow278.6%
pow278.6%
pow-prod-down99.8%
*-commutative99.8%
Applied egg-rr99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (+ 0.375 (* v -0.25))))
(if (<= v -20000000000000.0)
(+ t_0 (+ -1.5 (/ t_1 (/ (/ (/ v r) w) (* r w)))))
(if (<= v 1.0)
(+ t_0 (+ -1.5 (/ t_1 (* (/ 1.0 (* r w)) (/ (/ -1.0 r) w)))))
(+ t_0 (+ -1.5 (/ t_1 (/ (/ v (* r w)) (* r w)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = 0.375 + (v * -0.25);
double tmp;
if (v <= -20000000000000.0) {
tmp = t_0 + (-1.5 + (t_1 / (((v / r) / w) / (r * w))));
} else if (v <= 1.0) {
tmp = t_0 + (-1.5 + (t_1 / ((1.0 / (r * w)) * ((-1.0 / r) / w))));
} else {
tmp = t_0 + (-1.5 + (t_1 / ((v / (r * w)) / (r * w))));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = 0.375d0 + (v * (-0.25d0))
if (v <= (-20000000000000.0d0)) then
tmp = t_0 + ((-1.5d0) + (t_1 / (((v / r) / w) / (r * w))))
else if (v <= 1.0d0) then
tmp = t_0 + ((-1.5d0) + (t_1 / ((1.0d0 / (r * w)) * (((-1.0d0) / r) / w))))
else
tmp = t_0 + ((-1.5d0) + (t_1 / ((v / (r * w)) / (r * w))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = 0.375 + (v * -0.25);
double tmp;
if (v <= -20000000000000.0) {
tmp = t_0 + (-1.5 + (t_1 / (((v / r) / w) / (r * w))));
} else if (v <= 1.0) {
tmp = t_0 + (-1.5 + (t_1 / ((1.0 / (r * w)) * ((-1.0 / r) / w))));
} else {
tmp = t_0 + (-1.5 + (t_1 / ((v / (r * w)) / (r * w))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = 0.375 + (v * -0.25) tmp = 0 if v <= -20000000000000.0: tmp = t_0 + (-1.5 + (t_1 / (((v / r) / w) / (r * w)))) elif v <= 1.0: tmp = t_0 + (-1.5 + (t_1 / ((1.0 / (r * w)) * ((-1.0 / r) / w)))) else: tmp = t_0 + (-1.5 + (t_1 / ((v / (r * w)) / (r * w)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(0.375 + Float64(v * -0.25)) tmp = 0.0 if (v <= -20000000000000.0) tmp = Float64(t_0 + Float64(-1.5 + Float64(t_1 / Float64(Float64(Float64(v / r) / w) / Float64(r * w))))); elseif (v <= 1.0) tmp = Float64(t_0 + Float64(-1.5 + Float64(t_1 / Float64(Float64(1.0 / Float64(r * w)) * Float64(Float64(-1.0 / r) / w))))); else tmp = Float64(t_0 + Float64(-1.5 + Float64(t_1 / Float64(Float64(v / Float64(r * w)) / Float64(r * w))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = 0.375 + (v * -0.25); tmp = 0.0; if (v <= -20000000000000.0) tmp = t_0 + (-1.5 + (t_1 / (((v / r) / w) / (r * w)))); elseif (v <= 1.0) tmp = t_0 + (-1.5 + (t_1 / ((1.0 / (r * w)) * ((-1.0 / r) / w)))); else tmp = t_0 + (-1.5 + (t_1 / ((v / (r * w)) / (r * w)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -20000000000000.0], N[(t$95$0 + N[(-1.5 + N[(t$95$1 / N[(N[(N[(v / r), $MachinePrecision] / w), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 1.0], N[(t$95$0 + N[(-1.5 + N[(t$95$1 / N[(N[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(N[(-1.0 / r), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 + N[(t$95$1 / N[(N[(v / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := 0.375 + v \cdot -0.25\\
\mathbf{if}\;v \leq -20000000000000:\\
\;\;\;\;t\_0 + \left(-1.5 + \frac{t\_1}{\frac{\frac{\frac{v}{r}}{w}}{r \cdot w}}\right)\\
\mathbf{elif}\;v \leq 1:\\
\;\;\;\;t\_0 + \left(-1.5 + \frac{t\_1}{\frac{1}{r \cdot w} \cdot \frac{\frac{-1}{r}}{w}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 + \frac{t\_1}{\frac{\frac{v}{r \cdot w}}{r \cdot w}}\right)\\
\end{array}
\end{array}
if v < -2e13Initial program 83.1%
Simplified83.2%
fma-undefine83.2%
*-commutative83.2%
+-commutative83.2%
associate-*r/83.2%
*-commutative83.2%
associate-/l*84.5%
clear-num84.5%
un-div-inv84.5%
distribute-rgt-in84.5%
metadata-eval84.5%
*-commutative84.5%
associate-*l*84.5%
metadata-eval84.5%
associate-*r*78.0%
pow278.0%
pow278.0%
pow-prod-down99.7%
*-commutative99.7%
Applied egg-rr99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.6%
Applied egg-rr99.6%
associate-*l/99.7%
*-lft-identity99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in v around inf 99.5%
mul-1-neg99.5%
associate-/r*99.6%
distribute-neg-frac299.6%
Simplified99.6%
if -2e13 < v < 1Initial program 82.2%
Simplified82.3%
fma-undefine82.3%
*-commutative82.3%
+-commutative82.3%
associate-*r/82.3%
*-commutative82.3%
associate-/l*82.3%
clear-num82.2%
un-div-inv82.2%
distribute-rgt-in82.2%
metadata-eval82.2%
*-commutative82.2%
associate-*l*82.2%
metadata-eval82.2%
associate-*r*76.7%
pow276.7%
pow276.7%
pow-prod-down99.8%
*-commutative99.8%
Applied egg-rr99.8%
unpow299.8%
Applied egg-rr99.8%
associate-/r*99.8%
*-commutative99.8%
*-commutative99.8%
div-inv99.8%
associate-/l/99.8%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in v around 0 99.3%
if 1 < v Initial program 80.6%
Simplified83.7%
fma-undefine83.7%
*-commutative83.7%
+-commutative83.7%
associate-*r/83.7%
*-commutative83.7%
associate-/l*85.3%
clear-num85.3%
un-div-inv85.3%
distribute-rgt-in85.3%
metadata-eval85.3%
*-commutative85.3%
associate-*l*85.3%
metadata-eval85.3%
associate-*r*83.5%
pow283.5%
pow283.5%
pow-prod-down99.7%
*-commutative99.7%
Applied egg-rr99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-lft-identity99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in v around inf 99.5%
associate-*r/99.5%
neg-mul-199.5%
Simplified99.5%
Final simplification99.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 0.375 (* v -0.25))) (t_1 (/ 2.0 (* r r))))
(if (or (<= v -20000000000000.0) (not (<= v 1.0)))
(+ t_1 (+ -1.5 (/ t_0 (/ (/ v (* r w)) (* r w)))))
(+ t_1 (+ -1.5 (/ t_0 (/ (/ -1.0 (* r w)) (* r w))))))))
double code(double v, double w, double r) {
double t_0 = 0.375 + (v * -0.25);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -20000000000000.0) || !(v <= 1.0)) {
tmp = t_1 + (-1.5 + (t_0 / ((v / (r * w)) / (r * w))));
} else {
tmp = t_1 + (-1.5 + (t_0 / ((-1.0 / (r * w)) / (r * w))));
}
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.375d0 + (v * (-0.25d0))
t_1 = 2.0d0 / (r * r)
if ((v <= (-20000000000000.0d0)) .or. (.not. (v <= 1.0d0))) then
tmp = t_1 + ((-1.5d0) + (t_0 / ((v / (r * w)) / (r * w))))
else
tmp = t_1 + ((-1.5d0) + (t_0 / (((-1.0d0) / (r * w)) / (r * w))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 0.375 + (v * -0.25);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -20000000000000.0) || !(v <= 1.0)) {
tmp = t_1 + (-1.5 + (t_0 / ((v / (r * w)) / (r * w))));
} else {
tmp = t_1 + (-1.5 + (t_0 / ((-1.0 / (r * w)) / (r * w))));
}
return tmp;
}
def code(v, w, r): t_0 = 0.375 + (v * -0.25) t_1 = 2.0 / (r * r) tmp = 0 if (v <= -20000000000000.0) or not (v <= 1.0): tmp = t_1 + (-1.5 + (t_0 / ((v / (r * w)) / (r * w)))) else: tmp = t_1 + (-1.5 + (t_0 / ((-1.0 / (r * w)) / (r * w)))) return tmp
function code(v, w, r) t_0 = Float64(0.375 + Float64(v * -0.25)) t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -20000000000000.0) || !(v <= 1.0)) tmp = Float64(t_1 + Float64(-1.5 + Float64(t_0 / Float64(Float64(v / Float64(r * w)) / Float64(r * w))))); else tmp = Float64(t_1 + Float64(-1.5 + Float64(t_0 / Float64(Float64(-1.0 / Float64(r * w)) / Float64(r * w))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 0.375 + (v * -0.25); t_1 = 2.0 / (r * r); tmp = 0.0; if ((v <= -20000000000000.0) || ~((v <= 1.0))) tmp = t_1 + (-1.5 + (t_0 / ((v / (r * w)) / (r * w)))); else tmp = t_1 + (-1.5 + (t_0 / ((-1.0 / (r * w)) / (r * w)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -20000000000000.0], N[Not[LessEqual[v, 1.0]], $MachinePrecision]], N[(t$95$1 + N[(-1.5 + N[(t$95$0 / N[(N[(v / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(-1.5 + N[(t$95$0 / N[(N[(-1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.375 + v \cdot -0.25\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -20000000000000 \lor \neg \left(v \leq 1\right):\\
\;\;\;\;t\_1 + \left(-1.5 + \frac{t\_0}{\frac{\frac{v}{r \cdot w}}{r \cdot w}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \left(-1.5 + \frac{t\_0}{\frac{\frac{-1}{r \cdot w}}{r \cdot w}}\right)\\
\end{array}
\end{array}
if v < -2e13 or 1 < v Initial program 81.9%
Simplified83.5%
fma-undefine83.5%
*-commutative83.5%
+-commutative83.5%
associate-*r/83.4%
*-commutative83.4%
associate-/l*84.9%
clear-num84.9%
un-div-inv84.9%
distribute-rgt-in84.9%
metadata-eval84.9%
*-commutative84.9%
associate-*l*84.9%
metadata-eval84.9%
associate-*r*80.6%
pow280.6%
pow280.6%
pow-prod-down99.7%
*-commutative99.7%
Applied egg-rr99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.6%
Applied egg-rr99.6%
associate-*l/99.7%
*-lft-identity99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in v around inf 99.5%
associate-*r/99.5%
neg-mul-199.5%
Simplified99.5%
if -2e13 < v < 1Initial program 82.2%
Simplified82.3%
fma-undefine82.3%
*-commutative82.3%
+-commutative82.3%
associate-*r/82.3%
*-commutative82.3%
associate-/l*82.3%
clear-num82.2%
un-div-inv82.2%
distribute-rgt-in82.2%
metadata-eval82.2%
*-commutative82.2%
associate-*l*82.2%
metadata-eval82.2%
associate-*r*76.7%
pow276.7%
pow276.7%
pow-prod-down99.8%
*-commutative99.8%
Applied egg-rr99.8%
*-un-lft-identity99.8%
unpow299.8%
times-frac99.8%
Applied egg-rr99.8%
associate-*l/99.8%
*-lft-identity99.8%
*-commutative99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in v around 0 99.3%
Final simplification99.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (+ 0.375 (* v -0.25))))
(if (<= v -20000000000000.0)
(+ t_0 (+ -1.5 (/ t_1 (/ (/ (/ v r) w) (* r w)))))
(if (<= v 1.0)
(+ t_0 (+ -1.5 (/ t_1 (/ (/ -1.0 (* r w)) (* r w)))))
(+ t_0 (+ -1.5 (/ t_1 (/ (/ v (* r w)) (* r w)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = 0.375 + (v * -0.25);
double tmp;
if (v <= -20000000000000.0) {
tmp = t_0 + (-1.5 + (t_1 / (((v / r) / w) / (r * w))));
} else if (v <= 1.0) {
tmp = t_0 + (-1.5 + (t_1 / ((-1.0 / (r * w)) / (r * w))));
} else {
tmp = t_0 + (-1.5 + (t_1 / ((v / (r * w)) / (r * w))));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = 0.375d0 + (v * (-0.25d0))
if (v <= (-20000000000000.0d0)) then
tmp = t_0 + ((-1.5d0) + (t_1 / (((v / r) / w) / (r * w))))
else if (v <= 1.0d0) then
tmp = t_0 + ((-1.5d0) + (t_1 / (((-1.0d0) / (r * w)) / (r * w))))
else
tmp = t_0 + ((-1.5d0) + (t_1 / ((v / (r * w)) / (r * w))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = 0.375 + (v * -0.25);
double tmp;
if (v <= -20000000000000.0) {
tmp = t_0 + (-1.5 + (t_1 / (((v / r) / w) / (r * w))));
} else if (v <= 1.0) {
tmp = t_0 + (-1.5 + (t_1 / ((-1.0 / (r * w)) / (r * w))));
} else {
tmp = t_0 + (-1.5 + (t_1 / ((v / (r * w)) / (r * w))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = 0.375 + (v * -0.25) tmp = 0 if v <= -20000000000000.0: tmp = t_0 + (-1.5 + (t_1 / (((v / r) / w) / (r * w)))) elif v <= 1.0: tmp = t_0 + (-1.5 + (t_1 / ((-1.0 / (r * w)) / (r * w)))) else: tmp = t_0 + (-1.5 + (t_1 / ((v / (r * w)) / (r * w)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(0.375 + Float64(v * -0.25)) tmp = 0.0 if (v <= -20000000000000.0) tmp = Float64(t_0 + Float64(-1.5 + Float64(t_1 / Float64(Float64(Float64(v / r) / w) / Float64(r * w))))); elseif (v <= 1.0) tmp = Float64(t_0 + Float64(-1.5 + Float64(t_1 / Float64(Float64(-1.0 / Float64(r * w)) / Float64(r * w))))); else tmp = Float64(t_0 + Float64(-1.5 + Float64(t_1 / Float64(Float64(v / Float64(r * w)) / Float64(r * w))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = 0.375 + (v * -0.25); tmp = 0.0; if (v <= -20000000000000.0) tmp = t_0 + (-1.5 + (t_1 / (((v / r) / w) / (r * w)))); elseif (v <= 1.0) tmp = t_0 + (-1.5 + (t_1 / ((-1.0 / (r * w)) / (r * w)))); else tmp = t_0 + (-1.5 + (t_1 / ((v / (r * w)) / (r * w)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -20000000000000.0], N[(t$95$0 + N[(-1.5 + N[(t$95$1 / N[(N[(N[(v / r), $MachinePrecision] / w), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 1.0], N[(t$95$0 + N[(-1.5 + N[(t$95$1 / N[(N[(-1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 + N[(t$95$1 / N[(N[(v / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := 0.375 + v \cdot -0.25\\
\mathbf{if}\;v \leq -20000000000000:\\
\;\;\;\;t\_0 + \left(-1.5 + \frac{t\_1}{\frac{\frac{\frac{v}{r}}{w}}{r \cdot w}}\right)\\
\mathbf{elif}\;v \leq 1:\\
\;\;\;\;t\_0 + \left(-1.5 + \frac{t\_1}{\frac{\frac{-1}{r \cdot w}}{r \cdot w}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 + \frac{t\_1}{\frac{\frac{v}{r \cdot w}}{r \cdot w}}\right)\\
\end{array}
\end{array}
if v < -2e13Initial program 83.1%
Simplified83.2%
fma-undefine83.2%
*-commutative83.2%
+-commutative83.2%
associate-*r/83.2%
*-commutative83.2%
associate-/l*84.5%
clear-num84.5%
un-div-inv84.5%
distribute-rgt-in84.5%
metadata-eval84.5%
*-commutative84.5%
associate-*l*84.5%
metadata-eval84.5%
associate-*r*78.0%
pow278.0%
pow278.0%
pow-prod-down99.7%
*-commutative99.7%
Applied egg-rr99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.6%
Applied egg-rr99.6%
associate-*l/99.7%
*-lft-identity99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in v around inf 99.5%
mul-1-neg99.5%
associate-/r*99.6%
distribute-neg-frac299.6%
Simplified99.6%
if -2e13 < v < 1Initial program 82.2%
Simplified82.3%
fma-undefine82.3%
*-commutative82.3%
+-commutative82.3%
associate-*r/82.3%
*-commutative82.3%
associate-/l*82.3%
clear-num82.2%
un-div-inv82.2%
distribute-rgt-in82.2%
metadata-eval82.2%
*-commutative82.2%
associate-*l*82.2%
metadata-eval82.2%
associate-*r*76.7%
pow276.7%
pow276.7%
pow-prod-down99.8%
*-commutative99.8%
Applied egg-rr99.8%
*-un-lft-identity99.8%
unpow299.8%
times-frac99.8%
Applied egg-rr99.8%
associate-*l/99.8%
*-lft-identity99.8%
*-commutative99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in v around 0 99.3%
if 1 < v Initial program 80.6%
Simplified83.7%
fma-undefine83.7%
*-commutative83.7%
+-commutative83.7%
associate-*r/83.7%
*-commutative83.7%
associate-/l*85.3%
clear-num85.3%
un-div-inv85.3%
distribute-rgt-in85.3%
metadata-eval85.3%
*-commutative85.3%
associate-*l*85.3%
metadata-eval85.3%
associate-*r*83.5%
pow283.5%
pow283.5%
pow-prod-down99.7%
*-commutative99.7%
Applied egg-rr99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-lft-identity99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in v around inf 99.5%
associate-*r/99.5%
neg-mul-199.5%
Simplified99.5%
Final simplification99.4%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (+ -1.5 (/ (+ 0.375 (* v -0.25)) (/ (/ -1.0 (* r w)) (* r w))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + ((0.375 + (v * -0.25)) / ((-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.375d0 + (v * (-0.25d0))) / (((-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.375 + (v * -0.25)) / ((-1.0 / (r * w)) / (r * w))));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 + ((0.375 + (v * -0.25)) / ((-1.0 / (r * w)) / (r * w))))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(Float64(0.375 + Float64(v * -0.25)) / Float64(Float64(-1.0 / Float64(r * w)) / Float64(r * w))))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 + ((0.375 + (v * -0.25)) / ((-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[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 + \frac{0.375 + v \cdot -0.25}{\frac{\frac{-1}{r \cdot w}}{r \cdot w}}\right)
\end{array}
Initial program 82.1%
Simplified82.9%
fma-undefine82.9%
*-commutative82.9%
+-commutative82.9%
associate-*r/82.8%
*-commutative82.8%
associate-/l*83.6%
clear-num83.6%
un-div-inv83.6%
distribute-rgt-in83.6%
metadata-eval83.6%
*-commutative83.6%
associate-*l*83.6%
metadata-eval83.6%
associate-*r*78.6%
pow278.6%
pow278.6%
pow-prod-down99.8%
*-commutative99.8%
Applied egg-rr99.8%
*-un-lft-identity99.8%
unpow299.8%
times-frac99.7%
Applied egg-rr99.7%
associate-*l/99.8%
*-lft-identity99.8%
*-commutative99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in v around 0 82.9%
Final simplification82.9%
(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 82.1%
Simplified76.9%
Taylor expanded in r around 0 62.4%
Final simplification62.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 82.1%
Simplified76.9%
Taylor expanded in r around 0 62.4%
Taylor expanded in r around inf 14.4%
Final simplification14.4%
herbie shell --seed 2024077
(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))