
(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) (cbrt -0.5)) (cbrt (/ -1.0 a))))
double code(double g, double a) {
return (cbrt(g) * cbrt(-0.5)) * cbrt((-1.0 / a));
}
public static double code(double g, double a) {
return (Math.cbrt(g) * Math.cbrt(-0.5)) * Math.cbrt((-1.0 / a));
}
function code(g, a) return Float64(Float64(cbrt(g) * cbrt(-0.5)) * cbrt(Float64(-1.0 / a))) end
code[g_, a_] := N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt[3]{g} \cdot \sqrt[3]{-0.5}\right) \cdot \sqrt[3]{\frac{-1}{a}}
\end{array}
Initial program 77.4%
associate-/r*N/A
frac-2negN/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
metadata-evalN/A
cbrt-lowering-cbrt.f64N/A
metadata-evalN/A
frac-2negN/A
/-lowering-/.f6443.9%
Applied egg-rr43.9%
div-invN/A
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
pow1/3N/A
*-lowering-*.f64N/A
cbrt-lowering-cbrt.f64N/A
pow1/3N/A
cbrt-lowering-cbrt.f64N/A
metadata-eval98.7%
Applied egg-rr98.7%
(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.4%
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.f6445.7%
Applied egg-rr45.7%
metadata-evalN/A
pow-powN/A
inv-powN/A
clear-numN/A
pow1/3N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f6498.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (/ a (/ g 2.0)))))
double code(double g, double a) {
return 1.0 / cbrt((a / (g / 2.0)));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt((a / (g / 2.0)));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(a / Float64(g / 2.0)))) end
code[g_, a_] := N[(1.0 / N[Power[N[(a / N[(g / 2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{a}{\frac{g}{2}}}}
\end{array}
Initial program 77.4%
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.f6445.7%
Applied egg-rr45.7%
metadata-evalN/A
pow-powN/A
inv-powN/A
clear-numN/A
pow1/3N/A
cbrt-lowering-cbrt.f64N/A
/-lowering-/.f6498.7%
Applied egg-rr98.7%
Applied egg-rr78.2%
(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.4%
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 2024161
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))