
(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 0.5)) (cbrt a)))
double code(double g, double a) {
return cbrt((g * 0.5)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((g * 0.5)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(g * 0.5)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g \cdot 0.5}}{\sqrt[3]{a}}
\end{array}
Initial program 80.2%
associate-/r*80.2%
cbrt-div98.7%
div-inv98.7%
metadata-eval98.7%
Applied egg-rr98.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 80.2%
pow1/335.8%
clear-num35.8%
associate-/r/35.8%
unpow-prod-down20.9%
pow1/344.8%
associate-/r*44.8%
metadata-eval44.8%
pow1/398.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (* a 2.0))))
double code(double g, double a) {
return cbrt(g) / cbrt((a * 2.0));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((a * 2.0));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(a * 2.0))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a * 2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{a \cdot 2}}
\end{array}
Initial program 80.2%
cbrt-div98.7%
clear-num98.7%
Applied egg-rr98.7%
associate-/l*98.7%
*-lft-identity98.7%
*-commutative98.7%
Simplified98.7%
Final simplification98.7%
(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 80.2%
clear-num80.3%
cbrt-div81.4%
metadata-eval81.4%
associate-/l*80.2%
Applied egg-rr80.2%
associate-/r/81.4%
Simplified81.4%
Final simplification81.4%
(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 80.2%
clear-num80.3%
cbrt-div81.4%
metadata-eval81.4%
associate-/l*80.2%
Applied egg-rr80.2%
associate-/l*81.4%
*-commutative81.4%
Simplified81.4%
Final simplification81.4%
(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 80.2%
add-log-exp7.8%
*-un-lft-identity7.8%
log-prod7.8%
metadata-eval7.8%
add-log-exp80.2%
*-un-lft-identity80.2%
times-frac80.2%
metadata-eval80.2%
Applied egg-rr80.2%
+-lft-identity80.2%
metadata-eval80.2%
times-frac80.2%
*-commutative80.2%
times-frac80.2%
rem-square-sqrt37.2%
associate-*r/37.2%
/-rgt-identity37.2%
rem-square-sqrt80.2%
Simplified80.2%
Final simplification80.2%
(FPCore (g a) :precision binary64 (cbrt (/ 0.5 (/ a g))))
double code(double g, double a) {
return cbrt((0.5 / (a / g)));
}
public static double code(double g, double a) {
return Math.cbrt((0.5 / (a / g)));
}
function code(g, a) return cbrt(Float64(0.5 / Float64(a / g))) end
code[g_, a_] := N[Power[N[(0.5 / N[(a / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{\frac{a}{g}}}
\end{array}
Initial program 80.2%
add-log-exp7.8%
*-un-lft-identity7.8%
log-prod7.8%
metadata-eval7.8%
add-log-exp80.2%
*-un-lft-identity80.2%
times-frac80.2%
metadata-eval80.2%
Applied egg-rr80.2%
+-lft-identity80.2%
associate-*r/80.2%
associate-/l*80.3%
Simplified80.3%
Final simplification80.3%
herbie shell --seed 2024012
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))