
(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 a) (cbrt 0.5))))
double code(double g, double a) {
return cbrt(g) / (cbrt(a) / cbrt(0.5));
}
public static double code(double g, double a) {
return Math.cbrt(g) / (Math.cbrt(a) / Math.cbrt(0.5));
}
function code(g, a) return Float64(cbrt(g) / Float64(cbrt(a) / cbrt(0.5))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[(N[Power[a, 1/3], $MachinePrecision] / N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\frac{\sqrt[3]{a}}{\sqrt[3]{0.5}}}
\end{array}
Initial program 73.7%
clear-num72.6%
associate-/r/73.7%
associate-/r*74.1%
metadata-eval74.1%
Applied egg-rr74.1%
associate-*l/74.1%
*-commutative74.1%
cbrt-undiv98.6%
cbrt-prod98.7%
associate-/l*98.7%
Applied egg-rr98.7%
Final simplification98.7%
(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 73.7%
pow1/334.2%
*-un-lft-identity34.2%
times-frac34.6%
metadata-eval34.6%
unpow-prod-down34.6%
Applied egg-rr34.6%
unpow1/334.6%
unpow1/374.1%
Simplified74.1%
cbrt-div98.7%
div-inv98.7%
Applied egg-rr98.7%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (/ 1.0 (/ (cbrt a) (cbrt (* g 0.5)))))
double code(double g, double a) {
return 1.0 / (cbrt(a) / cbrt((g * 0.5)));
}
public static double code(double g, double a) {
return 1.0 / (Math.cbrt(a) / Math.cbrt((g * 0.5)));
}
function code(g, a) return Float64(1.0 / Float64(cbrt(a) / cbrt(Float64(g * 0.5)))) end
code[g_, a_] := N[(1.0 / N[(N[Power[a, 1/3], $MachinePrecision] / N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\sqrt[3]{a}}{\sqrt[3]{g \cdot 0.5}}}
\end{array}
Initial program 73.7%
clear-num72.6%
associate-/r/73.7%
associate-/r*74.1%
metadata-eval74.1%
Applied egg-rr74.1%
associate-*l/74.1%
*-commutative74.1%
cbrt-undiv98.6%
cbrt-prod98.7%
associate-/l*98.7%
Applied egg-rr98.7%
add-sqr-sqrt47.0%
div-inv46.9%
times-frac46.9%
pow1/344.7%
sqrt-pow144.7%
metadata-eval44.7%
pow1/344.0%
sqrt-pow144.0%
metadata-eval44.0%
Applied egg-rr44.0%
associate-/r/44.0%
/-rgt-identity44.0%
associate-*r*44.0%
associate-*l/44.0%
pow-sqr44.0%
metadata-eval44.0%
unpow1/398.7%
Simplified98.7%
associate-*l/98.7%
clear-num98.6%
cbrt-unprod98.6%
Applied egg-rr98.6%
Final simplification98.6%
(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 73.7%
clear-num72.6%
associate-/r/73.7%
cbrt-prod98.2%
associate-/r*98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Final simplification98.6%
(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 73.7%
associate-/r*74.1%
cbrt-div98.6%
div-inv98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Final simplification98.6%
(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.7%
clear-num72.6%
associate-/r/73.7%
associate-/r*74.1%
metadata-eval74.1%
Applied egg-rr74.1%
Final simplification74.1%
herbie shell --seed 2024026
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))