
(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 5 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 0.5) (/ (cbrt g) (cbrt a))))
double code(double g, double a) {
return cbrt(0.5) * (cbrt(g) / cbrt(a));
}
public static double code(double g, double a) {
return Math.cbrt(0.5) * (Math.cbrt(g) / Math.cbrt(a));
}
function code(g, a) return Float64(cbrt(0.5) * Float64(cbrt(g) / cbrt(a))) end
code[g_, a_] := N[(N[Power[0.5, 1/3], $MachinePrecision] * N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{0.5} \cdot \frac{\sqrt[3]{g}}{\sqrt[3]{a}}
\end{array}
Initial program 74.8%
associate-/r*75.1%
cbrt-div98.8%
div-inv98.8%
metadata-eval98.8%
Applied egg-rr98.8%
clear-num98.7%
inv-pow98.7%
div-inv98.7%
metadata-eval98.7%
metadata-eval98.7%
div-inv98.7%
cbrt-div98.7%
clear-num98.7%
unpow-prod-down98.7%
inv-pow98.7%
Applied egg-rr98.7%
unpow-198.7%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
cbrt-div98.1%
associate-/r/98.1%
associate-/r*98.1%
cbrt-prod98.4%
associate-/r/98.4%
clear-num98.4%
cbrt-undiv74.8%
*-commutative74.8%
*-un-lft-identity74.8%
times-frac75.1%
metadata-eval75.1%
clear-num74.4%
div-inv74.4%
cbrt-div74.8%
cbrt-div98.8%
associate-/r/98.7%
Applied egg-rr98.7%
associate-*l/98.8%
associate-/l*98.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 74.8%
pow1/337.2%
clear-num36.8%
associate-/r/37.2%
unpow-prod-down27.6%
pow1/347.9%
associate-/r*48.3%
metadata-eval48.3%
pow1/398.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (/ (cbrt (* 0.5 g)) (cbrt a)))
double code(double g, double a) {
return cbrt((0.5 * g)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 * g)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(0.5 * g)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{0.5 \cdot g}}{\sqrt[3]{a}}
\end{array}
Initial program 74.8%
associate-/r*75.1%
cbrt-div98.8%
div-inv98.8%
metadata-eval98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (cbrt (/ (/ 1.0 a) (/ 2.0 g))))
double code(double g, double a) {
return cbrt(((1.0 / a) / (2.0 / g)));
}
public static double code(double g, double a) {
return Math.cbrt(((1.0 / a) / (2.0 / g)));
}
function code(g, a) return cbrt(Float64(Float64(1.0 / a) / Float64(2.0 / g))) end
code[g_, a_] := N[Power[N[(N[(1.0 / a), $MachinePrecision] / N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{\frac{1}{a}}{\frac{2}{g}}}
\end{array}
Initial program 74.8%
associate-/r*75.1%
cbrt-div98.8%
div-inv98.8%
metadata-eval98.8%
Applied egg-rr98.8%
clear-num98.7%
inv-pow98.7%
div-inv98.7%
metadata-eval98.7%
metadata-eval98.7%
div-inv98.7%
cbrt-div98.7%
clear-num98.7%
unpow-prod-down98.7%
inv-pow98.7%
Applied egg-rr98.7%
unpow-198.7%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
add-cbrt-cube98.4%
cbrt-undiv74.8%
un-div-inv74.8%
frac-times74.8%
metadata-eval74.8%
associate-/r*74.8%
add-cube-cbrt75.1%
Applied egg-rr75.1%
Final simplification75.1%
(FPCore (g a) :precision binary64 (cbrt (* 0.5 (/ g a))))
double code(double g, double a) {
return cbrt((0.5 * (g / a)));
}
public static double code(double g, double a) {
return Math.cbrt((0.5 * (g / a)));
}
function code(g, a) return cbrt(Float64(0.5 * Float64(g / a))) end
code[g_, a_] := N[Power[N[(0.5 * N[(g / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{0.5 \cdot \frac{g}{a}}
\end{array}
Initial program 74.8%
Taylor expanded in g around 0 75.1%
Final simplification75.1%
herbie shell --seed 2024040
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))