
(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)) (/ -1.0 (/ -1.0 (cbrt g)))))
double code(double g, double a) {
return cbrt((0.5 / a)) * (-1.0 / (-1.0 / cbrt(g)));
}
public static double code(double g, double a) {
return Math.cbrt((0.5 / a)) * (-1.0 / (-1.0 / Math.cbrt(g)));
}
function code(g, a) return Float64(cbrt(Float64(0.5 / a)) * Float64(-1.0 / Float64(-1.0 / cbrt(g)))) end
code[g_, a_] := N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[(-1.0 / N[(-1.0 / N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a}} \cdot \frac{-1}{\frac{-1}{\sqrt[3]{g}}}
\end{array}
Initial program 74.3%
div-inv74.3%
cbrt-prod98.4%
associate-/r*98.8%
metadata-eval98.8%
Applied egg-rr98.8%
clear-num98.4%
cbrt-div98.2%
metadata-eval98.2%
div-inv98.2%
metadata-eval98.2%
div-inv98.3%
clear-num98.3%
*-commutative98.3%
div-inv98.2%
associate-/r*98.2%
*-commutative98.2%
metadata-eval98.2%
metadata-eval98.2%
div-inv98.2%
cbrt-div98.4%
clear-num98.7%
Applied egg-rr98.7%
frac-2neg98.7%
div-inv98.8%
distribute-neg-frac98.8%
metadata-eval98.8%
Applied egg-rr98.8%
Final simplification98.8%
(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 74.3%
div-inv74.3%
cbrt-prod98.4%
associate-/r*98.8%
metadata-eval98.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 74.3%
clear-num73.6%
cbrt-div74.9%
metadata-eval74.9%
*-un-lft-identity74.9%
times-frac75.2%
metadata-eval75.2%
Applied egg-rr75.2%
associate-*r/74.9%
*-commutative74.9%
Simplified74.9%
Final simplification74.9%
(FPCore (g a) :precision binary64 (cbrt (* 0.5 (/ g a))))
double code(double g, double a) {
return cbrt((0.5 * (g / a)));
}
public static double code(double g, double a) {
return Math.cbrt((0.5 * (g / a)));
}
function code(g, a) return cbrt(Float64(0.5 * Float64(g / a))) end
code[g_, a_] := N[Power[N[(0.5 * N[(g / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{0.5 \cdot \frac{g}{a}}
\end{array}
Initial program 74.3%
Taylor expanded in g around 0 74.7%
Final simplification74.7%
herbie shell --seed 2023193
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))