
(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 (/ 1.0 a)) (cbrt g)) (cbrt 0.5)))
double code(double g, double a) {
return (cbrt((1.0 / a)) * cbrt(g)) * cbrt(0.5);
}
public static double code(double g, double a) {
return (Math.cbrt((1.0 / a)) * Math.cbrt(g)) * Math.cbrt(0.5);
}
function code(g, a) return Float64(Float64(cbrt(Float64(1.0 / a)) * cbrt(g)) * cbrt(0.5)) end
code[g_, a_] := N[(N[(N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt[3]{\frac{1}{a}} \cdot \sqrt[3]{g}\right) \cdot \sqrt[3]{0.5}
\end{array}
Initial program 73.4%
Taylor expanded in g around 0 73.4%
pow1/339.4%
div-inv39.4%
unpow-prod-down26.6%
pow1/348.3%
Applied egg-rr48.3%
unpow1/398.7%
*-commutative98.7%
Simplified98.7%
(FPCore (g a) :precision binary64 (/ (* (cbrt g) (cbrt 0.5)) (cbrt a)))
double code(double g, double a) {
return (cbrt(g) * cbrt(0.5)) / cbrt(a);
}
public static double code(double g, double a) {
return (Math.cbrt(g) * Math.cbrt(0.5)) / Math.cbrt(a);
}
function code(g, a) return Float64(Float64(cbrt(g) * cbrt(0.5)) / cbrt(a)) end
code[g_, a_] := N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g} \cdot \sqrt[3]{0.5}}{\sqrt[3]{a}}
\end{array}
Initial program 73.4%
pow1/339.8%
clear-num39.0%
associate-/r/39.8%
unpow-prod-down26.6%
pow1/346.5%
associate-/r*46.5%
metadata-eval46.5%
pow1/398.7%
Applied egg-rr98.7%
*-commutative98.7%
cbrt-div98.7%
associate-*r/98.7%
Applied egg-rr98.7%
(FPCore (g a) :precision binary64 (/ (cbrt g) (/ (cbrt a) (cbrt 0.5))))
double code(double g, double a) {
return cbrt(g) / (cbrt(a) / cbrt(0.5));
}
public static double code(double g, double a) {
return Math.cbrt(g) / (Math.cbrt(a) / Math.cbrt(0.5));
}
function code(g, a) return Float64(cbrt(g) / Float64(cbrt(a) / cbrt(0.5))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[(N[Power[a, 1/3], $MachinePrecision] / N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\frac{\sqrt[3]{a}}{\sqrt[3]{0.5}}}
\end{array}
Initial program 73.4%
cbrt-div98.4%
clear-num98.4%
Applied egg-rr98.4%
associate-/r/98.3%
associate-*l/98.4%
*-lft-identity98.4%
*-commutative98.4%
Simplified98.4%
cbrt-undiv73.4%
metadata-eval73.4%
div-inv73.4%
add-cube-cbrt73.3%
cbrt-undiv73.2%
cbrt-undiv73.2%
cbrt-undiv73.0%
cbrt-undiv98.1%
*-un-lft-identity98.1%
add-cbrt-cube98.7%
div-inv98.4%
times-frac98.5%
Applied egg-rr98.5%
associate-*r/98.5%
associate-*l/98.5%
*-lft-identity98.5%
associate-/l/98.4%
associate-*l/98.7%
*-lft-identity98.7%
Simplified98.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 73.4%
pow1/339.8%
clear-num39.0%
associate-/r/39.8%
unpow-prod-down26.6%
pow1/346.5%
associate-/r*46.5%
metadata-eval46.5%
pow1/398.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (* 2.0 (/ a g)))))
double code(double g, double a) {
return 1.0 / cbrt((2.0 * (a / g)));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt((2.0 * (a / g)));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(2.0 * Float64(a / g)))) end
code[g_, a_] := N[(1.0 / N[Power[N[(2.0 * N[(a / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{2 \cdot \frac{a}{g}}}
\end{array}
Initial program 73.4%
clear-num72.4%
cbrt-div73.5%
metadata-eval73.5%
associate-/l*73.9%
Applied egg-rr73.9%
(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 73.4%
clear-num72.4%
associate-/r/73.5%
associate-/r*73.8%
metadata-eval73.8%
Applied egg-rr73.8%
Final simplification73.8%
herbie shell --seed 2024158
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))