
(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 4 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 a)) (/ 1.0 (cbrt g))))
double code(double g, double a) {
return cbrt((0.5 / a)) / (1.0 / cbrt(g));
}
public static double code(double g, double a) {
return Math.cbrt((0.5 / a)) / (1.0 / Math.cbrt(g));
}
function code(g, a) return Float64(cbrt(Float64(0.5 / a)) / Float64(1.0 / cbrt(g))) end
code[g_, a_] := N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] / N[(1.0 / N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{\frac{0.5}{a}}}{\frac{1}{\sqrt[3]{g}}}
\end{array}
Initial program 71.0%
pow1/335.5%
clear-num35.2%
associate-/r/35.5%
unpow-prod-down23.3%
pow1/351.1%
associate-/r*51.1%
metadata-eval51.1%
pow1/398.7%
Applied egg-rr98.7%
cbrt-prod70.9%
associate-*l/71.0%
*-commutative71.0%
/-rgt-identity71.0%
*-commutative71.0%
associate-*l/70.9%
cbrt-prod98.7%
associate-/l*98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (* (cbrt (* 0.5 g)) (cbrt (/ 1.0 a))))
double code(double g, double a) {
return cbrt((0.5 * g)) * cbrt((1.0 / a));
}
public static double code(double g, double a) {
return Math.cbrt((0.5 * g)) * Math.cbrt((1.0 / a));
}
function code(g, a) return Float64(cbrt(Float64(0.5 * g)) * cbrt(Float64(1.0 / a))) end
code[g_, a_] := N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{0.5 \cdot g} \cdot \sqrt[3]{\frac{1}{a}}
\end{array}
Initial program 71.0%
pow1/335.5%
associate-/r*35.5%
div-inv35.5%
unpow-prod-down23.3%
pow1/341.4%
div-inv41.4%
metadata-eval41.4%
Applied egg-rr41.4%
*-commutative41.4%
unpow1/398.8%
Simplified98.8%
Final simplification98.8%
(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 71.0%
pow1/335.5%
clear-num35.2%
associate-/r/35.5%
unpow-prod-down23.3%
pow1/351.1%
associate-/r*51.1%
metadata-eval51.1%
pow1/398.7%
Applied egg-rr98.7%
Final simplification98.7%
(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 71.0%
add-log-exp7.5%
*-un-lft-identity7.5%
log-prod7.5%
metadata-eval7.5%
add-log-exp71.0%
*-un-lft-identity71.0%
times-frac71.0%
metadata-eval71.0%
Applied egg-rr71.0%
+-lft-identity71.0%
Simplified71.0%
Final simplification71.0%
herbie shell --seed 2024035
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))