
(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 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 78.5%
pow1/337.2%
associate-/r*37.2%
div-inv37.2%
unpow-prod-down22.6%
pow1/343.8%
div-inv43.8%
metadata-eval43.8%
Applied egg-rr43.8%
*-commutative43.8%
unpow1/398.8%
Simplified98.8%
*-commutative98.8%
cbrt-prod98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (* (cbrt (/ 1.0 a)) (cbrt (* g 0.5))))
double code(double g, double a) {
return cbrt((1.0 / a)) * cbrt((g * 0.5));
}
public static double code(double g, double a) {
return Math.cbrt((1.0 / a)) * Math.cbrt((g * 0.5));
}
function code(g, a) return Float64(cbrt(Float64(1.0 / a)) * cbrt(Float64(g * 0.5))) end
code[g_, a_] := N[(N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{1}{a}} \cdot \sqrt[3]{g \cdot 0.5}
\end{array}
Initial program 78.5%
pow1/337.2%
associate-/r*37.2%
div-inv37.2%
unpow-prod-down22.6%
pow1/343.8%
div-inv43.8%
metadata-eval43.8%
Applied egg-rr43.8%
*-commutative43.8%
unpow1/398.8%
Simplified98.8%
Final simplification98.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 78.5%
pow1/337.2%
clear-num36.3%
associate-/r/37.2%
unpow-prod-down22.3%
pow1/347.6%
associate-/r*47.9%
metadata-eval47.9%
pow1/398.6%
Applied egg-rr98.6%
Final simplification98.6%
(FPCore (g a) :precision binary64 (/ (cbrt (* g 0.5)) (cbrt a)))
double code(double g, double a) {
return cbrt((g * 0.5)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((g * 0.5)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(g * 0.5)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g \cdot 0.5}}{\sqrt[3]{a}}
\end{array}
Initial program 78.5%
associate-/r*78.5%
cbrt-div98.7%
div-inv98.7%
metadata-eval98.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 78.5%
add-log-exp10.1%
*-un-lft-identity10.1%
log-prod10.1%
metadata-eval10.1%
add-log-exp78.5%
*-un-lft-identity78.5%
times-frac78.5%
metadata-eval78.5%
Applied egg-rr78.5%
+-lft-identity78.5%
associate-*r/78.5%
associate-/l*77.3%
associate-/r/78.5%
Simplified78.5%
Final simplification78.5%
(FPCore (g a) :precision binary64 (cbrt (/ g (* a 2.0))))
double code(double g, double a) {
return cbrt((g / (a * 2.0)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (a * 2.0)));
}
function code(g, a) return cbrt(Float64(g / Float64(a * 2.0))) end
code[g_, a_] := N[Power[N[(g / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{a \cdot 2}}
\end{array}
Initial program 78.5%
Final simplification78.5%
herbie shell --seed 2024041
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))