
(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 (+ (+ 3.0 (* 2.0 (pow r -2.0))) (- (* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (/ (* r w) (+ v -1.0)))) 4.5)))
double code(double v, double w, double r) {
return (3.0 + (2.0 * pow(r, -2.0))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * ((r * w) / (v + -1.0)))) - 4.5);
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = (3.0d0 + (2.0d0 * (r ** (-2.0d0)))) + (((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * ((r * w) * ((r * w) / (v + (-1.0d0))))) - 4.5d0)
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 * Math.pow(r, -2.0))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * ((r * w) / (v + -1.0)))) - 4.5);
}
def code(v, w, r): return (3.0 + (2.0 * math.pow(r, -2.0))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * ((r * w) / (v + -1.0)))) - 4.5)
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 * (r ^ -2.0))) + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(v + -1.0)))) - 4.5)) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 * (r ^ -2.0))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * ((r * w) / (v + -1.0)))) - 4.5); end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 * N[Power[r, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + 2 \cdot {r}^{-2}\right) + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v + -1}\right) - 4.5\right)
\end{array}
Initial program 85.3%
associate--l-85.3%
associate-*l*78.7%
sqr-neg78.7%
associate-*l*85.3%
associate-/l*87.4%
fma-define87.5%
Simplified87.4%
*-un-lft-identity87.4%
add-sqr-sqrt87.4%
times-frac87.4%
associate-*r*80.9%
sqrt-prod80.9%
sqrt-prod41.9%
add-sqr-sqrt72.5%
sqrt-prod38.4%
add-sqr-sqrt75.6%
associate-*r*65.8%
sqrt-prod65.8%
sqrt-prod37.5%
add-sqr-sqrt75.6%
sqrt-prod50.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
div-inv99.8%
pow299.8%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -0.0016) (not (<= v 0.000165)))
(+
t_0
(+ -1.5 (* (+ 0.375 (* v -0.25)) (/ (* r (* r (* w w))) (+ v -1.0)))))
(+ t_0 (- -1.5 (* (* (* r w) (/ (* r w) (- 1.0 v))) 0.375))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -0.0016) || !(v <= 0.000165)) {
tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * ((r * (r * (w * w))) / (v + -1.0))));
} else {
tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 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 <= (-0.0016d0)) .or. (.not. (v <= 0.000165d0))) then
tmp = t_0 + ((-1.5d0) + ((0.375d0 + (v * (-0.25d0))) * ((r * (r * (w * w))) / (v + (-1.0d0)))))
else
tmp = t_0 + ((-1.5d0) - (((r * w) * ((r * w) / (1.0d0 - v))) * 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 <= -0.0016) || !(v <= 0.000165)) {
tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * ((r * (r * (w * w))) / (v + -1.0))));
} else {
tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 0.375));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -0.0016) or not (v <= 0.000165): tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * ((r * (r * (w * w))) / (v + -1.0)))) else: tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 0.375)) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -0.0016) || !(v <= 0.000165)) tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(0.375 + Float64(v * -0.25)) * Float64(Float64(r * Float64(r * Float64(w * w))) / Float64(v + -1.0))))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(1.0 - v))) * 0.375))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -0.0016) || ~((v <= 0.000165))) tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * ((r * (r * (w * w))) / (v + -1.0)))); else tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 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, -0.0016], N[Not[LessEqual[v, 0.000165]], $MachinePrecision]], N[(t$95$0 + N[(-1.5 + N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] * N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -0.0016 \lor \neg \left(v \leq 0.000165\right):\\
\;\;\;\;t\_0 + \left(-1.5 + \left(0.375 + v \cdot -0.25\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right) \cdot 0.375\right)\\
\end{array}
\end{array}
if v < -0.00160000000000000008 or 1.65e-4 < v Initial program 88.6%
Simplified93.0%
Taylor expanded in v around 0 93.0%
*-commutative93.0%
Simplified93.0%
if -0.00160000000000000008 < v < 1.65e-4Initial program 82.0%
Simplified82.0%
Taylor expanded in v around 0 82.0%
add-sqr-sqrt82.0%
*-un-lft-identity82.0%
times-frac82.0%
associate-*r*73.5%
sqrt-prod73.5%
sqrt-prod35.2%
add-sqr-sqrt70.3%
sqrt-prod41.3%
add-sqr-sqrt78.7%
associate-*r*64.7%
sqrt-prod64.7%
sqrt-prod35.7%
add-sqr-sqrt74.7%
sqrt-prod51.8%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Final simplification96.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (* (* r w) (/ (* r w) (- 1.0 v)))))
(if (<= r 3.5e-91)
(+ t_0 (- -1.5 (* t_1 0.375)))
(if (<= r 1e+196)
(+
t_0
(+ -1.5 (* (+ 0.375 (* v -0.25)) (/ (* r (* r (* w w))) (+ v -1.0)))))
(- 3.0 (+ (* (* 0.125 (+ 3.0 (* -2.0 v))) t_1) 4.5))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = (r * w) * ((r * w) / (1.0 - v));
double tmp;
if (r <= 3.5e-91) {
tmp = t_0 + (-1.5 - (t_1 * 0.375));
} else if (r <= 1e+196) {
tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * ((r * (r * (w * w))) / (v + -1.0))));
} else {
tmp = 3.0 - (((0.125 * (3.0 + (-2.0 * v))) * t_1) + 4.5);
}
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) / (1.0d0 - v))
if (r <= 3.5d-91) then
tmp = t_0 + ((-1.5d0) - (t_1 * 0.375d0))
else if (r <= 1d+196) then
tmp = t_0 + ((-1.5d0) + ((0.375d0 + (v * (-0.25d0))) * ((r * (r * (w * w))) / (v + (-1.0d0)))))
else
tmp = 3.0d0 - (((0.125d0 * (3.0d0 + ((-2.0d0) * v))) * t_1) + 4.5d0)
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) / (1.0 - v));
double tmp;
if (r <= 3.5e-91) {
tmp = t_0 + (-1.5 - (t_1 * 0.375));
} else if (r <= 1e+196) {
tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * ((r * (r * (w * w))) / (v + -1.0))));
} else {
tmp = 3.0 - (((0.125 * (3.0 + (-2.0 * v))) * t_1) + 4.5);
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) t_1 = (r * w) * ((r * w) / (1.0 - v)) tmp = 0 if r <= 3.5e-91: tmp = t_0 + (-1.5 - (t_1 * 0.375)) elif r <= 1e+196: tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * ((r * (r * (w * w))) / (v + -1.0)))) else: tmp = 3.0 - (((0.125 * (3.0 + (-2.0 * v))) * t_1) + 4.5) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(1.0 - v))) tmp = 0.0 if (r <= 3.5e-91) tmp = Float64(t_0 + Float64(-1.5 - Float64(t_1 * 0.375))); elseif (r <= 1e+196) tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(0.375 + Float64(v * -0.25)) * Float64(Float64(r * Float64(r * Float64(w * w))) / Float64(v + -1.0))))); else tmp = Float64(3.0 - Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * t_1) + 4.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); t_1 = (r * w) * ((r * w) / (1.0 - v)); tmp = 0.0; if (r <= 3.5e-91) tmp = t_0 + (-1.5 - (t_1 * 0.375)); elseif (r <= 1e+196) tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * ((r * (r * (w * w))) / (v + -1.0)))); else tmp = 3.0 - (((0.125 * (3.0 + (-2.0 * v))) * t_1) + 4.5); 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[(N[(r * w), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 3.5e-91], N[(t$95$0 + N[(-1.5 - N[(t$95$1 * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[r, 1e+196], N[(t$95$0 + N[(-1.5 + N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] * N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(N[(N[(0.125 * N[(3.0 + N[(-2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := \left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\\
\mathbf{if}\;r \leq 3.5 \cdot 10^{-91}:\\
\;\;\;\;t\_0 + \left(-1.5 - t\_1 \cdot 0.375\right)\\
\mathbf{elif}\;r \leq 10^{+196}:\\
\;\;\;\;t\_0 + \left(-1.5 + \left(0.375 + v \cdot -0.25\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot t\_1 + 4.5\right)\\
\end{array}
\end{array}
if r < 3.4999999999999999e-91Initial program 84.2%
Simplified84.2%
Taylor expanded in v around 0 79.6%
add-sqr-sqrt84.2%
*-un-lft-identity84.2%
times-frac84.2%
associate-*r*79.4%
sqrt-prod79.3%
sqrt-prod21.1%
add-sqr-sqrt63.5%
sqrt-prod33.1%
add-sqr-sqrt78.7%
associate-*r*68.9%
sqrt-prod68.9%
sqrt-prod25.9%
add-sqr-sqrt78.6%
sqrt-prod48.5%
add-sqr-sqrt99.8%
Applied egg-rr89.7%
if 3.4999999999999999e-91 < r < 9.9999999999999995e195Initial program 89.1%
Simplified98.5%
Taylor expanded in v around 0 98.5%
*-commutative98.5%
Simplified98.5%
if 9.9999999999999995e195 < r Initial program 82.1%
associate--l-82.1%
associate-*l*55.7%
sqr-neg55.7%
associate-*l*82.1%
associate-/l*82.1%
fma-define82.1%
Simplified82.1%
*-un-lft-identity82.1%
add-sqr-sqrt82.2%
times-frac82.2%
associate-*r*55.7%
sqrt-prod55.7%
sqrt-prod82.2%
add-sqr-sqrt82.2%
sqrt-prod73.4%
add-sqr-sqrt73.4%
associate-*r*55.2%
sqrt-prod55.2%
sqrt-prod73.4%
add-sqr-sqrt73.4%
sqrt-prod90.6%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
Taylor expanded in r around inf 99.9%
Final simplification92.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -21.0) (not (<= v 1.6)))
(+ t_0 (+ -1.5 (* (* v -0.25) (/ (* r (* r (* w w))) (+ v -1.0)))))
(+ t_0 (- -1.5 (* (* (* r w) (/ (* r w) (- 1.0 v))) 0.375))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -21.0) || !(v <= 1.6)) {
tmp = t_0 + (-1.5 + ((v * -0.25) * ((r * (r * (w * w))) / (v + -1.0))));
} else {
tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 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 <= (-21.0d0)) .or. (.not. (v <= 1.6d0))) then
tmp = t_0 + ((-1.5d0) + ((v * (-0.25d0)) * ((r * (r * (w * w))) / (v + (-1.0d0)))))
else
tmp = t_0 + ((-1.5d0) - (((r * w) * ((r * w) / (1.0d0 - v))) * 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 <= -21.0) || !(v <= 1.6)) {
tmp = t_0 + (-1.5 + ((v * -0.25) * ((r * (r * (w * w))) / (v + -1.0))));
} else {
tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 0.375));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -21.0) or not (v <= 1.6): tmp = t_0 + (-1.5 + ((v * -0.25) * ((r * (r * (w * w))) / (v + -1.0)))) else: tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 0.375)) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -21.0) || !(v <= 1.6)) tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(v * -0.25) * Float64(Float64(r * Float64(r * Float64(w * w))) / Float64(v + -1.0))))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(1.0 - v))) * 0.375))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -21.0) || ~((v <= 1.6))) tmp = t_0 + (-1.5 + ((v * -0.25) * ((r * (r * (w * w))) / (v + -1.0)))); else tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 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, -21.0], N[Not[LessEqual[v, 1.6]], $MachinePrecision]], N[(t$95$0 + N[(-1.5 + N[(N[(v * -0.25), $MachinePrecision] * N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -21 \lor \neg \left(v \leq 1.6\right):\\
\;\;\;\;t\_0 + \left(-1.5 + \left(v \cdot -0.25\right) \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{v + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right) \cdot 0.375\right)\\
\end{array}
\end{array}
if v < -21 or 1.6000000000000001 < v Initial program 88.3%
Simplified92.8%
Taylor expanded in v around inf 92.1%
*-commutative92.1%
Simplified92.1%
if -21 < v < 1.6000000000000001Initial program 82.5%
Simplified82.5%
Taylor expanded in v around 0 82.0%
add-sqr-sqrt82.5%
*-un-lft-identity82.5%
times-frac82.5%
associate-*r*73.6%
sqrt-prod73.6%
sqrt-prod36.3%
add-sqr-sqrt70.4%
sqrt-prod41.6%
add-sqr-sqrt79.3%
associate-*r*65.0%
sqrt-prod65.0%
sqrt-prod36.9%
add-sqr-sqrt74.7%
sqrt-prod51.8%
add-sqr-sqrt99.8%
Applied egg-rr99.3%
Final simplification95.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= v -1.5e+139)
(+ t_0 (- -1.5 (* 0.375 (/ (* r (* r (* w w))) (- 1.0 v)))))
(+ t_0 (- -1.5 (* (* (* r w) (/ (* r w) (- 1.0 v))) 0.375))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (v <= -1.5e+139) {
tmp = t_0 + (-1.5 - (0.375 * ((r * (r * (w * w))) / (1.0 - v))));
} else {
tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 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 <= (-1.5d+139)) then
tmp = t_0 + ((-1.5d0) - (0.375d0 * ((r * (r * (w * w))) / (1.0d0 - v))))
else
tmp = t_0 + ((-1.5d0) - (((r * w) * ((r * w) / (1.0d0 - v))) * 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 <= -1.5e+139) {
tmp = t_0 + (-1.5 - (0.375 * ((r * (r * (w * w))) / (1.0 - v))));
} else {
tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 0.375));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if v <= -1.5e+139: tmp = t_0 + (-1.5 - (0.375 * ((r * (r * (w * w))) / (1.0 - v)))) else: tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 0.375)) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (v <= -1.5e+139) tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * Float64(r * Float64(w * w))) / Float64(1.0 - v))))); else tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(1.0 - v))) * 0.375))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (v <= -1.5e+139) tmp = t_0 + (-1.5 - (0.375 * ((r * (r * (w * w))) / (1.0 - v)))); else tmp = t_0 + (-1.5 - (((r * w) * ((r * w) / (1.0 - v))) * 0.375)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1.5e+139], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.5 \cdot 10^{+139}:\\
\;\;\;\;t\_0 + \left(-1.5 - 0.375 \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{1 - v}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{1 - v}\right) \cdot 0.375\right)\\
\end{array}
\end{array}
if v < -1.5e139Initial program 91.3%
Simplified94.2%
Taylor expanded in v around 0 86.6%
if -1.5e139 < v Initial program 84.4%
Simplified86.5%
Taylor expanded in v around 0 74.5%
add-sqr-sqrt86.4%
*-un-lft-identity86.4%
times-frac86.4%
associate-*r*79.4%
sqrt-prod79.4%
sqrt-prod40.9%
add-sqr-sqrt72.9%
sqrt-prod38.2%
add-sqr-sqrt76.5%
associate-*r*65.7%
sqrt-prod65.7%
sqrt-prod37.2%
add-sqr-sqrt75.5%
sqrt-prod49.6%
add-sqr-sqrt99.8%
Applied egg-rr85.5%
Final simplification85.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 4e-156)
(- (+ 3.0 t_0) 4.5)
(+ t_0 (- -1.5 (* 0.375 (/ (* r (* r (* w w))) (- 1.0 v))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 4e-156) {
tmp = (3.0 + t_0) - 4.5;
} else {
tmp = t_0 + (-1.5 - (0.375 * ((r * (r * (w * w))) / (1.0 - 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) :: tmp
t_0 = 2.0d0 / (r * r)
if (r <= 4d-156) then
tmp = (3.0d0 + t_0) - 4.5d0
else
tmp = t_0 + ((-1.5d0) - (0.375d0 * ((r * (r * (w * w))) / (1.0d0 - 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 tmp;
if (r <= 4e-156) {
tmp = (3.0 + t_0) - 4.5;
} else {
tmp = t_0 + (-1.5 - (0.375 * ((r * (r * (w * w))) / (1.0 - v))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 4e-156: tmp = (3.0 + t_0) - 4.5 else: tmp = t_0 + (-1.5 - (0.375 * ((r * (r * (w * w))) / (1.0 - v)))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 4e-156) tmp = Float64(Float64(3.0 + t_0) - 4.5); else tmp = Float64(t_0 + Float64(-1.5 - Float64(0.375 * Float64(Float64(r * Float64(r * Float64(w * w))) / Float64(1.0 - v))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 4e-156) tmp = (3.0 + t_0) - 4.5; else tmp = t_0 + (-1.5 - (0.375 * ((r * (r * (w * w))) / (1.0 - v)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 4e-156], N[(N[(3.0 + t$95$0), $MachinePrecision] - 4.5), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(0.375 * N[(N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 4 \cdot 10^{-156}:\\
\;\;\;\;\left(3 + t\_0\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 - 0.375 \cdot \frac{r \cdot \left(r \cdot \left(w \cdot w\right)\right)}{1 - v}\right)\\
\end{array}
\end{array}
if r < 4.00000000000000016e-156Initial program 84.7%
Simplified79.3%
Taylor expanded in r around 0 68.4%
if 4.00000000000000016e-156 < r Initial program 86.2%
Simplified92.5%
Taylor expanded in v around 0 69.7%
Final simplification68.9%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (+ (* (+ 0.375 (* v -0.25)) (* (* r w) (/ (* r w) (+ v -1.0)))) -1.5)))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (((0.375 + (v * -0.25)) * ((r * w) * ((r * w) / (v + -1.0)))) + -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))) * ((r * w) * ((r * w) / (v + (-1.0d0))))) + (-1.5d0))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (((0.375 + (v * -0.25)) * ((r * w) * ((r * w) / (v + -1.0)))) + -1.5);
}
def code(v, w, r): return (2.0 / (r * r)) + (((0.375 + (v * -0.25)) * ((r * w) * ((r * w) / (v + -1.0)))) + -1.5)
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(0.375 + Float64(v * -0.25)) * Float64(Float64(r * w) * Float64(Float64(r * w) / Float64(v + -1.0)))) + -1.5)) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (((0.375 + (v * -0.25)) * ((r * w) * ((r * w) / (v + -1.0)))) + -1.5); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(\left(0.375 + v \cdot -0.25\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{r \cdot w}{v + -1}\right) + -1.5\right)
\end{array}
Initial program 85.3%
Simplified87.5%
Taylor expanded in v around 0 87.5%
*-commutative87.5%
Simplified87.5%
add-sqr-sqrt87.4%
*-un-lft-identity87.4%
times-frac87.4%
associate-*r*80.9%
sqrt-prod80.9%
sqrt-prod41.9%
add-sqr-sqrt72.5%
sqrt-prod38.4%
add-sqr-sqrt75.6%
associate-*r*65.8%
sqrt-prod65.8%
sqrt-prod37.5%
add-sqr-sqrt75.6%
sqrt-prod50.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) 4.5))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - 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))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - 4.5;
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) - 4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - 4.5) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) - 4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) - 4.5
\end{array}
Initial program 85.3%
Simplified80.3%
Taylor expanded in r around 0 61.7%
(FPCore (v w r) :precision binary64 -1.5)
double code(double v, double w, double r) {
return -1.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = -1.5d0
end function
public static double code(double v, double w, double r) {
return -1.5;
}
def code(v, w, r): return -1.5
function code(v, w, r) return -1.5 end
function tmp = code(v, w, r) tmp = -1.5; end
code[v_, w_, r_] := -1.5
\begin{array}{l}
\\
-1.5
\end{array}
Initial program 85.3%
Simplified80.3%
Taylor expanded in r around 0 61.7%
Taylor expanded in r around inf 13.8%
herbie shell --seed 2024139
(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))