
(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)) (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.9%
pow1/338.1%
clear-num37.5%
associate-/r/38.1%
unpow-prod-down23.6%
pow1/345.6%
associate-/r*45.6%
metadata-eval45.6%
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 77.9%
clear-num77.3%
cbrt-div78.2%
metadata-eval78.2%
associate-/l*77.2%
Applied egg-rr77.2%
associate-/l*78.2%
*-commutative78.2%
Simplified78.2%
Final simplification78.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(Float64(0.5 / a) * g)) end
code[g_, a_] := N[Power[N[(N[(0.5 / a), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot g}
\end{array}
Initial program 77.9%
add-log-exp9.9%
*-un-lft-identity9.9%
log-prod9.9%
metadata-eval9.9%
add-log-exp77.9%
*-un-lft-identity77.9%
times-frac77.9%
metadata-eval77.9%
Applied egg-rr77.9%
+-lft-identity77.9%
metadata-eval77.9%
times-frac77.9%
*-commutative77.9%
times-frac77.8%
rem-square-sqrt40.3%
associate-*r/40.3%
/-rgt-identity40.3%
rem-square-sqrt77.8%
Simplified77.8%
Final simplification77.8%
(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 77.9%
Final simplification77.9%
herbie shell --seed 2023298
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))