
(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)) (* (/ (+ -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 82.7%
Simplified86.7%
Taylor expanded in r around 0 82.2%
unpow282.2%
unpow282.2%
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 (/ 2.0 (* r r))) (t_1 (* (* r w) (* r w))))
(if (<= v -3.1e+26)
(+ -1.5 (+ t_0 (* t_1 -0.25)))
(if (<= v 3.8e-5)
(+ -1.5 (+ t_0 (* -0.375 (/ (* r w) (/ (/ 1.0 r) w)))))
(+ -1.5 (+ t_0 (* t_1 (+ -0.25 (/ 0.125 v)))))))))
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 <= -3.1e+26) {
tmp = -1.5 + (t_0 + (t_1 * -0.25));
} else if (v <= 3.8e-5) {
tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / ((1.0 / r) / w))));
} else {
tmp = -1.5 + (t_0 + (t_1 * (-0.25 + (0.125 / 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) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = (r * w) * (r * w)
if (v <= (-3.1d+26)) then
tmp = (-1.5d0) + (t_0 + (t_1 * (-0.25d0)))
else if (v <= 3.8d-5) then
tmp = (-1.5d0) + (t_0 + ((-0.375d0) * ((r * w) / ((1.0d0 / r) / w))))
else
tmp = (-1.5d0) + (t_0 + (t_1 * ((-0.25d0) + (0.125d0 / 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 t_1 = (r * w) * (r * w);
double tmp;
if (v <= -3.1e+26) {
tmp = -1.5 + (t_0 + (t_1 * -0.25));
} else if (v <= 3.8e-5) {
tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / ((1.0 / r) / w))));
} else {
tmp = -1.5 + (t_0 + (t_1 * (-0.25 + (0.125 / v))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = (r * w) * (r * w) tmp = 0 if v <= -3.1e+26: tmp = -1.5 + (t_0 + (t_1 * -0.25)) elif v <= 3.8e-5: tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / ((1.0 / r) / w)))) else: tmp = -1.5 + (t_0 + (t_1 * (-0.25 + (0.125 / v)))) 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 <= -3.1e+26) tmp = Float64(-1.5 + Float64(t_0 + Float64(t_1 * -0.25))); elseif (v <= 3.8e-5) tmp = Float64(-1.5 + Float64(t_0 + Float64(-0.375 * Float64(Float64(r * w) / Float64(Float64(1.0 / r) / w))))); else tmp = Float64(-1.5 + Float64(t_0 + Float64(t_1 * Float64(-0.25 + Float64(0.125 / v))))); 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 <= -3.1e+26) tmp = -1.5 + (t_0 + (t_1 * -0.25)); elseif (v <= 3.8e-5) tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / ((1.0 / r) / w)))); else tmp = -1.5 + (t_0 + (t_1 * (-0.25 + (0.125 / v)))); 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, -3.1e+26], N[(-1.5 + N[(t$95$0 + N[(t$95$1 * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 3.8e-5], N[(-1.5 + N[(t$95$0 + N[(-0.375 * N[(N[(r * w), $MachinePrecision] / N[(N[(1.0 / r), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(t$95$0 + N[(t$95$1 * N[(-0.25 + N[(0.125 / v), $MachinePrecision]), $MachinePrecision]), $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 -3.1 \cdot 10^{+26}:\\
\;\;\;\;-1.5 + \left(t_0 + t_1 \cdot -0.25\right)\\
\mathbf{elif}\;v \leq 3.8 \cdot 10^{-5}:\\
\;\;\;\;-1.5 + \left(t_0 + -0.375 \cdot \frac{r \cdot w}{\frac{\frac{1}{r}}{w}}\right)\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(t_0 + t_1 \cdot \left(-0.25 + \frac{0.125}{v}\right)\right)\\
\end{array}
\end{array}
if v < -3.1e26Initial program 78.1%
Simplified86.0%
Taylor expanded in r around 0 81.8%
unpow281.8%
unpow281.8%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
Taylor expanded in v around inf 99.7%
if -3.1e26 < v < 3.8000000000000002e-5Initial program 88.3%
Simplified88.3%
Taylor expanded in v around 0 82.8%
*-commutative82.8%
unpow282.8%
unpow282.8%
swap-sqr99.2%
unpow299.2%
Simplified99.2%
unpow299.2%
remove-double-div99.2%
un-div-inv99.2%
Applied egg-rr99.2%
inv-pow99.2%
*-commutative99.2%
unpow-prod-down99.2%
inv-pow99.2%
inv-pow99.2%
Applied egg-rr99.2%
Taylor expanded in w around 0 99.2%
associate-/r*99.2%
Simplified99.2%
if 3.8000000000000002e-5 < v Initial program 76.4%
Simplified84.1%
Taylor expanded in r around 0 80.4%
unpow280.4%
unpow280.4%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 98.7%
sub-neg98.7%
associate-*r/98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Final simplification99.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (* (* r w) (* r w))))
(if (<= v -1.0)
(+ -1.5 (+ t_0 (* t_1 -0.25)))
(if (<= v 3.8e-5)
(+ -1.5 (+ t_0 (* t_1 (- (* v -0.125) 0.375))))
(+ -1.5 (+ t_0 (* t_1 (+ -0.25 (/ 0.125 v)))))))))
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 <= -1.0) {
tmp = -1.5 + (t_0 + (t_1 * -0.25));
} else if (v <= 3.8e-5) {
tmp = -1.5 + (t_0 + (t_1 * ((v * -0.125) - 0.375)));
} else {
tmp = -1.5 + (t_0 + (t_1 * (-0.25 + (0.125 / 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) :: t_1
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
t_1 = (r * w) * (r * w)
if (v <= (-1.0d0)) then
tmp = (-1.5d0) + (t_0 + (t_1 * (-0.25d0)))
else if (v <= 3.8d-5) then
tmp = (-1.5d0) + (t_0 + (t_1 * ((v * (-0.125d0)) - 0.375d0)))
else
tmp = (-1.5d0) + (t_0 + (t_1 * ((-0.25d0) + (0.125d0 / 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 t_1 = (r * w) * (r * w);
double tmp;
if (v <= -1.0) {
tmp = -1.5 + (t_0 + (t_1 * -0.25));
} else if (v <= 3.8e-5) {
tmp = -1.5 + (t_0 + (t_1 * ((v * -0.125) - 0.375)));
} else {
tmp = -1.5 + (t_0 + (t_1 * (-0.25 + (0.125 / v))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = (r * w) * (r * w) tmp = 0 if v <= -1.0: tmp = -1.5 + (t_0 + (t_1 * -0.25)) elif v <= 3.8e-5: tmp = -1.5 + (t_0 + (t_1 * ((v * -0.125) - 0.375))) else: tmp = -1.5 + (t_0 + (t_1 * (-0.25 + (0.125 / v)))) 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 <= -1.0) tmp = Float64(-1.5 + Float64(t_0 + Float64(t_1 * -0.25))); elseif (v <= 3.8e-5) tmp = Float64(-1.5 + Float64(t_0 + Float64(t_1 * Float64(Float64(v * -0.125) - 0.375)))); else tmp = Float64(-1.5 + Float64(t_0 + Float64(t_1 * Float64(-0.25 + Float64(0.125 / v))))); 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 <= -1.0) tmp = -1.5 + (t_0 + (t_1 * -0.25)); elseif (v <= 3.8e-5) tmp = -1.5 + (t_0 + (t_1 * ((v * -0.125) - 0.375))); else tmp = -1.5 + (t_0 + (t_1 * (-0.25 + (0.125 / v)))); 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, -1.0], N[(-1.5 + N[(t$95$0 + N[(t$95$1 * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 3.8e-5], N[(-1.5 + N[(t$95$0 + N[(t$95$1 * N[(N[(v * -0.125), $MachinePrecision] - 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(t$95$0 + N[(t$95$1 * N[(-0.25 + N[(0.125 / v), $MachinePrecision]), $MachinePrecision]), $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 -1:\\
\;\;\;\;-1.5 + \left(t_0 + t_1 \cdot -0.25\right)\\
\mathbf{elif}\;v \leq 3.8 \cdot 10^{-5}:\\
\;\;\;\;-1.5 + \left(t_0 + t_1 \cdot \left(v \cdot -0.125 - 0.375\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(t_0 + t_1 \cdot \left(-0.25 + \frac{0.125}{v}\right)\right)\\
\end{array}
\end{array}
if v < -1Initial program 79.8%
Simplified87.1%
Taylor expanded in r around 0 83.2%
unpow283.2%
unpow283.2%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
Taylor expanded in v around inf 99.7%
if -1 < v < 3.8000000000000002e-5Initial program 87.8%
Simplified87.8%
Taylor expanded in r around 0 82.5%
unpow282.5%
unpow282.5%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.4%
if 3.8000000000000002e-5 < v Initial program 76.4%
Simplified84.1%
Taylor expanded in r around 0 80.4%
unpow280.4%
unpow280.4%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 98.7%
sub-neg98.7%
associate-*r/98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Final simplification99.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -3.2e+26) (not (<= v 3.8e-5)))
(+ -1.5 (+ t_0 (* (* (* r w) (* r w)) -0.25)))
(+ -1.5 (+ t_0 (* -0.375 (/ (* r w) (/ 1.0 (* r w)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -3.2e+26) || !(v <= 3.8e-5)) {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
} else {
tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / (1.0 / (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) :: tmp
t_0 = 2.0d0 / (r * r)
if ((v <= (-3.2d+26)) .or. (.not. (v <= 3.8d-5))) then
tmp = (-1.5d0) + (t_0 + (((r * w) * (r * w)) * (-0.25d0)))
else
tmp = (-1.5d0) + (t_0 + ((-0.375d0) * ((r * w) / (1.0d0 / (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 tmp;
if ((v <= -3.2e+26) || !(v <= 3.8e-5)) {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
} else {
tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / (1.0 / (r * w)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -3.2e+26) or not (v <= 3.8e-5): tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)) else: tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / (1.0 / (r * w))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -3.2e+26) || !(v <= 3.8e-5)) tmp = Float64(-1.5 + Float64(t_0 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.25))); else tmp = Float64(-1.5 + Float64(t_0 + Float64(-0.375 * Float64(Float64(r * w) / Float64(1.0 / Float64(r * w)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -3.2e+26) || ~((v <= 3.8e-5))) tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)); else tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / (1.0 / (r * w))))); 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, -3.2e+26], N[Not[LessEqual[v, 3.8e-5]], $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[(-1.5 + N[(t$95$0 + N[(-0.375 * N[(N[(r * w), $MachinePrecision] / N[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -3.2 \cdot 10^{+26} \lor \neg \left(v \leq 3.8 \cdot 10^{-5}\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}:\\
\;\;\;\;-1.5 + \left(t_0 + -0.375 \cdot \frac{r \cdot w}{\frac{1}{r \cdot w}}\right)\\
\end{array}
\end{array}
if v < -3.20000000000000029e26 or 3.8000000000000002e-5 < v Initial program 77.3%
Simplified85.1%
Taylor expanded in r around 0 81.1%
unpow281.1%
unpow281.1%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.2%
if -3.20000000000000029e26 < v < 3.8000000000000002e-5Initial program 88.3%
Simplified88.3%
Taylor expanded in v around 0 82.8%
*-commutative82.8%
unpow282.8%
unpow282.8%
swap-sqr99.2%
unpow299.2%
Simplified99.2%
unpow299.2%
remove-double-div99.2%
un-div-inv99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -3.1e+26) (not (<= v 5e-9)))
(+ -1.5 (+ t_0 (* (* (* r w) (* r w)) -0.25)))
(+ -1.5 (+ t_0 (* -0.375 (/ (* r w) (/ (/ 1.0 r) w))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -3.1e+26) || !(v <= 5e-9)) {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
} else {
tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / ((1.0 / 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) :: tmp
t_0 = 2.0d0 / (r * r)
if ((v <= (-3.1d+26)) .or. (.not. (v <= 5d-9))) then
tmp = (-1.5d0) + (t_0 + (((r * w) * (r * w)) * (-0.25d0)))
else
tmp = (-1.5d0) + (t_0 + ((-0.375d0) * ((r * w) / ((1.0d0 / 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 tmp;
if ((v <= -3.1e+26) || !(v <= 5e-9)) {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
} else {
tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / ((1.0 / r) / w))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -3.1e+26) or not (v <= 5e-9): tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)) else: tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / ((1.0 / r) / w)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -3.1e+26) || !(v <= 5e-9)) tmp = Float64(-1.5 + Float64(t_0 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.25))); else tmp = Float64(-1.5 + Float64(t_0 + Float64(-0.375 * Float64(Float64(r * w) / Float64(Float64(1.0 / r) / w))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -3.1e+26) || ~((v <= 5e-9))) tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)); else tmp = -1.5 + (t_0 + (-0.375 * ((r * w) / ((1.0 / r) / w)))); 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, -3.1e+26], N[Not[LessEqual[v, 5e-9]], $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[(-1.5 + N[(t$95$0 + N[(-0.375 * N[(N[(r * w), $MachinePrecision] / N[(N[(1.0 / r), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -3.1 \cdot 10^{+26} \lor \neg \left(v \leq 5 \cdot 10^{-9}\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}:\\
\;\;\;\;-1.5 + \left(t_0 + -0.375 \cdot \frac{r \cdot w}{\frac{\frac{1}{r}}{w}}\right)\\
\end{array}
\end{array}
if v < -3.1e26 or 5.0000000000000001e-9 < v Initial program 77.3%
Simplified85.1%
Taylor expanded in r around 0 81.1%
unpow281.1%
unpow281.1%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.2%
if -3.1e26 < v < 5.0000000000000001e-9Initial program 88.3%
Simplified88.3%
Taylor expanded in v around 0 82.8%
*-commutative82.8%
unpow282.8%
unpow282.8%
swap-sqr99.2%
unpow299.2%
Simplified99.2%
unpow299.2%
remove-double-div99.2%
un-div-inv99.2%
Applied egg-rr99.2%
inv-pow99.2%
*-commutative99.2%
unpow-prod-down99.2%
inv-pow99.2%
inv-pow99.2%
Applied egg-rr99.2%
Taylor expanded in w around 0 99.2%
associate-/r*99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -1e+36) (not (<= v 3.2e-5)))
(+ -1.5 (+ t_0 (* (* (* r w) (* r w)) -0.25)))
(+ -1.5 (+ t_0 (* -0.375 (* r (* w (* r w)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -1e+36) || !(v <= 3.2e-5)) {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
} else {
tmp = -1.5 + (t_0 + (-0.375 * (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) :: tmp
t_0 = 2.0d0 / (r * r)
if ((v <= (-1d+36)) .or. (.not. (v <= 3.2d-5))) then
tmp = (-1.5d0) + (t_0 + (((r * w) * (r * w)) * (-0.25d0)))
else
tmp = (-1.5d0) + (t_0 + ((-0.375d0) * (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 tmp;
if ((v <= -1e+36) || !(v <= 3.2e-5)) {
tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25));
} else {
tmp = -1.5 + (t_0 + (-0.375 * (r * (w * (r * w)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -1e+36) or not (v <= 3.2e-5): tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)) else: tmp = -1.5 + (t_0 + (-0.375 * (r * (w * (r * w))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -1e+36) || !(v <= 3.2e-5)) tmp = Float64(-1.5 + Float64(t_0 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.25))); else tmp = Float64(-1.5 + Float64(t_0 + Float64(-0.375 * Float64(r * Float64(w * Float64(r * w)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -1e+36) || ~((v <= 3.2e-5))) tmp = -1.5 + (t_0 + (((r * w) * (r * w)) * -0.25)); else tmp = -1.5 + (t_0 + (-0.375 * (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]}, If[Or[LessEqual[v, -1e+36], N[Not[LessEqual[v, 3.2e-5]], $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[(-1.5 + N[(t$95$0 + N[(-0.375 * N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1 \cdot 10^{+36} \lor \neg \left(v \leq 3.2 \cdot 10^{-5}\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}:\\
\;\;\;\;-1.5 + \left(t_0 + -0.375 \cdot \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right)\right)\\
\end{array}
\end{array}
if v < -1.00000000000000004e36 or 3.19999999999999986e-5 < v Initial program 77.3%
Simplified85.1%
Taylor expanded in r around 0 81.1%
unpow281.1%
unpow281.1%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.2%
if -1.00000000000000004e36 < v < 3.19999999999999986e-5Initial program 88.3%
Simplified88.3%
Taylor expanded in v around 0 82.8%
*-commutative82.8%
unpow282.8%
unpow282.8%
swap-sqr99.2%
unpow299.2%
Simplified99.2%
unpow299.2%
remove-double-div99.2%
un-div-inv99.2%
Applied egg-rr99.2%
associate-/r/99.2%
/-rgt-identity99.2%
associate-*l*96.1%
Applied egg-rr96.1%
Final simplification97.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* (* r w) (* r w))) (t_1 (/ 2.0 (* r r))))
(if (or (<= v -2e+31) (not (<= v 3.8e-5)))
(+ -1.5 (+ t_1 (* t_0 -0.25)))
(+ -1.5 (+ t_1 (* -0.375 t_0))))))
double code(double v, double w, double r) {
double t_0 = (r * w) * (r * w);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -2e+31) || !(v <= 3.8e-5)) {
tmp = -1.5 + (t_1 + (t_0 * -0.25));
} else {
tmp = -1.5 + (t_1 + (-0.375 * t_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) :: t_1
real(8) :: tmp
t_0 = (r * w) * (r * w)
t_1 = 2.0d0 / (r * r)
if ((v <= (-2d+31)) .or. (.not. (v <= 3.8d-5))) then
tmp = (-1.5d0) + (t_1 + (t_0 * (-0.25d0)))
else
tmp = (-1.5d0) + (t_1 + ((-0.375d0) * t_0))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = (r * w) * (r * w);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -2e+31) || !(v <= 3.8e-5)) {
tmp = -1.5 + (t_1 + (t_0 * -0.25));
} else {
tmp = -1.5 + (t_1 + (-0.375 * t_0));
}
return tmp;
}
def code(v, w, r): t_0 = (r * w) * (r * w) t_1 = 2.0 / (r * r) tmp = 0 if (v <= -2e+31) or not (v <= 3.8e-5): tmp = -1.5 + (t_1 + (t_0 * -0.25)) else: tmp = -1.5 + (t_1 + (-0.375 * t_0)) return tmp
function code(v, w, r) t_0 = Float64(Float64(r * w) * Float64(r * w)) t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -2e+31) || !(v <= 3.8e-5)) tmp = Float64(-1.5 + Float64(t_1 + Float64(t_0 * -0.25))); else tmp = Float64(-1.5 + Float64(t_1 + Float64(-0.375 * t_0))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (r * w) * (r * w); t_1 = 2.0 / (r * r); tmp = 0.0; if ((v <= -2e+31) || ~((v <= 3.8e-5))) tmp = -1.5 + (t_1 + (t_0 * -0.25)); else tmp = -1.5 + (t_1 + (-0.375 * t_0)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -2e+31], N[Not[LessEqual[v, 3.8e-5]], $MachinePrecision]], N[(-1.5 + N[(t$95$1 + N[(t$95$0 * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(t$95$1 + N[(-0.375 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(r \cdot w\right) \cdot \left(r \cdot w\right)\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2 \cdot 10^{+31} \lor \neg \left(v \leq 3.8 \cdot 10^{-5}\right):\\
\;\;\;\;-1.5 + \left(t_1 + t_0 \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(t_1 + -0.375 \cdot t_0\right)\\
\end{array}
\end{array}
if v < -1.9999999999999999e31 or 3.8000000000000002e-5 < v Initial program 77.3%
Simplified85.1%
Taylor expanded in r around 0 81.1%
unpow281.1%
unpow281.1%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.2%
if -1.9999999999999999e31 < v < 3.8000000000000002e-5Initial program 88.3%
Simplified88.3%
Taylor expanded in v around 0 82.8%
*-commutative82.8%
unpow282.8%
unpow282.8%
swap-sqr99.2%
unpow299.2%
Simplified99.2%
unpow299.8%
Applied egg-rr99.2%
Final simplification99.2%
(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 82.7%
Simplified86.7%
Taylor expanded in r around 0 82.2%
unpow282.2%
unpow282.2%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 94.8%
Final simplification94.8%
herbie shell --seed 2023306
(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))