
(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}
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (+ -1.5 (* (* r w) (* (* r w) (/ (fma v -0.25 0.375) (+ v -1.0)))))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 + ((r * w) * ((r * w) * (fma(v, -0.25, 0.375) / (v + -1.0)))));
}
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 + Float64(Float64(r * w) * Float64(Float64(r * w) * Float64(fma(v, -0.25, 0.375) / Float64(v + -1.0)))))) end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 + N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(N[(v * -0.25 + 0.375), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 + \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{\mathsf{fma}\left(v, -0.25, 0.375\right)}{v + -1}\right)\right)
\end{array}
Initial program 84.2%
Simplified86.7%
Taylor expanded in v around inf 86.7%
sub-neg86.7%
associate-*r/86.7%
metadata-eval86.7%
metadata-eval86.7%
Simplified86.7%
*-commutative86.7%
distribute-lft-in86.7%
distribute-lft-in73.8%
Applied egg-rr84.6%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (pow (* r w) 2.0)) (t_1 (/ 2.0 (* r r))))
(if (or (<= v -1.15) (not (<= v 0.5)))
(+ 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 = pow((r * w), 2.0);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -1.15) || !(v <= 0.5)) {
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) ** 2.0d0
t_1 = 2.0d0 / (r * r)
if ((v <= (-1.15d0)) .or. (.not. (v <= 0.5d0))) 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 = Math.pow((r * w), 2.0);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -1.15) || !(v <= 0.5)) {
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 = math.pow((r * w), 2.0) t_1 = 2.0 / (r * r) tmp = 0 if (v <= -1.15) or not (v <= 0.5): 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(r * w) ^ 2.0 t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -1.15) || !(v <= 0.5)) 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) ^ 2.0; t_1 = 2.0 / (r * r); tmp = 0.0; if ((v <= -1.15) || ~((v <= 0.5))) 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[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -1.15], N[Not[LessEqual[v, 0.5]], $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)}^{2}\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.15 \lor \neg \left(v \leq 0.5\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 < -1.1499999999999999 or 0.5 < v Initial program 82.2%
Simplified87.0%
Taylor expanded in v around inf 82.6%
*-commutative82.6%
unpow282.6%
unpow282.6%
swap-sqr99.4%
unpow299.4%
Simplified99.4%
if -1.1499999999999999 < v < 0.5Initial program 86.3%
Simplified86.3%
Taylor expanded in v around 0 80.2%
*-commutative80.2%
unpow280.2%
unpow280.2%
swap-sqr98.9%
unpow298.9%
Simplified98.9%
Final simplification99.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= (* w w) 2e+250)
(+
t_0
(+ -1.5 (* (+ 0.375 (* v -0.25)) (* r (* (* w w) (/ r (+ v -1.0)))))))
(+ t_0 (- -1.5 (* (pow (* r w) 2.0) 0.25))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((w * w) <= 2e+250) {
tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = t_0 + (-1.5 - (pow((r * w), 2.0) * 0.25));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if ((w * w) <= 2d+250) then
tmp = t_0 + ((-1.5d0) + ((0.375d0 + (v * (-0.25d0))) * (r * ((w * w) * (r / (v + (-1.0d0)))))))
else
tmp = t_0 + ((-1.5d0) - (((r * w) ** 2.0d0) * 0.25d0))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((w * w) <= 2e+250) {
tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * (r * ((w * w) * (r / (v + -1.0))))));
} else {
tmp = t_0 + (-1.5 - (Math.pow((r * w), 2.0) * 0.25));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (w * w) <= 2e+250: tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * (r * ((w * w) * (r / (v + -1.0)))))) else: tmp = t_0 + (-1.5 - (math.pow((r * w), 2.0) * 0.25)) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(w * w) <= 2e+250) tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(0.375 + Float64(v * -0.25)) * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); else tmp = Float64(t_0 + Float64(-1.5 - Float64((Float64(r * w) ^ 2.0) * 0.25))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((w * w) <= 2e+250) tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * (r * ((w * w) * (r / (v + -1.0)))))); else tmp = t_0 + (-1.5 - (((r * w) ^ 2.0) * 0.25)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(w * w), $MachinePrecision], 2e+250], N[(t$95$0 + N[(-1.5 + N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.5 - N[(N[Power[N[(r * w), $MachinePrecision], 2.0], $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \cdot w \leq 2 \cdot 10^{+250}:\\
\;\;\;\;t\_0 + \left(-1.5 + \left(0.375 + v \cdot -0.25\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 - {\left(r \cdot w\right)}^{2} \cdot 0.25\right)\\
\end{array}
\end{array}
if (*.f64 w w) < 1.9999999999999998e250Initial program 94.3%
Simplified97.5%
fma-undefine97.5%
distribute-rgt-in97.5%
associate-*l*97.5%
metadata-eval97.5%
metadata-eval97.5%
Applied egg-rr97.5%
if 1.9999999999999998e250 < (*.f64 w w) Initial program 62.4%
Simplified63.4%
Taylor expanded in v around inf 63.5%
*-commutative63.5%
unpow263.5%
unpow263.5%
swap-sqr97.3%
unpow297.3%
Simplified97.3%
Final simplification97.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* r (* (* w w) (/ r (+ v -1.0)))))
(t_1 (/ 2.0 (* r r)))
(t_2 (+ t_1 (+ -1.5 (* (* v -0.25) t_0)))))
(if (<= v -1e+242)
t_2
(if (<= v -3.15e+178)
(+ t_1 -1.5)
(if (or (<= v -13000000000000.0) (not (<= v 4000.0)))
t_2
(+ t_1 (+ -1.5 (* 0.375 t_0))))))))
double code(double v, double w, double r) {
double t_0 = r * ((w * w) * (r / (v + -1.0)));
double t_1 = 2.0 / (r * r);
double t_2 = t_1 + (-1.5 + ((v * -0.25) * t_0));
double tmp;
if (v <= -1e+242) {
tmp = t_2;
} else if (v <= -3.15e+178) {
tmp = t_1 + -1.5;
} else if ((v <= -13000000000000.0) || !(v <= 4000.0)) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_0 = r * ((w * w) * (r / (v + (-1.0d0))))
t_1 = 2.0d0 / (r * r)
t_2 = t_1 + ((-1.5d0) + ((v * (-0.25d0)) * t_0))
if (v <= (-1d+242)) then
tmp = t_2
else if (v <= (-3.15d+178)) then
tmp = t_1 + (-1.5d0)
else if ((v <= (-13000000000000.0d0)) .or. (.not. (v <= 4000.0d0))) then
tmp = t_2
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 * w) * (r / (v + -1.0)));
double t_1 = 2.0 / (r * r);
double t_2 = t_1 + (-1.5 + ((v * -0.25) * t_0));
double tmp;
if (v <= -1e+242) {
tmp = t_2;
} else if (v <= -3.15e+178) {
tmp = t_1 + -1.5;
} else if ((v <= -13000000000000.0) || !(v <= 4000.0)) {
tmp = t_2;
} else {
tmp = t_1 + (-1.5 + (0.375 * t_0));
}
return tmp;
}
def code(v, w, r): t_0 = r * ((w * w) * (r / (v + -1.0))) t_1 = 2.0 / (r * r) t_2 = t_1 + (-1.5 + ((v * -0.25) * t_0)) tmp = 0 if v <= -1e+242: tmp = t_2 elif v <= -3.15e+178: tmp = t_1 + -1.5 elif (v <= -13000000000000.0) or not (v <= 4000.0): tmp = t_2 else: tmp = t_1 + (-1.5 + (0.375 * t_0)) return tmp
function code(v, w, r) t_0 = Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0)))) t_1 = Float64(2.0 / Float64(r * r)) t_2 = Float64(t_1 + Float64(-1.5 + Float64(Float64(v * -0.25) * t_0))) tmp = 0.0 if (v <= -1e+242) tmp = t_2; elseif (v <= -3.15e+178) tmp = Float64(t_1 + -1.5); elseif ((v <= -13000000000000.0) || !(v <= 4000.0)) tmp = t_2; 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 * w) * (r / (v + -1.0))); t_1 = 2.0 / (r * r); t_2 = t_1 + (-1.5 + ((v * -0.25) * t_0)); tmp = 0.0; if (v <= -1e+242) tmp = t_2; elseif (v <= -3.15e+178) tmp = t_1 + -1.5; elseif ((v <= -13000000000000.0) || ~((v <= 4000.0))) tmp = t_2; else tmp = t_1 + (-1.5 + (0.375 * t_0)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(-1.5 + N[(N[(v * -0.25), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1e+242], t$95$2, If[LessEqual[v, -3.15e+178], N[(t$95$1 + -1.5), $MachinePrecision], If[Or[LessEqual[v, -13000000000000.0], N[Not[LessEqual[v, 4000.0]], $MachinePrecision]], t$95$2, N[(t$95$1 + N[(-1.5 + N[(0.375 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\\
t_1 := \frac{2}{r \cdot r}\\
t_2 := t\_1 + \left(-1.5 + \left(v \cdot -0.25\right) \cdot t\_0\right)\\
\mathbf{if}\;v \leq -1 \cdot 10^{+242}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;v \leq -3.15 \cdot 10^{+178}:\\
\;\;\;\;t\_1 + -1.5\\
\mathbf{elif}\;v \leq -13000000000000 \lor \neg \left(v \leq 4000\right):\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \left(-1.5 + 0.375 \cdot t\_0\right)\\
\end{array}
\end{array}
if v < -1.00000000000000005e242 or -3.15000000000000015e178 < v < -1.3e13 or 4e3 < v Initial program 85.1%
Simplified91.0%
Taylor expanded in v around inf 91.0%
*-commutative91.0%
Simplified91.0%
if -1.00000000000000005e242 < v < -3.15000000000000015e178Initial program 68.7%
Simplified68.7%
add-cube-cbrt68.8%
pow368.8%
Applied egg-rr99.9%
Taylor expanded in r around 0 94.5%
if -1.3e13 < v < 4e3Initial program 85.3%
Simplified85.3%
Taylor expanded in v around 0 84.4%
Final simplification87.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 1.6e-84)
(+ t_0 -1.5)
(+
t_0
(+ -1.5 (* (+ 0.375 (* v -0.25)) (* r (* (* w w) (/ r (+ v -1.0))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 1.6e-84) {
tmp = t_0 + -1.5;
} else {
tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * (r * ((w * w) * (r / (v + -1.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 = 2.0d0 / (r * r)
if (r <= 1.6d-84) then
tmp = t_0 + (-1.5d0)
else
tmp = t_0 + ((-1.5d0) + ((0.375d0 + (v * (-0.25d0))) * (r * ((w * w) * (r / (v + (-1.0d0)))))))
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 <= 1.6e-84) {
tmp = t_0 + -1.5;
} else {
tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * (r * ((w * w) * (r / (v + -1.0))))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 1.6e-84: tmp = t_0 + -1.5 else: tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * (r * ((w * w) * (r / (v + -1.0)))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 1.6e-84) tmp = Float64(t_0 + -1.5); else tmp = Float64(t_0 + Float64(-1.5 + Float64(Float64(0.375 + Float64(v * -0.25)) * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 1.6e-84) tmp = t_0 + -1.5; else tmp = t_0 + (-1.5 + ((0.375 + (v * -0.25)) * (r * ((w * w) * (r / (v + -1.0)))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 1.6e-84], N[(t$95$0 + -1.5), $MachinePrecision], N[(t$95$0 + N[(-1.5 + N[(N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision] * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 1.6 \cdot 10^{-84}:\\
\;\;\;\;t\_0 + -1.5\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 + \left(0.375 + v \cdot -0.25\right) \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\end{array}
\end{array}
if r < 1.6e-84Initial program 78.5%
Simplified81.7%
add-cube-cbrt81.6%
pow381.6%
Applied egg-rr99.7%
Taylor expanded in r around 0 72.4%
if 1.6e-84 < r Initial program 96.1%
Simplified97.2%
fma-undefine97.2%
distribute-rgt-in97.2%
associate-*l*97.2%
metadata-eval97.2%
metadata-eval97.2%
Applied egg-rr97.2%
Final simplification80.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 1.1e-83)
(+ t_0 -1.5)
(+ t_0 (+ -1.5 (* 0.375 (* r (* (* w w) (/ r (+ v -1.0))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 1.1e-83) {
tmp = t_0 + -1.5;
} else {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.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 = 2.0d0 / (r * r)
if (r <= 1.1d-83) then
tmp = t_0 + (-1.5d0)
else
tmp = t_0 + ((-1.5d0) + (0.375d0 * (r * ((w * w) * (r / (v + (-1.0d0)))))))
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 <= 1.1e-83) {
tmp = t_0 + -1.5;
} else {
tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0))))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 1.1e-83: tmp = t_0 + -1.5 else: tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 1.1e-83) tmp = Float64(t_0 + -1.5); else tmp = Float64(t_0 + Float64(-1.5 + Float64(0.375 * Float64(r * Float64(Float64(w * w) * Float64(r / Float64(v + -1.0))))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 1.1e-83) tmp = t_0 + -1.5; else tmp = t_0 + (-1.5 + (0.375 * (r * ((w * w) * (r / (v + -1.0)))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 1.1e-83], N[(t$95$0 + -1.5), $MachinePrecision], N[(t$95$0 + N[(-1.5 + N[(0.375 * N[(r * N[(N[(w * w), $MachinePrecision] * N[(r / N[(v + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 1.1 \cdot 10^{-83}:\\
\;\;\;\;t\_0 + -1.5\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(-1.5 + 0.375 \cdot \left(r \cdot \left(\left(w \cdot w\right) \cdot \frac{r}{v + -1}\right)\right)\right)\\
\end{array}
\end{array}
if r < 1.10000000000000004e-83Initial program 78.5%
Simplified81.7%
add-cube-cbrt81.6%
pow381.6%
Applied egg-rr99.7%
Taylor expanded in r around 0 72.4%
if 1.10000000000000004e-83 < r Initial program 96.1%
Simplified97.2%
Taylor expanded in v around 0 77.5%
Final simplification74.0%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) -1.5))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + -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)) + (-1.5d0)
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + -1.5;
}
def code(v, w, r): return (2.0 / (r * r)) + -1.5
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + -1.5) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + -1.5; end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + -1.5
\end{array}
Initial program 84.2%
Simplified86.7%
add-cube-cbrt86.6%
pow386.6%
Applied egg-rr99.6%
Taylor expanded in r around 0 60.4%
herbie shell --seed 2024111
(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))