
(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 6 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 81.7%
lift-*.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.8
Applied egg-rr98.8%
metadata-evalN/A
associate-/r/N/A
div-invN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6498.8
Applied egg-rr98.8%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) -2e-305) (/ 1.0 (cbrt (/ a (* g 0.5)))) (* (pow a -0.3333333333333333) (cbrt (* g 0.5)))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -2e-305) {
tmp = 1.0 / cbrt((a / (g * 0.5)));
} else {
tmp = pow(a, -0.3333333333333333) * cbrt((g * 0.5));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -2e-305) {
tmp = 1.0 / Math.cbrt((a / (g * 0.5)));
} else {
tmp = Math.pow(a, -0.3333333333333333) * Math.cbrt((g * 0.5));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= -2e-305) tmp = Float64(1.0 / cbrt(Float64(a / Float64(g * 0.5)))); else tmp = Float64((a ^ -0.3333333333333333) * cbrt(Float64(g * 0.5))); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], -2e-305], N[(1.0 / N[Power[N[(a / N[(g * 0.5), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[a, -0.3333333333333333], $MachinePrecision] * N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq -2 \cdot 10^{-305}:\\
\;\;\;\;\frac{1}{\sqrt[3]{\frac{a}{g \cdot 0.5}}}\\
\mathbf{else}:\\
\;\;\;\;{a}^{-0.3333333333333333} \cdot \sqrt[3]{g \cdot 0.5}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -1.99999999999999999e-305Initial program 81.1%
lift-*.f64N/A
clear-numN/A
cbrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-cbrt.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/r*N/A
clear-numN/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval81.2
Applied egg-rr81.2%
if -1.99999999999999999e-305 < (*.f64 #s(literal 2 binary64) a) Initial program 82.3%
associate-/r*N/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.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval92.3
Applied egg-rr92.3%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (* 2.0 a))))
double code(double g, double a) {
return cbrt(g) / cbrt((2.0 * a));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((2.0 * a));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(2.0 * a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(2.0 * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{2 \cdot a}}
\end{array}
Initial program 81.7%
lift-*.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.8
Applied egg-rr98.8%
(FPCore (g a) :precision binary64 (* (cbrt g) (cbrt (/ 0.5 a))))
double code(double g, double a) {
return cbrt(g) * cbrt((0.5 / a));
}
public static double code(double g, double a) {
return Math.cbrt(g) * Math.cbrt((0.5 / a));
}
function code(g, a) return Float64(cbrt(g) * cbrt(Float64(0.5 / a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g} \cdot \sqrt[3]{\frac{0.5}{a}}
\end{array}
Initial program 81.7%
lift-*.f64N/A
div-invN/A
inv-powN/A
sqr-powN/A
sqr-powN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
pow2N/A
remove-double-negN/A
remove-double-negN/A
sqr-negN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
Applied egg-rr44.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
associate-/r/N/A
un-div-invN/A
clear-numN/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
cbrt-prodN/A
lift-cbrt.f64N/A
lower-*.f64N/A
Applied egg-rr57.4%
lift-*.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
*-inversesN/A
lift-/.f64N/A
*-rgt-identity98.7
Applied egg-rr98.7%
(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}
Initial program 81.7%
(FPCore (g a) :precision binary64 (cbrt (* g (/ 0.5 a))))
double code(double g, double a) {
return cbrt((g * (0.5 / a)));
}
public static double code(double g, double a) {
return Math.cbrt((g * (0.5 / a)));
}
function code(g, a) return cbrt(Float64(g * Float64(0.5 / a))) end
code[g_, a_] := N[Power[N[(g * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g \cdot \frac{0.5}{a}}
\end{array}
Initial program 81.7%
lift-*.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval81.7
Applied egg-rr81.7%
Final simplification81.7%
herbie shell --seed 2024207
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))