
(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 7 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) (cbrt (/ 2.0 (/ 1.0 a)))))
double code(double g, double a) {
return cbrt(g) / cbrt((2.0 / (1.0 / a)));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((2.0 / (1.0 / a)));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(2.0 / Float64(1.0 / a)))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(2.0 / N[(1.0 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{\frac{2}{\frac{1}{a}}}}
\end{array}
Initial program 76.0%
lift-cbrt.f64N/A
lift-/.f64N/A
frac-2negN/A
cbrt-divN/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
associate-/r*N/A
lower-/.f64N/A
pow1/3N/A
sqr-powN/A
pow-prod-downN/A
sqr-negN/A
remove-double-negN/A
remove-double-negN/A
pow-prod-downN/A
sqr-powN/A
pow1/3N/A
lower-/.f64N/A
lower-cbrt.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-cbrt.f641.7
remove-double-divN/A
Applied rewrites98.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-prodN/A
neg-mul-1N/A
lower-cbrt.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f6498.8
Applied rewrites98.8%
lift-*.f64N/A
metadata-evalN/A
metadata-evalN/A
associate-/r/N/A
div-invN/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f64N/A
metadata-eval98.8
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) -4e-307) (* (cbrt (* -0.5 g)) (pow (- a) -0.3333333333333333)) (* (cbrt (* 0.5 g)) (pow a -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -4e-307) {
tmp = cbrt((-0.5 * g)) * pow(-a, -0.3333333333333333);
} else {
tmp = cbrt((0.5 * g)) * pow(a, -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -4e-307) {
tmp = Math.cbrt((-0.5 * g)) * Math.pow(-a, -0.3333333333333333);
} else {
tmp = Math.cbrt((0.5 * g)) * Math.pow(a, -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= -4e-307) tmp = Float64(cbrt(Float64(-0.5 * g)) * (Float64(-a) ^ -0.3333333333333333)); else tmp = Float64(cbrt(Float64(0.5 * g)) * (a ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], -4e-307], N[(N[Power[N[(-0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[(-a), -0.3333333333333333], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq -4 \cdot 10^{-307}:\\
\;\;\;\;\sqrt[3]{-0.5 \cdot g} \cdot {\left(-a\right)}^{-0.3333333333333333}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{0.5 \cdot g} \cdot {a}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -3.99999999999999964e-307Initial program 76.3%
Applied rewrites92.1%
if -3.99999999999999964e-307 < (*.f64 #s(literal 2 binary64) a) Initial program 76.2%
lift-cbrt.f64N/A
lift-/.f64N/A
frac-2negN/A
cbrt-divN/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
associate-/r*N/A
lower-/.f64N/A
pow1/3N/A
sqr-powN/A
pow-prod-downN/A
sqr-negN/A
remove-double-negN/A
remove-double-negN/A
pow-prod-downN/A
sqr-powN/A
pow1/3N/A
lower-/.f64N/A
lower-cbrt.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-cbrt.f641.7
remove-double-divN/A
Applied rewrites98.7%
lift-/.f64N/A
clear-numN/A
metadata-evalN/A
lift-cbrt.f64N/A
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
cbrt-undivN/A
lift-*.f64N/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
times-fracN/A
metadata-evalN/A
associate-/l*N/A
associate-*l/N/A
lift-/.f64N/A
cbrt-divN/A
associate-/l/N/A
lift-/.f64N/A
Applied rewrites92.0%
Final simplification92.1%
herbie shell --seed 2024234
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))