
(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 (* g 0.5)) (cbrt (/ 1.0 a))))
double code(double g, double a) {
return cbrt((g * 0.5)) * cbrt((1.0 / a));
}
public static double code(double g, double a) {
return Math.cbrt((g * 0.5)) * Math.cbrt((1.0 / a));
}
function code(g, a) return Float64(cbrt(Float64(g * 0.5)) * cbrt(Float64(1.0 / a))) end
code[g_, a_] := N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g \cdot 0.5} \cdot \sqrt[3]{\frac{1}{a}}
\end{array}
Initial program 73.0%
pow1/333.0%
associate-/r*33.0%
div-inv33.0%
unpow-prod-down22.9%
pow1/347.6%
div-inv47.6%
metadata-eval47.6%
Applied egg-rr47.6%
unpow1/398.7%
Simplified98.7%
(FPCore (g a) :precision binary64 (* (cbrt (/ 0.5 a)) (cbrt g)))
double code(double g, double a) {
return cbrt((0.5 / a)) * cbrt(g);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 / a)) * Math.cbrt(g);
}
function code(g, a) return Float64(cbrt(Float64(0.5 / a)) * cbrt(g)) end
code[g_, a_] := N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g}
\end{array}
Initial program 73.0%
pow1/333.0%
clear-num32.8%
associate-/r/33.0%
unpow-prod-down22.9%
pow1/345.8%
associate-/r*45.8%
metadata-eval45.8%
pow1/398.7%
Applied egg-rr98.7%
(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 73.0%
Final simplification73.0%
(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.0%
clear-num71.3%
associate-/r/73.0%
associate-/r*73.0%
metadata-eval73.0%
Applied egg-rr73.0%
Final simplification73.0%
(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 \left(g \cdot a\right)}
\end{array}
Initial program 73.0%
clear-num71.3%
associate-/r/73.0%
associate-/r*73.0%
metadata-eval73.0%
Applied egg-rr73.0%
associate-*l/73.0%
*-commutative73.0%
div-inv73.0%
cbrt-unprod98.7%
*-commutative98.7%
cbrt-prod98.6%
associate-*r*98.6%
cbrt-div98.6%
metadata-eval98.6%
Applied egg-rr98.6%
*-commutative98.6%
associate-*l/98.7%
*-lft-identity98.7%
Simplified98.7%
*-commutative98.7%
cbrt-undiv73.0%
cbrt-unprod73.0%
div-inv73.0%
add-exp-log34.9%
neg-log34.9%
add-sqr-sqrt13.7%
sqrt-unprod15.6%
sqr-neg15.6%
sqrt-unprod1.7%
add-sqr-sqrt3.2%
add-exp-log5.8%
Applied egg-rr5.8%
Final simplification5.8%
herbie shell --seed 2024132
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))