
(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}
NOTE: r should be positive before calling this function
(FPCore (v w r)
:precision binary64
(if (<= r 2.5e-34)
(+ -1.5 (+ (* 2.0 (pow r -2.0)) (* -0.25 (* w (* r (* r w))))))
(+
(/ 2.0 (* r r))
(+ -1.5 (* r (* w (/ (* r w) (/ (- 1.0 v) (fma v 0.25 -0.375)))))))))r = abs(r);
double code(double v, double w, double r) {
double tmp;
if (r <= 2.5e-34) {
tmp = -1.5 + ((2.0 * pow(r, -2.0)) + (-0.25 * (w * (r * (r * w)))));
} else {
tmp = (2.0 / (r * r)) + (-1.5 + (r * (w * ((r * w) / ((1.0 - v) / fma(v, 0.25, -0.375))))));
}
return tmp;
}
r = abs(r) function code(v, w, r) tmp = 0.0 if (r <= 2.5e-34) tmp = Float64(-1.5 + Float64(Float64(2.0 * (r ^ -2.0)) + Float64(-0.25 * Float64(w * Float64(r * Float64(r * w)))))); else tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(r * Float64(w * Float64(Float64(r * w) / Float64(Float64(1.0 - v) / fma(v, 0.25, -0.375))))))); end return tmp end
NOTE: r should be positive before calling this function code[v_, w_, r_] := If[LessEqual[r, 2.5e-34], N[(-1.5 + N[(N[(2.0 * N[Power[r, -2.0], $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(w * N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(r * N[(w * N[(N[(r * w), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] / N[(v * 0.25 + -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
r = |r|\\
\\
\begin{array}{l}
\mathbf{if}\;r \leq 2.5 \cdot 10^{-34}:\\
\;\;\;\;-1.5 + \left(2 \cdot {r}^{-2} + -0.25 \cdot \left(w \cdot \left(r \cdot \left(r \cdot w\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + r \cdot \left(w \cdot \frac{r \cdot w}{\frac{1 - v}{\mathsf{fma}\left(v, 0.25, -0.375\right)}}\right)\right)\\
\end{array}
\end{array}
if r < 2.5000000000000001e-34Initial program 82.9%
Simplified84.4%
Taylor expanded in v around inf 78.5%
unpow278.5%
unpow278.5%
swap-sqr95.6%
unpow295.6%
Simplified95.6%
unpow295.6%
associate-*r*94.4%
Applied egg-rr94.4%
div-inv94.4%
*-commutative94.4%
pow294.4%
pow-flip94.5%
metadata-eval94.5%
Applied egg-rr94.5%
if 2.5000000000000001e-34 < r Initial program 91.5%
Simplified89.7%
associate-/r*89.7%
*-un-lft-identity89.7%
associate-*r*91.0%
times-frac90.8%
Applied egg-rr90.8%
frac-times91.0%
*-un-lft-identity91.0%
associate-/r/91.1%
*-commutative91.1%
associate-*l/99.7%
fma-def99.7%
*-commutative99.7%
associate-*l*99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
Applied egg-rr99.7%
Final simplification95.9%
NOTE: r should be positive before calling this function
(FPCore (v w r)
:precision binary64
(if (<= r 2e-34)
(+ -1.5 (+ (* 2.0 (pow r -2.0)) (* -0.25 (* w (* r (* r w))))))
(+
(/ 2.0 (* r r))
(+ -1.5 (* (* r w) (* (/ r (- 1.0 v)) (* (fma v 0.25 -0.375) w)))))))r = abs(r);
double code(double v, double w, double r) {
double tmp;
if (r <= 2e-34) {
tmp = -1.5 + ((2.0 * pow(r, -2.0)) + (-0.25 * (w * (r * (r * w)))));
} else {
tmp = (2.0 / (r * r)) + (-1.5 + ((r * w) * ((r / (1.0 - v)) * (fma(v, 0.25, -0.375) * w))));
}
return tmp;
}
r = abs(r) function code(v, w, r) tmp = 0.0 if (r <= 2e-34) tmp = Float64(-1.5 + Float64(Float64(2.0 * (r ^ -2.0)) + Float64(-0.25 * Float64(w * Float64(r * Float64(r * w)))))); else tmp = Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(Float64(r * w) * Float64(Float64(r / Float64(1.0 - v)) * Float64(fma(v, 0.25, -0.375) * w))))); end return tmp end
NOTE: r should be positive before calling this function code[v_, w_, r_] := If[LessEqual[r, 2e-34], N[(-1.5 + N[(N[(2.0 * N[Power[r, -2.0], $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(w * N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(N[(r * w), $MachinePrecision] * N[(N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(N[(v * 0.25 + -0.375), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
r = |r|\\
\\
\begin{array}{l}
\mathbf{if}\;r \leq 2 \cdot 10^{-34}:\\
\;\;\;\;-1.5 + \left(2 \cdot {r}^{-2} + -0.25 \cdot \left(w \cdot \left(r \cdot \left(r \cdot w\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{r \cdot r} + \left(-1.5 + \left(r \cdot w\right) \cdot \left(\frac{r}{1 - v} \cdot \left(\mathsf{fma}\left(v, 0.25, -0.375\right) \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if r < 1.99999999999999986e-34Initial program 82.9%
Simplified84.4%
Taylor expanded in v around inf 78.5%
unpow278.5%
unpow278.5%
swap-sqr95.6%
unpow295.6%
Simplified95.6%
unpow295.6%
associate-*r*94.4%
Applied egg-rr94.4%
div-inv94.4%
*-commutative94.4%
pow294.4%
pow-flip94.5%
metadata-eval94.5%
Applied egg-rr94.5%
if 1.99999999999999986e-34 < r Initial program 91.5%
Simplified89.7%
associate-/r*89.7%
associate-/r/89.7%
*-commutative89.7%
associate-*l/97.5%
associate-*r*97.4%
add-sqr-sqrt97.4%
associate-*r*97.4%
fma-def97.4%
associate-*r*79.5%
sqrt-prod79.6%
sqrt-prod97.4%
add-sqr-sqrt97.5%
sqrt-prod57.2%
add-sqr-sqrt66.3%
Applied egg-rr99.7%
Taylor expanded in r around 0 98.3%
associate-/l*99.8%
associate-/r/99.7%
sub-neg99.7%
*-commutative99.7%
metadata-eval99.7%
fma-udef99.7%
Simplified99.7%
Final simplification95.9%
NOTE: r should be positive before calling this function (FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (+ (* (* r w) (* (/ (fma v 0.25 -0.375) (- 1.0 v)) (* r w))) -1.5)))
r = abs(r);
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (((r * w) * ((fma(v, 0.25, -0.375) / (1.0 - v)) * (r * w))) + -1.5);
}
r = abs(r) function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(r * w) * Float64(Float64(fma(v, 0.25, -0.375) / Float64(1.0 - v)) * Float64(r * w))) + -1.5)) end
NOTE: r should be positive before calling this function code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * w), $MachinePrecision] * N[(N[(N[(v * 0.25 + -0.375), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
r = |r|\\
\\
\frac{2}{r \cdot r} + \left(\left(r \cdot w\right) \cdot \left(\frac{\mathsf{fma}\left(v, 0.25, -0.375\right)}{1 - v} \cdot \left(r \cdot w\right)\right) + -1.5\right)
\end{array}
Initial program 85.2%
Simplified81.8%
associate-/r*83.0%
associate-/r/83.0%
*-commutative83.0%
associate-*l/87.8%
associate-*r*87.8%
add-sqr-sqrt87.7%
associate-*r*87.7%
fma-def87.7%
associate-*r*80.3%
sqrt-prod80.3%
sqrt-prod40.4%
add-sqr-sqrt69.2%
sqrt-prod33.2%
add-sqr-sqrt68.8%
Applied egg-rr99.8%
Final simplification99.8%
NOTE: r should be positive before calling this function
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -2100000000.0) (not (<= v 2.6e-9)))
(+ t_0 (+ -1.5 (* (* r w) (* w (* r -0.25)))))
(+ t_0 (+ -1.5 (/ (* w (* r 0.375)) (/ (/ -1.0 r) w)))))))r = abs(r);
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -2100000000.0) || !(v <= 2.6e-9)) {
tmp = t_0 + (-1.5 + ((r * w) * (w * (r * -0.25))));
} else {
tmp = t_0 + (-1.5 + ((w * (r * 0.375)) / ((-1.0 / r) / w)));
}
return tmp;
}
NOTE: r should be positive before calling this function
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 <= (-2100000000.0d0)) .or. (.not. (v <= 2.6d-9))) then
tmp = t_0 + ((-1.5d0) + ((r * w) * (w * (r * (-0.25d0)))))
else
tmp = t_0 + ((-1.5d0) + ((w * (r * 0.375d0)) / (((-1.0d0) / r) / w)))
end if
code = tmp
end function
r = Math.abs(r);
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -2100000000.0) || !(v <= 2.6e-9)) {
tmp = t_0 + (-1.5 + ((r * w) * (w * (r * -0.25))));
} else {
tmp = t_0 + (-1.5 + ((w * (r * 0.375)) / ((-1.0 / r) / w)));
}
return tmp;
}
r = abs(r) def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -2100000000.0) or not (v <= 2.6e-9): tmp = t_0 + (-1.5 + ((r * w) * (w * (r * -0.25)))) else: tmp = t_0 + (-1.5 + ((w * (r * 0.375)) / ((-1.0 / r) / w))) return tmp
r = abs(r) function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -2100000000.0) || !(v <= 2.6e-9)) tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(r * w) * Float64(w * Float64(r * -0.25))))); else tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(w * Float64(r * 0.375)) / Float64(Float64(-1.0 / r) / w)))); end return tmp end
r = abs(r) function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -2100000000.0) || ~((v <= 2.6e-9))) tmp = t_0 + (-1.5 + ((r * w) * (w * (r * -0.25)))); else tmp = t_0 + (-1.5 + ((w * (r * 0.375)) / ((-1.0 / r) / w))); end tmp_2 = tmp; end
NOTE: r should be positive before calling this function
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -2100000000.0], N[Not[LessEqual[v, 2.6e-9]], $MachinePrecision]], N[(t$95$0 + N[(-1.5 + N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 + N[(N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 / r), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
r = |r|\\
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2100000000 \lor \neg \left(v \leq 2.6 \cdot 10^{-9}\right):\\
\;\;\;\;t_0 + \left(-1.5 + \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot -0.25\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 + \frac{w \cdot \left(r \cdot 0.375\right)}{\frac{\frac{-1}{r}}{w}}\right)\\
\end{array}
\end{array}
if v < -2.1e9 or 2.6000000000000001e-9 < v Initial program 80.0%
Simplified73.6%
associate-/r*75.9%
associate-/r/76.0%
*-commutative76.0%
associate-*l/85.0%
associate-*r*85.0%
add-sqr-sqrt84.9%
associate-*r*84.9%
fma-def84.9%
associate-*r*76.6%
sqrt-prod76.7%
sqrt-prod41.1%
add-sqr-sqrt70.2%
sqrt-prod35.3%
add-sqr-sqrt67.2%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.8%
associate-*r*99.8%
Simplified99.8%
if -2.1e9 < v < 2.6000000000000001e-9Initial program 90.9%
Simplified90.9%
associate-/r*90.9%
associate-/r/90.9%
*-commutative90.9%
associate-*l/90.9%
associate-*r*90.9%
add-sqr-sqrt90.8%
associate-*r*90.9%
fma-def90.9%
associate-*r*84.4%
sqrt-prod84.4%
sqrt-prod39.6%
add-sqr-sqrt68.0%
sqrt-prod30.7%
add-sqr-sqrt70.6%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.8%
associate-*r*99.7%
Simplified99.7%
*-commutative99.7%
associate-*l*98.1%
/-rgt-identity98.1%
*-commutative98.1%
associate-*l*95.9%
associate-/r/95.9%
associate-/r*95.9%
frac-2neg95.9%
associate-*l/99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
distribute-neg-frac99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
NOTE: r should be positive before calling this function
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -2.6e+17) (not (<= v 1e+62)))
(+ -1.5 (+ t_0 (* -0.25 (* w (* r (* r w))))))
(+ t_0 (+ -1.5 (* (* r w) (* -0.375 (* r w))))))))r = abs(r);
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -2.6e+17) || !(v <= 1e+62)) {
tmp = -1.5 + (t_0 + (-0.25 * (w * (r * (r * w)))));
} else {
tmp = t_0 + (-1.5 + ((r * w) * (-0.375 * (r * w))));
}
return tmp;
}
NOTE: r should be positive before calling this function
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 <= (-2.6d+17)) .or. (.not. (v <= 1d+62))) then
tmp = (-1.5d0) + (t_0 + ((-0.25d0) * (w * (r * (r * w)))))
else
tmp = t_0 + ((-1.5d0) + ((r * w) * ((-0.375d0) * (r * w))))
end if
code = tmp
end function
r = Math.abs(r);
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -2.6e+17) || !(v <= 1e+62)) {
tmp = -1.5 + (t_0 + (-0.25 * (w * (r * (r * w)))));
} else {
tmp = t_0 + (-1.5 + ((r * w) * (-0.375 * (r * w))));
}
return tmp;
}
r = abs(r) def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -2.6e+17) or not (v <= 1e+62): tmp = -1.5 + (t_0 + (-0.25 * (w * (r * (r * w))))) else: tmp = t_0 + (-1.5 + ((r * w) * (-0.375 * (r * w)))) return tmp
r = abs(r) function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -2.6e+17) || !(v <= 1e+62)) tmp = Float64(-1.5 + Float64(t_0 + Float64(-0.25 * Float64(w * Float64(r * Float64(r * w)))))); else tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(r * w) * Float64(-0.375 * Float64(r * w))))); end return tmp end
r = abs(r) function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -2.6e+17) || ~((v <= 1e+62))) tmp = -1.5 + (t_0 + (-0.25 * (w * (r * (r * w))))); else tmp = t_0 + (-1.5 + ((r * w) * (-0.375 * (r * w)))); end tmp_2 = tmp; end
NOTE: r should be positive before calling this function
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -2.6e+17], N[Not[LessEqual[v, 1e+62]], $MachinePrecision]], N[(-1.5 + N[(t$95$0 + N[(-0.25 * N[(w * N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 + N[(N[(r * w), $MachinePrecision] * N[(-0.375 * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
r = |r|\\
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2.6 \cdot 10^{+17} \lor \neg \left(v \leq 10^{+62}\right):\\
\;\;\;\;-1.5 + \left(t_0 + -0.25 \cdot \left(w \cdot \left(r \cdot \left(r \cdot w\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 + \left(r \cdot w\right) \cdot \left(-0.375 \cdot \left(r \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if v < -2.6e17 or 1.00000000000000004e62 < v Initial program 80.1%
Simplified85.6%
Taylor expanded in v around inf 77.1%
unpow277.1%
unpow277.1%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
associate-*r*97.4%
Applied egg-rr97.4%
if -2.6e17 < v < 1.00000000000000004e62Initial program 89.4%
Simplified89.4%
associate-/r*89.3%
associate-/r/89.4%
*-commutative89.4%
associate-*l/89.6%
associate-*r*89.6%
add-sqr-sqrt89.5%
associate-*r*89.5%
fma-def89.5%
associate-*r*83.0%
sqrt-prod83.0%
sqrt-prod41.6%
add-sqr-sqrt69.8%
sqrt-prod31.9%
add-sqr-sqrt70.6%
Applied egg-rr99.8%
Taylor expanded in v around 0 98.6%
Final simplification98.1%
NOTE: r should be positive before calling this function
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -2100000000.0) (not (<= v 2e-9)))
(+ t_0 (+ -1.5 (* (* r w) (* w (* r -0.25)))))
(+ t_0 (+ -1.5 (* (* r w) (* -0.375 (* r w))))))))r = abs(r);
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -2100000000.0) || !(v <= 2e-9)) {
tmp = t_0 + (-1.5 + ((r * w) * (w * (r * -0.25))));
} else {
tmp = t_0 + (-1.5 + ((r * w) * (-0.375 * (r * w))));
}
return tmp;
}
NOTE: r should be positive before calling this function
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 <= (-2100000000.0d0)) .or. (.not. (v <= 2d-9))) then
tmp = t_0 + ((-1.5d0) + ((r * w) * (w * (r * (-0.25d0)))))
else
tmp = t_0 + ((-1.5d0) + ((r * w) * ((-0.375d0) * (r * w))))
end if
code = tmp
end function
r = Math.abs(r);
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -2100000000.0) || !(v <= 2e-9)) {
tmp = t_0 + (-1.5 + ((r * w) * (w * (r * -0.25))));
} else {
tmp = t_0 + (-1.5 + ((r * w) * (-0.375 * (r * w))));
}
return tmp;
}
r = abs(r) def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -2100000000.0) or not (v <= 2e-9): tmp = t_0 + (-1.5 + ((r * w) * (w * (r * -0.25)))) else: tmp = t_0 + (-1.5 + ((r * w) * (-0.375 * (r * w)))) return tmp
r = abs(r) function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -2100000000.0) || !(v <= 2e-9)) tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(r * w) * Float64(w * Float64(r * -0.25))))); else tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(r * w) * Float64(-0.375 * Float64(r * w))))); end return tmp end
r = abs(r) function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -2100000000.0) || ~((v <= 2e-9))) tmp = t_0 + (-1.5 + ((r * w) * (w * (r * -0.25)))); else tmp = t_0 + (-1.5 + ((r * w) * (-0.375 * (r * w)))); end tmp_2 = tmp; end
NOTE: r should be positive before calling this function
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -2100000000.0], N[Not[LessEqual[v, 2e-9]], $MachinePrecision]], N[(t$95$0 + N[(-1.5 + N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 + N[(N[(r * w), $MachinePrecision] * N[(-0.375 * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
r = |r|\\
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2100000000 \lor \neg \left(v \leq 2 \cdot 10^{-9}\right):\\
\;\;\;\;t_0 + \left(-1.5 + \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot -0.25\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-1.5 + \left(r \cdot w\right) \cdot \left(-0.375 \cdot \left(r \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if v < -2.1e9 or 2.00000000000000012e-9 < v Initial program 80.0%
Simplified73.6%
associate-/r*75.9%
associate-/r/76.0%
*-commutative76.0%
associate-*l/85.0%
associate-*r*85.0%
add-sqr-sqrt84.9%
associate-*r*84.9%
fma-def84.9%
associate-*r*76.6%
sqrt-prod76.7%
sqrt-prod41.1%
add-sqr-sqrt70.2%
sqrt-prod35.3%
add-sqr-sqrt67.2%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.8%
associate-*r*99.8%
Simplified99.8%
if -2.1e9 < v < 2.00000000000000012e-9Initial program 90.9%
Simplified90.9%
associate-/r*90.9%
associate-/r/90.9%
*-commutative90.9%
associate-*l/90.9%
associate-*r*90.9%
add-sqr-sqrt90.8%
associate-*r*90.9%
fma-def90.9%
associate-*r*84.4%
sqrt-prod84.4%
sqrt-prod39.6%
add-sqr-sqrt68.0%
sqrt-prod30.7%
add-sqr-sqrt70.6%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.8%
Final simplification99.8%
NOTE: r should be positive before calling this function (FPCore (v w r) :precision binary64 (+ -1.5 (+ (/ 2.0 (* r r)) (* -0.25 (* w (* r (* r w)))))))
r = abs(r);
double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (-0.25 * (w * (r * (r * w)))));
}
NOTE: r should be positive before calling this function
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)) + ((-0.25d0) * (w * (r * (r * w)))))
end function
r = Math.abs(r);
public static double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (-0.25 * (w * (r * (r * w)))));
}
r = abs(r) def code(v, w, r): return -1.5 + ((2.0 / (r * r)) + (-0.25 * (w * (r * (r * w)))))
r = abs(r) function code(v, w, r) return Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(-0.25 * Float64(w * Float64(r * Float64(r * w)))))) end
r = abs(r) function tmp = code(v, w, r) tmp = -1.5 + ((2.0 / (r * r)) + (-0.25 * (w * (r * (r * w))))); end
NOTE: r should be positive before calling this function code[v_, w_, r_] := N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(w * N[(r * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
r = |r|\\
\\
-1.5 + \left(\frac{2}{r \cdot r} + -0.25 \cdot \left(w \cdot \left(r \cdot \left(r \cdot w\right)\right)\right)\right)
\end{array}
Initial program 85.2%
Simplified87.8%
Taylor expanded in v around inf 76.6%
unpow276.6%
unpow276.6%
swap-sqr93.3%
unpow293.3%
Simplified93.3%
unpow293.3%
associate-*r*91.2%
Applied egg-rr91.2%
Final simplification91.2%
herbie shell --seed 2023305
(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))