
(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 6 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 0.5)) (cbrt (/ 1.0 a))))
double code(double g, double a) {
return (cbrt(g) * cbrt(0.5)) * cbrt((1.0 / a));
}
public static double code(double g, double a) {
return (Math.cbrt(g) * Math.cbrt(0.5)) * Math.cbrt((1.0 / a));
}
function code(g, a) return Float64(Float64(cbrt(g) * cbrt(0.5)) * cbrt(Float64(1.0 / a))) end
code[g_, a_] := N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt[3]{g} \cdot \sqrt[3]{0.5}\right) \cdot \sqrt[3]{\frac{1}{a}}
\end{array}
Initial program 80.0%
pow1/335.1%
associate-/r*35.1%
div-inv35.1%
unpow-prod-down21.1%
pow1/344.6%
div-inv44.6%
metadata-eval44.6%
Applied egg-rr44.6%
*-commutative44.6%
unpow1/398.7%
Simplified98.7%
*-commutative98.7%
cbrt-prod98.9%
Applied egg-rr98.9%
Final simplification98.9%
(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 80.0%
cbrt-div98.7%
clear-num98.8%
Applied egg-rr98.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 80.0%
pow1/335.1%
clear-num34.7%
associate-/r/35.1%
unpow-prod-down21.1%
pow1/346.2%
associate-/r*46.2%
metadata-eval46.2%
pow1/398.8%
Applied egg-rr98.8%
Final simplification98.8%
(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.0%
clear-num79.4%
cbrt-div80.0%
metadata-eval80.0%
associate-/l*79.4%
Applied egg-rr79.4%
associate-/l*80.0%
*-commutative80.0%
Simplified80.0%
Final simplification80.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 80.0%
add-log-exp10.2%
*-un-lft-identity10.2%
log-prod10.2%
metadata-eval10.2%
add-log-exp80.0%
*-un-lft-identity80.0%
times-frac80.0%
metadata-eval80.0%
Applied egg-rr80.0%
+-lft-identity80.0%
metadata-eval80.0%
times-frac80.0%
*-commutative80.0%
times-frac80.0%
rem-square-sqrt38.9%
associate-*r/38.9%
/-rgt-identity38.9%
rem-square-sqrt80.0%
Simplified80.0%
Final simplification80.0%
(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 80.0%
Final simplification80.0%
herbie shell --seed 2023333
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))