
(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 (* (/ 1.0 (cbrt (/ 2.0 g))) (cbrt (/ 1.0 a))))
double code(double g, double a) {
return (1.0 / cbrt((2.0 / g))) * cbrt((1.0 / a));
}
public static double code(double g, double a) {
return (1.0 / Math.cbrt((2.0 / g))) * Math.cbrt((1.0 / a));
}
function code(g, a) return Float64(Float64(1.0 / cbrt(Float64(2.0 / g))) * cbrt(Float64(1.0 / a))) end
code[g_, a_] := N[(N[(1.0 / N[Power[N[(2.0 / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{2}{g}}} \cdot \sqrt[3]{\frac{1}{a}}
\end{array}
Initial program 77.3%
pow1/338.1%
associate-/r*38.1%
div-inv38.1%
unpow-prod-down22.8%
pow1/346.4%
div-inv46.4%
metadata-eval46.4%
Applied egg-rr46.4%
*-commutative46.4%
unpow1/398.7%
Simplified98.7%
*-commutative98.7%
cbrt-prod98.7%
Applied egg-rr98.7%
cbrt-unprod98.7%
metadata-eval98.7%
div-inv98.7%
cbrt-undiv98.0%
clear-num98.0%
cbrt-undiv98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (* (cbrt (/ 1.0 a)) (cbrt (* g 0.5))))
double code(double g, double a) {
return cbrt((1.0 / a)) * cbrt((g * 0.5));
}
public static double code(double g, double a) {
return Math.cbrt((1.0 / a)) * Math.cbrt((g * 0.5));
}
function code(g, a) return Float64(cbrt(Float64(1.0 / a)) * cbrt(Float64(g * 0.5))) end
code[g_, a_] := N[(N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{1}{a}} \cdot \sqrt[3]{g \cdot 0.5}
\end{array}
Initial program 77.3%
pow1/338.1%
associate-/r*38.1%
div-inv38.1%
unpow-prod-down22.8%
pow1/346.4%
div-inv46.4%
metadata-eval46.4%
Applied egg-rr46.4%
*-commutative46.4%
unpow1/398.7%
Simplified98.7%
Final simplification98.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 77.3%
pow1/338.1%
clear-num37.3%
associate-/r/38.1%
unpow-prod-down22.8%
pow1/341.6%
associate-/r*41.6%
metadata-eval41.6%
pow1/398.7%
Applied egg-rr98.7%
Final simplification98.7%
(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 77.3%
associate-/r*77.3%
cbrt-div98.7%
div-inv98.7%
metadata-eval98.7%
Applied egg-rr98.7%
Final simplification98.7%
(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 77.3%
add-log-exp8.3%
*-un-lft-identity8.3%
log-prod8.3%
metadata-eval8.3%
add-log-exp77.3%
*-un-lft-identity77.3%
times-frac77.3%
metadata-eval77.3%
Applied egg-rr77.3%
+-lft-identity77.3%
associate-*r/77.3%
associate-/l*75.9%
associate-/r/77.2%
Simplified77.2%
Final simplification77.2%
(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}
Initial program 77.3%
Final simplification77.3%
herbie shell --seed 2024018
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))