
(FPCore (g a) :precision binary64 (cbrt (/ g (* 2.0 a))))
double code(double g, double a) {
return cbrt((g / (2.0 * a)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (2.0 * a)));
}
function code(g, a) return cbrt(Float64(g / Float64(2.0 * a))) end
code[g_, a_] := N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{2 \cdot a}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (g a) :precision binary64 (cbrt (/ g (* 2.0 a))))
double code(double g, double a) {
return cbrt((g / (2.0 * a)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (2.0 * a)));
}
function code(g, a) return cbrt(Float64(g / Float64(2.0 * a))) end
code[g_, a_] := N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{2 \cdot a}}
\end{array}
(FPCore (g a) :precision binary64 (/ (cbrt (* g 0.5)) (cbrt a)))
double code(double g, double a) {
return cbrt((g * 0.5)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((g * 0.5)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(g * 0.5)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g \cdot 0.5}}{\sqrt[3]{a}}
\end{array}
Initial program 78.2%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.8
Applied rewrites98.8%
(FPCore (g a)
:precision binary64
(let* ((t_0 (/ g (* a 2.0))) (t_1 (/ 1.0 (/ a (cbrt (* a (* g (* 0.5 a))))))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 -5e-306)
(cbrt (/ (/ g a) (* (/ 0.5 a) (* a 4.0))))
(if (<= t_0 2e-310)
t_1
(if (<= t_0 2e+302) (/ 1.0 (cbrt (* a (/ 2.0 g)))) t_1))))))
double code(double g, double a) {
double t_0 = g / (a * 2.0);
double t_1 = 1.0 / (a / cbrt((a * (g * (0.5 * a)))));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= -5e-306) {
tmp = cbrt(((g / a) / ((0.5 / a) * (a * 4.0))));
} else if (t_0 <= 2e-310) {
tmp = t_1;
} else if (t_0 <= 2e+302) {
tmp = 1.0 / cbrt((a * (2.0 / g)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double g, double a) {
double t_0 = g / (a * 2.0);
double t_1 = 1.0 / (a / Math.cbrt((a * (g * (0.5 * a)))));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_0 <= -5e-306) {
tmp = Math.cbrt(((g / a) / ((0.5 / a) * (a * 4.0))));
} else if (t_0 <= 2e-310) {
tmp = t_1;
} else if (t_0 <= 2e+302) {
tmp = 1.0 / Math.cbrt((a * (2.0 / g)));
} else {
tmp = t_1;
}
return tmp;
}
function code(g, a) t_0 = Float64(g / Float64(a * 2.0)) t_1 = Float64(1.0 / Float64(a / cbrt(Float64(a * Float64(g * Float64(0.5 * a)))))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= -5e-306) tmp = cbrt(Float64(Float64(g / a) / Float64(Float64(0.5 / a) * Float64(a * 4.0)))); elseif (t_0 <= 2e-310) tmp = t_1; elseif (t_0 <= 2e+302) tmp = Float64(1.0 / cbrt(Float64(a * Float64(2.0 / g)))); else tmp = t_1; end return tmp end
code[g_, a_] := Block[{t$95$0 = N[(g / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(a / N[Power[N[(a * N[(g * N[(0.5 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, -5e-306], N[Power[N[(N[(g / a), $MachinePrecision] / N[(N[(0.5 / a), $MachinePrecision] * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[t$95$0, 2e-310], t$95$1, If[LessEqual[t$95$0, 2e+302], N[(1.0 / N[Power[N[(a * N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{g}{a \cdot 2}\\
t_1 := \frac{1}{\frac{a}{\sqrt[3]{a \cdot \left(g \cdot \left(0.5 \cdot a\right)\right)}}}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\sqrt[3]{\frac{\frac{g}{a}}{\frac{0.5}{a} \cdot \left(a \cdot 4\right)}}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-310}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;\frac{1}{\sqrt[3]{a \cdot \frac{2}{g}}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 g (*.f64 #s(literal 2 binary64) a)) < -inf.0 or -4.99999999999999998e-306 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) < 1.999999999999994e-310 or 2.0000000000000002e302 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) Initial program 7.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.6
Applied rewrites98.6%
Applied rewrites98.4%
Applied rewrites27.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6468.5
Applied rewrites68.5%
if -inf.0 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) < -4.99999999999999998e-306Initial program 99.1%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval99.1
Applied rewrites99.1%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
metadata-evalN/A
*-inversesN/A
times-fracN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
times-fracN/A
associate-/r*N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
metadata-evalN/A
associate-/r/N/A
lift-/.f64N/A
frac-timesN/A
*-lft-identityN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6499.0
Applied rewrites99.0%
if 1.999999999999994e-310 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) < 2.0000000000000002e302Initial program 99.1%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
Applied rewrites42.3%
Applied rewrites98.9%
Final simplification91.3%
herbie shell --seed 2024226
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))