
(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 6 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)) (* (/ (+ -0.375 (* v 0.25)) (- 1.0 v)) (* (* r w) (* r w)))) -1.5))
double code(double v, double w, double r) {
return ((2.0 / (r * r)) + (((-0.375 + (v * 0.25)) / (1.0 - v)) * ((r * w) * (r * w)))) + -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)) + ((((-0.375d0) + (v * 0.25d0)) / (1.0d0 - v)) * ((r * w) * (r * w)))) + (-1.5d0)
end function
public static double code(double v, double w, double r) {
return ((2.0 / (r * r)) + (((-0.375 + (v * 0.25)) / (1.0 - v)) * ((r * w) * (r * w)))) + -1.5;
}
def code(v, w, r): return ((2.0 / (r * r)) + (((-0.375 + (v * 0.25)) / (1.0 - v)) * ((r * w) * (r * w)))) + -1.5
function code(v, w, r) return Float64(Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(-0.375 + Float64(v * 0.25)) / Float64(1.0 - v)) * Float64(Float64(r * w) * Float64(r * w)))) + -1.5) end
function tmp = code(v, w, r) tmp = ((2.0 / (r * r)) + (((-0.375 + (v * 0.25)) / (1.0 - v)) * ((r * w) * (r * w)))) + -1.5; end
code[v_, w_, r_] := N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-0.375 + N[(v * 0.25), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{2}{r \cdot r} + \frac{-0.375 + v \cdot 0.25}{1 - v} \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right) + -1.5
\end{array}
Initial program 86.1%
Simplified89.4%
Taylor expanded in r around 0 84.8%
unpow284.8%
unpow284.8%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ (/ 1.0 w) r)) (t_1 (/ 2.0 (* r r))))
(if (<= v -500.0)
(+ -1.5 (+ t_1 (* -0.25 (/ w (/ t_0 r)))))
(if (<= v 2.5e-99)
(- (+ t_1 -1.5) (/ (* r (* w 0.375)) t_0))
(+ -1.5 (+ t_1 (* (* (* r w) (* r w)) -0.25)))))))
double code(double v, double w, double r) {
double t_0 = (1.0 / w) / r;
double t_1 = 2.0 / (r * r);
double tmp;
if (v <= -500.0) {
tmp = -1.5 + (t_1 + (-0.25 * (w / (t_0 / r))));
} else if (v <= 2.5e-99) {
tmp = (t_1 + -1.5) - ((r * (w * 0.375)) / t_0);
} else {
tmp = -1.5 + (t_1 + (((r * w) * (r * w)) * -0.25));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (1.0d0 / w) / r
t_1 = 2.0d0 / (r * r)
if (v <= (-500.0d0)) then
tmp = (-1.5d0) + (t_1 + ((-0.25d0) * (w / (t_0 / r))))
else if (v <= 2.5d-99) then
tmp = (t_1 + (-1.5d0)) - ((r * (w * 0.375d0)) / t_0)
else
tmp = (-1.5d0) + (t_1 + (((r * w) * (r * w)) * (-0.25d0)))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = (1.0 / w) / r;
double t_1 = 2.0 / (r * r);
double tmp;
if (v <= -500.0) {
tmp = -1.5 + (t_1 + (-0.25 * (w / (t_0 / r))));
} else if (v <= 2.5e-99) {
tmp = (t_1 + -1.5) - ((r * (w * 0.375)) / t_0);
} else {
tmp = -1.5 + (t_1 + (((r * w) * (r * w)) * -0.25));
}
return tmp;
}
def code(v, w, r): t_0 = (1.0 / w) / r t_1 = 2.0 / (r * r) tmp = 0 if v <= -500.0: tmp = -1.5 + (t_1 + (-0.25 * (w / (t_0 / r)))) elif v <= 2.5e-99: tmp = (t_1 + -1.5) - ((r * (w * 0.375)) / t_0) else: tmp = -1.5 + (t_1 + (((r * w) * (r * w)) * -0.25)) return tmp
function code(v, w, r) t_0 = Float64(Float64(1.0 / w) / r) t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (v <= -500.0) tmp = Float64(-1.5 + Float64(t_1 + Float64(-0.25 * Float64(w / Float64(t_0 / r))))); elseif (v <= 2.5e-99) tmp = Float64(Float64(t_1 + -1.5) - Float64(Float64(r * Float64(w * 0.375)) / t_0)); else tmp = Float64(-1.5 + Float64(t_1 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.25))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (1.0 / w) / r; t_1 = 2.0 / (r * r); tmp = 0.0; if (v <= -500.0) tmp = -1.5 + (t_1 + (-0.25 * (w / (t_0 / r)))); elseif (v <= 2.5e-99) tmp = (t_1 + -1.5) - ((r * (w * 0.375)) / t_0); else tmp = -1.5 + (t_1 + (((r * w) * (r * w)) * -0.25)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(1.0 / w), $MachinePrecision] / r), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -500.0], N[(-1.5 + N[(t$95$1 + N[(-0.25 * N[(w / N[(t$95$0 / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 2.5e-99], N[(N[(t$95$1 + -1.5), $MachinePrecision] - N[(N[(r * N[(w * 0.375), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(t$95$1 + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{w}}{r}\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -500:\\
\;\;\;\;-1.5 + \left(t_1 + -0.25 \cdot \frac{w}{\frac{t_0}{r}}\right)\\
\mathbf{elif}\;v \leq 2.5 \cdot 10^{-99}:\\
\;\;\;\;\left(t_1 + -1.5\right) - \frac{r \cdot \left(w \cdot 0.375\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(t_1 + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.25\right)\\
\end{array}
\end{array}
if v < -500Initial program 80.6%
Simplified86.3%
Taylor expanded in r around 0 86.2%
unpow286.2%
unpow286.2%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
Taylor expanded in v around inf 97.9%
associate-*r*98.0%
/-rgt-identity98.0%
associate-/r/98.0%
associate-/l*97.9%
*-commutative97.9%
associate-/l*98.0%
Applied egg-rr98.0%
if -500 < v < 2.49999999999999985e-99Initial program 92.4%
Simplified97.1%
Taylor expanded in v around 0 86.6%
*-commutative86.6%
unpow286.6%
unpow286.6%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
associate-*r*99.0%
/-rgt-identity99.0%
associate-/r/99.0%
clear-num99.0%
clear-num99.0%
associate-/l*99.8%
associate-*l/99.8%
associate-*l*99.9%
Applied egg-rr99.9%
if 2.49999999999999985e-99 < v Initial program 81.9%
Simplified87.8%
Taylor expanded in r around 0 81.5%
unpow281.5%
unpow281.5%
swap-sqr99.9%
unpow299.9%
Simplified99.9%
unpow299.9%
Applied egg-rr99.9%
Taylor expanded in v around inf 99.9%
Final simplification99.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (* (* r w) (* r w))))
(if (<= v -480.0)
(+ -1.5 (+ t_0 (* t_1 (+ (/ 0.125 v) -0.25))))
(if (<= v 2.5e-99)
(- (+ t_0 -1.5) (/ (* r (* w 0.375)) (/ (/ 1.0 w) r)))
(+ -1.5 (+ t_0 (* t_1 -0.25)))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = (r * w) * (r * w);
double tmp;
if (v <= -480.0) {
tmp = -1.5 + (t_0 + (t_1 * ((0.125 / v) + -0.25)));
} else if (v <= 2.5e-99) {
tmp = (t_0 + -1.5) - ((r * (w * 0.375)) / ((1.0 / w) / r));
} else {
tmp = -1.5 + (t_0 + (t_1 * -0.25));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = (r * w) * (r * w)
if (v <= (-480.0d0)) then
tmp = (-1.5d0) + (t_0 + (t_1 * ((0.125d0 / v) + (-0.25d0))))
else if (v <= 2.5d-99) then
tmp = (t_0 + (-1.5d0)) - ((r * (w * 0.375d0)) / ((1.0d0 / w) / r))
else
tmp = (-1.5d0) + (t_0 + (t_1 * (-0.25d0)))
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 = (r * w) * (r * w);
double tmp;
if (v <= -480.0) {
tmp = -1.5 + (t_0 + (t_1 * ((0.125 / v) + -0.25)));
} else if (v <= 2.5e-99) {
tmp = (t_0 + -1.5) - ((r * (w * 0.375)) / ((1.0 / w) / r));
} else {
tmp = -1.5 + (t_0 + (t_1 * -0.25));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = (r * w) * (r * w) tmp = 0 if v <= -480.0: tmp = -1.5 + (t_0 + (t_1 * ((0.125 / v) + -0.25))) elif v <= 2.5e-99: tmp = (t_0 + -1.5) - ((r * (w * 0.375)) / ((1.0 / w) / r)) else: tmp = -1.5 + (t_0 + (t_1 * -0.25)) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(Float64(r * w) * Float64(r * w)) tmp = 0.0 if (v <= -480.0) tmp = Float64(-1.5 + Float64(t_0 + Float64(t_1 * Float64(Float64(0.125 / v) + -0.25)))); elseif (v <= 2.5e-99) tmp = Float64(Float64(t_0 + -1.5) - Float64(Float64(r * Float64(w * 0.375)) / Float64(Float64(1.0 / w) / r))); else tmp = Float64(-1.5 + Float64(t_0 + Float64(t_1 * -0.25))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = (r * w) * (r * w); tmp = 0.0; if (v <= -480.0) tmp = -1.5 + (t_0 + (t_1 * ((0.125 / v) + -0.25))); elseif (v <= 2.5e-99) tmp = (t_0 + -1.5) - ((r * (w * 0.375)) / ((1.0 / w) / r)); else tmp = -1.5 + (t_0 + (t_1 * -0.25)); 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[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -480.0], N[(-1.5 + N[(t$95$0 + N[(t$95$1 * N[(N[(0.125 / v), $MachinePrecision] + -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 2.5e-99], N[(N[(t$95$0 + -1.5), $MachinePrecision] - N[(N[(r * N[(w * 0.375), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / w), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(t$95$0 + N[(t$95$1 * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := \left(r \cdot w\right) \cdot \left(r \cdot w\right)\\
\mathbf{if}\;v \leq -480:\\
\;\;\;\;-1.5 + \left(t_0 + t_1 \cdot \left(\frac{0.125}{v} + -0.25\right)\right)\\
\mathbf{elif}\;v \leq 2.5 \cdot 10^{-99}:\\
\;\;\;\;\left(t_0 + -1.5\right) - \frac{r \cdot \left(w \cdot 0.375\right)}{\frac{\frac{1}{w}}{r}}\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(t_0 + t_1 \cdot -0.25\right)\\
\end{array}
\end{array}
if v < -480Initial program 80.6%
Simplified86.3%
Taylor expanded in r around 0 86.2%
unpow286.2%
unpow286.2%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
Taylor expanded in v around inf 98.6%
sub-neg98.6%
associate-*r/98.6%
metadata-eval98.6%
metadata-eval98.6%
Simplified98.6%
if -480 < v < 2.49999999999999985e-99Initial program 92.4%
Simplified97.1%
Taylor expanded in v around 0 86.6%
*-commutative86.6%
unpow286.6%
unpow286.6%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
associate-*r*99.0%
/-rgt-identity99.0%
associate-/r/99.0%
clear-num99.0%
clear-num99.0%
associate-/l*99.8%
associate-*l/99.8%
associate-*l*99.9%
Applied egg-rr99.9%
if 2.49999999999999985e-99 < v Initial program 81.9%
Simplified87.8%
Taylor expanded in r around 0 81.5%
unpow281.5%
unpow281.5%
swap-sqr99.9%
unpow299.9%
Simplified99.9%
unpow299.9%
Applied egg-rr99.9%
Taylor expanded in v around inf 99.9%
Final simplification99.6%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -470.0) (not (<= v 2.5e-99)))
(+ -1.5 (+ t_0 (* (* (* r w) (* r w)) -0.25)))
(- (+ t_0 -1.5) (* (* r w) (* r (* w 0.375)))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -470.0) || !(v <= 2.5e-99)) {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
} else {
tmp = (t_0 + -1.5) - ((r * w) * (r * (w * 0.375)));
}
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 ((v <= (-470.0d0)) .or. (.not. (v <= 2.5d-99))) then
tmp = (-1.5d0) + (t_0 + (((r * w) * (r * w)) * (-0.25d0)))
else
tmp = (t_0 + (-1.5d0)) - ((r * w) * (r * (w * 0.375d0)))
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 ((v <= -470.0) || !(v <= 2.5e-99)) {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
} else {
tmp = (t_0 + -1.5) - ((r * w) * (r * (w * 0.375)));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -470.0) or not (v <= 2.5e-99): tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)) else: tmp = (t_0 + -1.5) - ((r * w) * (r * (w * 0.375))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -470.0) || !(v <= 2.5e-99)) tmp = Float64(-1.5 + Float64(t_0 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.25))); else tmp = Float64(Float64(t_0 + -1.5) - Float64(Float64(r * w) * Float64(r * Float64(w * 0.375)))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -470.0) || ~((v <= 2.5e-99))) tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)); else tmp = (t_0 + -1.5) - ((r * w) * (r * (w * 0.375))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -470.0], N[Not[LessEqual[v, 2.5e-99]], $MachinePrecision]], N[(-1.5 + N[(t$95$0 + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + -1.5), $MachinePrecision] - N[(N[(r * w), $MachinePrecision] * N[(r * N[(w * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -470 \lor \neg \left(v \leq 2.5 \cdot 10^{-99}\right):\\
\;\;\;\;-1.5 + \left(t_0 + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 + -1.5\right) - \left(r \cdot w\right) \cdot \left(r \cdot \left(w \cdot 0.375\right)\right)\\
\end{array}
\end{array}
if v < -470 or 2.49999999999999985e-99 < v Initial program 81.3%
Simplified87.1%
Taylor expanded in r around 0 83.5%
unpow283.5%
unpow283.5%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.0%
if -470 < v < 2.49999999999999985e-99Initial program 92.4%
Simplified97.1%
Taylor expanded in v around 0 86.6%
*-commutative86.6%
unpow286.6%
unpow286.6%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
associate-*r*99.0%
/-rgt-identity99.0%
associate-/r/99.0%
clear-num99.0%
clear-num99.0%
associate-/l*99.8%
associate-*l/99.8%
associate-*l*99.9%
Applied egg-rr99.9%
div-inv99.9%
associate-/l/99.9%
remove-double-div99.9%
Applied egg-rr99.9%
Final simplification99.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= v -500.0)
(+ -1.5 (+ t_0 (* -0.25 (/ w (/ (/ (/ 1.0 w) r) r)))))
(if (<= v 2.5e-99)
(- (+ t_0 -1.5) (* (* r w) (* r (* w 0.375))))
(+ -1.5 (+ t_0 (* (* (* r w) (* r w)) -0.25)))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (v <= -500.0) {
tmp = -1.5 + (t_0 + (-0.25 * (w / (((1.0 / w) / r) / r))));
} else if (v <= 2.5e-99) {
tmp = (t_0 + -1.5) - ((r * w) * (r * (w * 0.375)));
} else {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if (v <= (-500.0d0)) then
tmp = (-1.5d0) + (t_0 + ((-0.25d0) * (w / (((1.0d0 / w) / r) / r))))
else if (v <= 2.5d-99) then
tmp = (t_0 + (-1.5d0)) - ((r * w) * (r * (w * 0.375d0)))
else
tmp = (-1.5d0) + (t_0 + (((r * w) * (r * w)) * (-0.25d0)))
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 (v <= -500.0) {
tmp = -1.5 + (t_0 + (-0.25 * (w / (((1.0 / w) / r) / r))));
} else if (v <= 2.5e-99) {
tmp = (t_0 + -1.5) - ((r * w) * (r * (w * 0.375)));
} else {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if v <= -500.0: tmp = -1.5 + (t_0 + (-0.25 * (w / (((1.0 / w) / r) / r)))) elif v <= 2.5e-99: tmp = (t_0 + -1.5) - ((r * w) * (r * (w * 0.375))) else: tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (v <= -500.0) tmp = Float64(-1.5 + Float64(t_0 + Float64(-0.25 * Float64(w / Float64(Float64(Float64(1.0 / w) / r) / r))))); elseif (v <= 2.5e-99) tmp = Float64(Float64(t_0 + -1.5) - Float64(Float64(r * w) * Float64(r * Float64(w * 0.375)))); else tmp = Float64(-1.5 + Float64(t_0 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.25))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (v <= -500.0) tmp = -1.5 + (t_0 + (-0.25 * (w / (((1.0 / w) / r) / r)))); elseif (v <= 2.5e-99) tmp = (t_0 + -1.5) - ((r * w) * (r * (w * 0.375))); else tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -500.0], N[(-1.5 + N[(t$95$0 + N[(-0.25 * N[(w / N[(N[(N[(1.0 / w), $MachinePrecision] / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 2.5e-99], N[(N[(t$95$0 + -1.5), $MachinePrecision] - N[(N[(r * w), $MachinePrecision] * N[(r * N[(w * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(t$95$0 + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -500:\\
\;\;\;\;-1.5 + \left(t_0 + -0.25 \cdot \frac{w}{\frac{\frac{\frac{1}{w}}{r}}{r}}\right)\\
\mathbf{elif}\;v \leq 2.5 \cdot 10^{-99}:\\
\;\;\;\;\left(t_0 + -1.5\right) - \left(r \cdot w\right) \cdot \left(r \cdot \left(w \cdot 0.375\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(t_0 + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.25\right)\\
\end{array}
\end{array}
if v < -500Initial program 80.6%
Simplified86.3%
Taylor expanded in r around 0 86.2%
unpow286.2%
unpow286.2%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
Taylor expanded in v around inf 97.9%
associate-*r*98.0%
/-rgt-identity98.0%
associate-/r/98.0%
associate-/l*97.9%
*-commutative97.9%
associate-/l*98.0%
Applied egg-rr98.0%
if -500 < v < 2.49999999999999985e-99Initial program 92.4%
Simplified97.1%
Taylor expanded in v around 0 86.6%
*-commutative86.6%
unpow286.6%
unpow286.6%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
associate-*r*99.0%
/-rgt-identity99.0%
associate-/r/99.0%
clear-num99.0%
clear-num99.0%
associate-/l*99.8%
associate-*l/99.8%
associate-*l*99.9%
Applied egg-rr99.9%
div-inv99.9%
associate-/l/99.9%
remove-double-div99.9%
Applied egg-rr99.9%
if 2.49999999999999985e-99 < v Initial program 81.9%
Simplified87.8%
Taylor expanded in r around 0 81.5%
unpow281.5%
unpow281.5%
swap-sqr99.9%
unpow299.9%
Simplified99.9%
unpow299.9%
Applied egg-rr99.9%
Taylor expanded in v around inf 99.9%
Final simplification99.4%
(FPCore (v w r) :precision binary64 (+ -1.5 (+ (/ 2.0 (* r r)) (* (* (* r w) (* r w)) -0.25))))
double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (((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 = (-1.5d0) + ((2.0d0 / (r * r)) + (((r * w) * (r * w)) * (-0.25d0)))
end function
public static double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.25));
}
def code(v, w, r): return -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.25))
function code(v, w, r) return Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.25))) end
function tmp = code(v, w, r) tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.25)); end
code[v_, w_, r_] := N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1.5 + \left(\frac{2}{r \cdot r} + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.25\right)
\end{array}
Initial program 86.1%
Simplified89.4%
Taylor expanded in r around 0 84.8%
unpow284.8%
unpow284.8%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 95.7%
Final simplification95.7%
herbie shell --seed 2023318
(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))