
(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 9 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
(let* ((t_0 (- -1.5 (* (* (* r w) (* r w)) 0.25))))
(if (<= v -2.7e+22)
(+ (/ 1.0 (* r (/ r 2.0))) t_0)
(if (<= v 9e-23)
(-
(+ 3.0 (/ 2.0 (* r r)))
(+ (* (pow (* r w) 2.0) (+ 0.375 (* v 0.125))) 4.5))
(+ (/ (/ 2.0 r) r) t_0)))))
double code(double v, double w, double r) {
double t_0 = -1.5 - (((r * w) * (r * w)) * 0.25);
double tmp;
if (v <= -2.7e+22) {
tmp = (1.0 / (r * (r / 2.0))) + t_0;
} else if (v <= 9e-23) {
tmp = (3.0 + (2.0 / (r * r))) - ((pow((r * w), 2.0) * (0.375 + (v * 0.125))) + 4.5);
} else {
tmp = ((2.0 / r) / r) + 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) :: tmp
t_0 = (-1.5d0) - (((r * w) * (r * w)) * 0.25d0)
if (v <= (-2.7d+22)) then
tmp = (1.0d0 / (r * (r / 2.0d0))) + t_0
else if (v <= 9d-23) then
tmp = (3.0d0 + (2.0d0 / (r * r))) - ((((r * w) ** 2.0d0) * (0.375d0 + (v * 0.125d0))) + 4.5d0)
else
tmp = ((2.0d0 / r) / r) + t_0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = -1.5 - (((r * w) * (r * w)) * 0.25);
double tmp;
if (v <= -2.7e+22) {
tmp = (1.0 / (r * (r / 2.0))) + t_0;
} else if (v <= 9e-23) {
tmp = (3.0 + (2.0 / (r * r))) - ((Math.pow((r * w), 2.0) * (0.375 + (v * 0.125))) + 4.5);
} else {
tmp = ((2.0 / r) / r) + t_0;
}
return tmp;
}
def code(v, w, r): t_0 = -1.5 - (((r * w) * (r * w)) * 0.25) tmp = 0 if v <= -2.7e+22: tmp = (1.0 / (r * (r / 2.0))) + t_0 elif v <= 9e-23: tmp = (3.0 + (2.0 / (r * r))) - ((math.pow((r * w), 2.0) * (0.375 + (v * 0.125))) + 4.5) else: tmp = ((2.0 / r) / r) + t_0 return tmp
function code(v, w, r) t_0 = Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25)) tmp = 0.0 if (v <= -2.7e+22) tmp = Float64(Float64(1.0 / Float64(r * Float64(r / 2.0))) + t_0); elseif (v <= 9e-23) tmp = Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64((Float64(r * w) ^ 2.0) * Float64(0.375 + Float64(v * 0.125))) + 4.5)); else tmp = Float64(Float64(Float64(2.0 / r) / r) + t_0); end return tmp end
function tmp_2 = code(v, w, r) t_0 = -1.5 - (((r * w) * (r * w)) * 0.25); tmp = 0.0; if (v <= -2.7e+22) tmp = (1.0 / (r * (r / 2.0))) + t_0; elseif (v <= 9e-23) tmp = (3.0 + (2.0 / (r * r))) - ((((r * w) ^ 2.0) * (0.375 + (v * 0.125))) + 4.5); else tmp = ((2.0 / r) / r) + t_0; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -2.7e+22], N[(N[(1.0 / N[(r * N[(r / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[v, 9e-23], N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.375 + N[(v * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\\
\mathbf{if}\;v \leq -2.7 \cdot 10^{+22}:\\
\;\;\;\;\frac{1}{r \cdot \frac{r}{2}} + t\_0\\
\mathbf{elif}\;v \leq 9 \cdot 10^{-23}:\\
\;\;\;\;\left(3 + \frac{2}{r \cdot r}\right) - \left({\left(r \cdot w\right)}^{2} \cdot \left(0.375 + v \cdot 0.125\right) + 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + t\_0\\
\end{array}
\end{array}
if v < -2.7000000000000002e22Initial program 86.5%
Simplified99.7%
Taylor expanded in v around inf 92.1%
*-commutative92.1%
*-commutative92.1%
unpow292.1%
unpow292.1%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
associate-/r/99.8%
Simplified99.8%
if -2.7000000000000002e22 < v < 8.9999999999999995e-23Initial program 87.1%
Simplified87.0%
metadata-eval87.0%
cancel-sign-sub-inv87.0%
associate-*r*96.8%
*-commutative96.8%
*-commutative96.8%
*-commutative96.8%
associate-*l*87.0%
associate-/l*87.1%
clear-num87.0%
inv-pow87.0%
Applied egg-rr99.8%
unpow-199.8%
associate-*r/99.8%
*-commutative99.8%
times-frac99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in v around 0 55.4%
+-commutative55.4%
associate-*r*55.4%
distribute-rgt-out--70.6%
metadata-eval70.6%
*-rgt-identity70.6%
distribute-rgt-out83.5%
unpow283.5%
unpow283.5%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
if 8.9999999999999995e-23 < v Initial program 79.5%
Simplified99.8%
Taylor expanded in v around inf 86.6%
*-commutative86.6%
*-commutative86.6%
unpow286.6%
unpow286.6%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (- -1.5 (/ (fma v -0.25 0.375) (* (* (/ 1.0 w) (/ 1.0 r)) (/ (- 1.0 v) (* r w)))))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (fma(v, -0.25, 0.375) / (((1.0 / w) * (1.0 / r)) * ((1.0 - v) / (r * w)))));
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(fma(v, -0.25, 0.375) / Float64(Float64(Float64(1.0 / w) * Float64(1.0 / r)) * Float64(Float64(1.0 - v) / Float64(r * w)))))) end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(v * -0.25 + 0.375), $MachinePrecision] / N[(N[(N[(1.0 / w), $MachinePrecision] * N[(1.0 / r), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 - \frac{\mathsf{fma}\left(v, -0.25, 0.375\right)}{\left(\frac{1}{w} \cdot \frac{1}{r}\right) \cdot \frac{1 - v}{r \cdot w}}\right)
\end{array}
Initial program 85.0%
Simplified98.3%
*-un-lft-identity98.3%
associate-*r*99.7%
times-frac99.7%
*-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
inv-pow99.7%
unpow-prod-down99.8%
inv-pow99.8%
inv-pow99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (- -1.5 (/ (fma v -0.25 0.375) (/ (* (- 1.0 v) (/ (/ 1.0 w) r)) (* r w))))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (fma(v, -0.25, 0.375) / (((1.0 - v) * ((1.0 / w) / r)) / (r * w))));
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(fma(v, -0.25, 0.375) / Float64(Float64(Float64(1.0 - v) * Float64(Float64(1.0 / w) / r)) / Float64(r * w))))) end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(v * -0.25 + 0.375), $MachinePrecision] / N[(N[(N[(1.0 - v), $MachinePrecision] * N[(N[(1.0 / w), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 - \frac{\mathsf{fma}\left(v, -0.25, 0.375\right)}{\frac{\left(1 - v\right) \cdot \frac{\frac{1}{w}}{r}}{r \cdot w}}\right)
\end{array}
Initial program 85.0%
Simplified98.3%
*-un-lft-identity98.3%
associate-*r*99.7%
times-frac99.7%
*-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
associate-*r/99.7%
associate-/r*99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (- -1.5 (/ (fma v -0.25 0.375) (/ (- 1.0 v) (* r (* w (* r w))))))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (fma(v, -0.25, 0.375) / ((1.0 - v) / (r * (w * (r * w))))));
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(fma(v, -0.25, 0.375) / Float64(Float64(1.0 - v) / Float64(r * Float64(w * Float64(r * w))))))) end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(v * -0.25 + 0.375), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] / N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 - \frac{\mathsf{fma}\left(v, -0.25, 0.375\right)}{\frac{1 - v}{r \cdot \left(w \cdot \left(r \cdot w\right)\right)}}\right)
\end{array}
Initial program 85.0%
Simplified98.3%
Final simplification98.3%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (- -1.5 (/ (fma v -0.25 0.375) (/ (/ (- 1.0 v) (* r w)) (* r w))))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (fma(v, -0.25, 0.375) / (((1.0 - v) / (r * w)) / (r * w))));
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(fma(v, -0.25, 0.375) / Float64(Float64(Float64(1.0 - v) / Float64(r * w)) / Float64(r * w))))) end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(v * -0.25 + 0.375), $MachinePrecision] / N[(N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 - \frac{\mathsf{fma}\left(v, -0.25, 0.375\right)}{\frac{\frac{1 - v}{r \cdot w}}{r \cdot w}}\right)
\end{array}
Initial program 85.0%
Simplified98.3%
*-un-lft-identity98.3%
associate-*r*99.7%
times-frac99.7%
*-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-un-lft-identity99.7%
*-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* (* r w) (* r w)))
(t_1 (/ 1.0 (* r (/ r 2.0))))
(t_2 (- -1.5 (* t_0 0.25))))
(if (<= v -3.4e+24)
(+ t_1 t_2)
(if (<= v 1e-24)
(+ t_1 (- -1.5 (* 0.375 t_0)))
(+ (/ (/ 2.0 r) r) t_2)))))
double code(double v, double w, double r) {
double t_0 = (r * w) * (r * w);
double t_1 = 1.0 / (r * (r / 2.0));
double t_2 = -1.5 - (t_0 * 0.25);
double tmp;
if (v <= -3.4e+24) {
tmp = t_1 + t_2;
} else if (v <= 1e-24) {
tmp = t_1 + (-1.5 - (0.375 * t_0));
} else {
tmp = ((2.0 / r) / r) + t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = (r * w) * (r * w)
t_1 = 1.0d0 / (r * (r / 2.0d0))
t_2 = (-1.5d0) - (t_0 * 0.25d0)
if (v <= (-3.4d+24)) then
tmp = t_1 + t_2
else if (v <= 1d-24) then
tmp = t_1 + ((-1.5d0) - (0.375d0 * t_0))
else
tmp = ((2.0d0 / r) / r) + t_2
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 = 1.0 / (r * (r / 2.0));
double t_2 = -1.5 - (t_0 * 0.25);
double tmp;
if (v <= -3.4e+24) {
tmp = t_1 + t_2;
} else if (v <= 1e-24) {
tmp = t_1 + (-1.5 - (0.375 * t_0));
} else {
tmp = ((2.0 / r) / r) + t_2;
}
return tmp;
}
def code(v, w, r): t_0 = (r * w) * (r * w) t_1 = 1.0 / (r * (r / 2.0)) t_2 = -1.5 - (t_0 * 0.25) tmp = 0 if v <= -3.4e+24: tmp = t_1 + t_2 elif v <= 1e-24: tmp = t_1 + (-1.5 - (0.375 * t_0)) else: tmp = ((2.0 / r) / r) + t_2 return tmp
function code(v, w, r) t_0 = Float64(Float64(r * w) * Float64(r * w)) t_1 = Float64(1.0 / Float64(r * Float64(r / 2.0))) t_2 = Float64(-1.5 - Float64(t_0 * 0.25)) tmp = 0.0 if (v <= -3.4e+24) tmp = Float64(t_1 + t_2); elseif (v <= 1e-24) tmp = Float64(t_1 + Float64(-1.5 - Float64(0.375 * t_0))); else tmp = Float64(Float64(Float64(2.0 / r) / r) + t_2); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (r * w) * (r * w); t_1 = 1.0 / (r * (r / 2.0)); t_2 = -1.5 - (t_0 * 0.25); tmp = 0.0; if (v <= -3.4e+24) tmp = t_1 + t_2; elseif (v <= 1e-24) tmp = t_1 + (-1.5 - (0.375 * t_0)); else tmp = ((2.0 / r) / r) + t_2; 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[(1.0 / N[(r * N[(r / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-1.5 - N[(t$95$0 * 0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -3.4e+24], N[(t$95$1 + t$95$2), $MachinePrecision], If[LessEqual[v, 1e-24], N[(t$95$1 + N[(-1.5 - N[(0.375 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(r \cdot w\right) \cdot \left(r \cdot w\right)\\
t_1 := \frac{1}{r \cdot \frac{r}{2}}\\
t_2 := -1.5 - t\_0 \cdot 0.25\\
\mathbf{if}\;v \leq -3.4 \cdot 10^{+24}:\\
\;\;\;\;t\_1 + t\_2\\
\mathbf{elif}\;v \leq 10^{-24}:\\
\;\;\;\;t\_1 + \left(-1.5 - 0.375 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + t\_2\\
\end{array}
\end{array}
if v < -3.4000000000000001e24Initial program 86.1%
Simplified99.7%
Taylor expanded in v around inf 91.9%
*-commutative91.9%
*-commutative91.9%
unpow291.9%
unpow291.9%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
associate-/r/99.8%
Simplified99.8%
if -3.4000000000000001e24 < v < 9.99999999999999924e-25Initial program 87.3%
Simplified96.8%
Taylor expanded in v around 0 83.4%
*-commutative83.4%
*-commutative83.4%
unpow283.4%
unpow283.4%
swap-sqr99.1%
unpow299.1%
*-commutative99.1%
Simplified99.1%
unpow283.7%
Applied egg-rr99.1%
clear-num83.7%
inv-pow83.7%
Applied egg-rr99.1%
unpow-183.7%
associate-/r/83.7%
Simplified99.2%
if 9.99999999999999924e-25 < v Initial program 79.5%
Simplified99.8%
Taylor expanded in v around inf 86.6%
*-commutative86.6%
*-commutative86.6%
unpow286.6%
unpow286.6%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* (* r w) (* r w))) (t_1 (/ (/ 2.0 r) r)))
(if (or (<= v -3.4e+24) (not (<= v 9e-23)))
(+ t_1 (- -1.5 (* t_0 0.25)))
(+ t_1 (- -1.5 (* 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 <= -3.4e+24) || !(v <= 9e-23)) {
tmp = t_1 + (-1.5 - (t_0 * 0.25));
} else {
tmp = t_1 + (-1.5 - (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 <= (-3.4d+24)) .or. (.not. (v <= 9d-23))) then
tmp = t_1 + ((-1.5d0) - (t_0 * 0.25d0))
else
tmp = t_1 + ((-1.5d0) - (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 <= -3.4e+24) || !(v <= 9e-23)) {
tmp = t_1 + (-1.5 - (t_0 * 0.25));
} else {
tmp = t_1 + (-1.5 - (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 <= -3.4e+24) or not (v <= 9e-23): tmp = t_1 + (-1.5 - (t_0 * 0.25)) else: tmp = t_1 + (-1.5 - (0.375 * t_0)) return tmp
function code(v, w, r) t_0 = Float64(Float64(r * w) * Float64(r * w)) t_1 = Float64(Float64(2.0 / r) / r) tmp = 0.0 if ((v <= -3.4e+24) || !(v <= 9e-23)) tmp = Float64(t_1 + Float64(-1.5 - Float64(t_0 * 0.25))); else tmp = Float64(t_1 + Float64(-1.5 - 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 <= -3.4e+24) || ~((v <= 9e-23))) tmp = t_1 + (-1.5 - (t_0 * 0.25)); else tmp = t_1 + (-1.5 - (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[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]}, If[Or[LessEqual[v, -3.4e+24], N[Not[LessEqual[v, 9e-23]], $MachinePrecision]], N[(t$95$1 + N[(-1.5 - N[(t$95$0 * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(-1.5 - 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{\frac{2}{r}}{r}\\
\mathbf{if}\;v \leq -3.4 \cdot 10^{+24} \lor \neg \left(v \leq 9 \cdot 10^{-23}\right):\\
\;\;\;\;t\_1 + \left(-1.5 - t\_0 \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \left(-1.5 - 0.375 \cdot t\_0\right)\\
\end{array}
\end{array}
if v < -3.4000000000000001e24 or 8.9999999999999995e-23 < v Initial program 82.7%
Simplified99.8%
Taylor expanded in v around inf 89.1%
*-commutative89.1%
*-commutative89.1%
unpow289.1%
unpow289.1%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
if -3.4000000000000001e24 < v < 8.9999999999999995e-23Initial program 87.3%
Simplified96.8%
Taylor expanded in v around 0 83.4%
*-commutative83.4%
*-commutative83.4%
unpow283.4%
unpow283.4%
swap-sqr99.1%
unpow299.1%
*-commutative99.1%
Simplified99.1%
unpow283.7%
Applied egg-rr99.1%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* (* r w) (* r w)))
(t_1 (/ (/ 2.0 r) r))
(t_2 (- -1.5 (* t_0 0.25))))
(if (<= v -3e+21)
(+ (/ 1.0 (* r (/ r 2.0))) t_2)
(if (<= v 9e-23) (+ t_1 (- -1.5 (* 0.375 t_0))) (+ t_1 t_2)))))
double code(double v, double w, double r) {
double t_0 = (r * w) * (r * w);
double t_1 = (2.0 / r) / r;
double t_2 = -1.5 - (t_0 * 0.25);
double tmp;
if (v <= -3e+21) {
tmp = (1.0 / (r * (r / 2.0))) + t_2;
} else if (v <= 9e-23) {
tmp = t_1 + (-1.5 - (0.375 * t_0));
} else {
tmp = t_1 + t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = (r * w) * (r * w)
t_1 = (2.0d0 / r) / r
t_2 = (-1.5d0) - (t_0 * 0.25d0)
if (v <= (-3d+21)) then
tmp = (1.0d0 / (r * (r / 2.0d0))) + t_2
else if (v <= 9d-23) then
tmp = t_1 + ((-1.5d0) - (0.375d0 * t_0))
else
tmp = t_1 + t_2
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 t_2 = -1.5 - (t_0 * 0.25);
double tmp;
if (v <= -3e+21) {
tmp = (1.0 / (r * (r / 2.0))) + t_2;
} else if (v <= 9e-23) {
tmp = t_1 + (-1.5 - (0.375 * t_0));
} else {
tmp = t_1 + t_2;
}
return tmp;
}
def code(v, w, r): t_0 = (r * w) * (r * w) t_1 = (2.0 / r) / r t_2 = -1.5 - (t_0 * 0.25) tmp = 0 if v <= -3e+21: tmp = (1.0 / (r * (r / 2.0))) + t_2 elif v <= 9e-23: tmp = t_1 + (-1.5 - (0.375 * t_0)) else: tmp = t_1 + t_2 return tmp
function code(v, w, r) t_0 = Float64(Float64(r * w) * Float64(r * w)) t_1 = Float64(Float64(2.0 / r) / r) t_2 = Float64(-1.5 - Float64(t_0 * 0.25)) tmp = 0.0 if (v <= -3e+21) tmp = Float64(Float64(1.0 / Float64(r * Float64(r / 2.0))) + t_2); elseif (v <= 9e-23) tmp = Float64(t_1 + Float64(-1.5 - Float64(0.375 * t_0))); else tmp = Float64(t_1 + t_2); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (r * w) * (r * w); t_1 = (2.0 / r) / r; t_2 = -1.5 - (t_0 * 0.25); tmp = 0.0; if (v <= -3e+21) tmp = (1.0 / (r * (r / 2.0))) + t_2; elseif (v <= 9e-23) tmp = t_1 + (-1.5 - (0.375 * t_0)); else tmp = t_1 + t_2; 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[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]}, Block[{t$95$2 = N[(-1.5 - N[(t$95$0 * 0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -3e+21], N[(N[(1.0 / N[(r * N[(r / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision], If[LessEqual[v, 9e-23], N[(t$95$1 + N[(-1.5 - N[(0.375 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(r \cdot w\right) \cdot \left(r \cdot w\right)\\
t_1 := \frac{\frac{2}{r}}{r}\\
t_2 := -1.5 - t\_0 \cdot 0.25\\
\mathbf{if}\;v \leq -3 \cdot 10^{+21}:\\
\;\;\;\;\frac{1}{r \cdot \frac{r}{2}} + t\_2\\
\mathbf{elif}\;v \leq 9 \cdot 10^{-23}:\\
\;\;\;\;t\_1 + \left(-1.5 - 0.375 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 + t\_2\\
\end{array}
\end{array}
if v < -3e21Initial program 86.7%
Simplified99.7%
Taylor expanded in v around inf 92.2%
*-commutative92.2%
*-commutative92.2%
unpow292.2%
unpow292.2%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
associate-/r/99.8%
Simplified99.8%
if -3e21 < v < 8.9999999999999995e-23Initial program 87.0%
Simplified96.7%
Taylor expanded in v around 0 83.0%
*-commutative83.0%
*-commutative83.0%
unpow283.0%
unpow283.0%
swap-sqr99.1%
unpow299.1%
*-commutative99.1%
Simplified99.1%
unpow283.3%
Applied egg-rr99.1%
if 8.9999999999999995e-23 < v Initial program 79.5%
Simplified99.8%
Taylor expanded in v around inf 86.6%
*-commutative86.6%
*-commutative86.6%
unpow286.6%
unpow286.6%
swap-sqr99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.5%
(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(Float64(2.0 / 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[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{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 85.0%
Simplified98.3%
Taylor expanded in v around inf 81.2%
*-commutative81.2%
*-commutative81.2%
unpow281.2%
unpow281.2%
swap-sqr91.7%
unpow291.7%
*-commutative91.7%
Simplified91.7%
unpow291.7%
Applied egg-rr91.7%
Final simplification91.7%
herbie shell --seed 2024026
(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))