
(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 10 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)) (/ 1.0 (cbrt (* a -2.0)))))
double code(double g, double a) {
return cbrt(-g) * (1.0 / cbrt((a * -2.0)));
}
public static double code(double g, double a) {
return Math.cbrt(-g) * (1.0 / Math.cbrt((a * -2.0)));
}
function code(g, a) return Float64(cbrt(Float64(-g)) * Float64(1.0 / cbrt(Float64(a * -2.0)))) end
code[g_, a_] := N[(N[Power[(-g), 1/3], $MachinePrecision] * N[(1.0 / N[Power[N[(a * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-g} \cdot \frac{1}{\sqrt[3]{a \cdot -2}}
\end{array}
Initial program 76.0%
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%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
metadata-evalN/A
div-invN/A
associate-/r/N/A
lift-/.f64N/A
frac-2negN/A
cbrt-divN/A
div-invN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) -2e-301) (* (cbrt (- g)) (pow (* a -2.0) -0.3333333333333333)) (* (cbrt g) (pow (* a 2.0) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -2e-301) {
tmp = cbrt(-g) * pow((a * -2.0), -0.3333333333333333);
} else {
tmp = cbrt(g) * pow((a * 2.0), -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -2e-301) {
tmp = Math.cbrt(-g) * Math.pow((a * -2.0), -0.3333333333333333);
} else {
tmp = Math.cbrt(g) * Math.pow((a * 2.0), -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= -2e-301) tmp = Float64(cbrt(Float64(-g)) * (Float64(a * -2.0) ^ -0.3333333333333333)); else tmp = Float64(cbrt(g) * (Float64(a * 2.0) ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], -2e-301], N[(N[Power[(-g), 1/3], $MachinePrecision] * N[Power[N[(a * -2.0), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(a * 2.0), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq -2 \cdot 10^{-301}:\\
\;\;\;\;\sqrt[3]{-g} \cdot {\left(a \cdot -2\right)}^{-0.3333333333333333}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(a \cdot 2\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -2.00000000000000013e-301Initial program 76.5%
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%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
metadata-evalN/A
div-invN/A
associate-/r/N/A
lift-/.f64N/A
frac-2negN/A
cbrt-divN/A
div-invN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites98.6%
lift-/.f64N/A
lift-cbrt.f64N/A
pow1/3N/A
pow-flipN/A
metadata-evalN/A
lower-pow.f6492.1
Applied rewrites92.1%
if -2.00000000000000013e-301 < (*.f64 #s(literal 2 binary64) a) Initial program 75.7%
lift-cbrt.f64N/A
lift-/.f64N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f6490.9
Applied rewrites90.9%
Final simplification91.5%
herbie shell --seed 2024229
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))