
(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 7 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 (/ 1.0 a))) (cbrt 0.5)))
double code(double g, double a) {
return (cbrt(g) * cbrt((1.0 / a))) * cbrt(0.5);
}
public static double code(double g, double a) {
return (Math.cbrt(g) * Math.cbrt((1.0 / a))) * Math.cbrt(0.5);
}
function code(g, a) return Float64(Float64(cbrt(g) * cbrt(Float64(1.0 / a))) * cbrt(0.5)) end
code[g_, a_] := N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \sqrt[3]{0.5}
\end{array}
Initial program 76.5%
Taylor expanded in g around 0 76.4%
pow1/337.1%
div-inv37.1%
unpow-prod-down20.8%
pow1/343.9%
Applied egg-rr43.9%
unpow1/398.8%
Simplified98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (/ 1.0 (/ (cbrt (* a 2.0)) (cbrt g))))
double code(double g, double a) {
return 1.0 / (cbrt((a * 2.0)) / cbrt(g));
}
public static double code(double g, double a) {
return 1.0 / (Math.cbrt((a * 2.0)) / Math.cbrt(g));
}
function code(g, a) return Float64(1.0 / Float64(cbrt(Float64(a * 2.0)) / cbrt(g))) end
code[g_, a_] := N[(1.0 / N[(N[Power[N[(a * 2.0), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\sqrt[3]{a \cdot 2}}{\sqrt[3]{g}}}
\end{array}
Initial program 76.5%
cbrt-div98.7%
clear-num98.7%
Applied egg-rr98.7%
*-commutative98.7%
Simplified98.7%
Final simplification98.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 76.5%
pow1/337.1%
clear-num37.0%
associate-/r/37.1%
unpow-prod-down20.8%
pow1/342.2%
associate-/r*42.2%
metadata-eval42.2%
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 76.5%
clear-num76.2%
cbrt-div76.9%
metadata-eval76.9%
associate-/l*76.9%
Applied egg-rr76.9%
Final simplification76.9%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (* a (/ 2.0 g)))))
double code(double g, double a) {
return 1.0 / cbrt((a * (2.0 / g)));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt((a * (2.0 / g)));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(a * Float64(2.0 / g)))) end
code[g_, a_] := N[(1.0 / N[Power[N[(a * N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{a \cdot \frac{2}{g}}}
\end{array}
Initial program 76.5%
clear-num76.2%
cbrt-div76.9%
metadata-eval76.9%
associate-/l*76.9%
Applied egg-rr76.9%
associate-*r/76.9%
*-commutative76.9%
associate-/l*76.9%
Simplified76.9%
Final simplification76.9%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (/ (* a 2.0) g))))
double code(double g, double a) {
return 1.0 / cbrt(((a * 2.0) / g));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((a * 2.0) / g));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(a * 2.0) / g))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(a * 2.0), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{a \cdot 2}{g}}}
\end{array}
Initial program 76.5%
Taylor expanded in g around 0 76.4%
pow1/337.1%
div-inv37.1%
unpow-prod-down20.8%
pow1/343.9%
Applied egg-rr43.9%
unpow1/398.8%
Simplified98.8%
cbrt-div98.6%
metadata-eval98.6%
div-inv98.6%
*-commutative98.6%
cbrt-undiv76.4%
cbrt-unprod76.5%
metadata-eval76.5%
times-frac76.5%
*-un-lft-identity76.5%
*-commutative76.5%
cbrt-undiv98.7%
clear-num98.7%
cbrt-undiv76.9%
Applied egg-rr76.9%
Final simplification76.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 76.5%
add-log-exp9.1%
*-un-lft-identity9.1%
log-prod9.1%
metadata-eval9.1%
add-log-exp76.5%
div-inv76.5%
associate-/r*76.5%
metadata-eval76.5%
Applied egg-rr76.5%
+-lft-identity76.5%
Simplified76.5%
Final simplification76.5%
herbie shell --seed 2024073
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))