
(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 4 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 2.0)) (cbrt a)))
double code(double g, double a) {
return cbrt((g / 2.0)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((g / 2.0)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(g / 2.0)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(g / 2.0), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{\frac{g}{2}}}{\sqrt[3]{a}}
\end{array}
Initial program 77.5%
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
inv-powN/A
pow-powN/A
unpow-prod-downN/A
metadata-evalN/A
metadata-evalN/A
pow-flipN/A
pow1/3N/A
div-invN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
metadata-evalN/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f6498.6%
Applied egg-rr98.6%
sqr-powN/A
pow2N/A
pow-lowering-pow.f64N/A
pow-lowering-pow.f64N/A
metadata-eval98.7%
Applied egg-rr98.7%
*-commutativeN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-flipN/A
pow1/3N/A
div-invN/A
cbrt-divN/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f6498.8%
Applied egg-rr98.8%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (/ a 0.5))))
double code(double g, double a) {
return cbrt(g) / cbrt((a / 0.5));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((a / 0.5));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(a / 0.5))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a / 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{\frac{a}{0.5}}}
\end{array}
Initial program 77.5%
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
inv-powN/A
pow-powN/A
unpow-prod-downN/A
metadata-evalN/A
metadata-evalN/A
pow-flipN/A
pow1/3N/A
div-invN/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
metadata-evalN/A
cbrt-lowering-cbrt.f64N/A
cbrt-lowering-cbrt.f6498.6%
Applied egg-rr98.6%
sqr-powN/A
pow2N/A
pow-lowering-pow.f64N/A
pow-lowering-pow.f64N/A
metadata-eval98.7%
Applied egg-rr98.7%
*-commutativeN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-flipN/A
pow1/3N/A
div-invN/A
cbrt-divN/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f6498.8%
Applied egg-rr98.8%
cbrt-undivN/A
div-invN/A
metadata-evalN/A
associate-/l*N/A
cbrt-unprodN/A
cbrt-undivN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
cbrt-lowering-cbrt.f64N/A
cbrt-undivN/A
metadata-evalN/A
distribute-neg-frac2N/A
cbrt-lowering-cbrt.f64N/A
distribute-neg-frac2N/A
metadata-evalN/A
/-lowering-/.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 77.5%
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
*-lowering-*.f64N/A
inv-powN/A
pow-powN/A
pow-lowering-pow.f64N/A
remove-double-divN/A
associate-/r*N/A
clear-numN/A
/-lowering-/.f64N/A
metadata-evalN/A
metadata-evalN/A
cbrt-lowering-cbrt.f6447.4%
Applied egg-rr47.4%
clear-numN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
pow1/3N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f6498.7%
Applied egg-rr98.7%
Final simplification98.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 77.5%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-eval77.5%
Applied egg-rr77.5%
Final simplification77.5%
herbie shell --seed 2024163
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))