
(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 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 78.6%
clear-num77.3%
cbrt-div78.0%
metadata-eval78.0%
associate-/l*77.1%
Applied egg-rr77.1%
associate-/r/78.0%
cbrt-prod98.6%
Applied egg-rr98.6%
clear-num98.6%
cbrt-div98.7%
metadata-eval98.7%
div-inv98.7%
metadata-eval98.7%
associate-/r/98.6%
clear-num98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (* (cbrt (* g 0.5)) (cbrt (/ 1.0 a))))
double code(double g, double a) {
return cbrt((g * 0.5)) * cbrt((1.0 / a));
}
public static double code(double g, double a) {
return Math.cbrt((g * 0.5)) * Math.cbrt((1.0 / a));
}
function code(g, a) return Float64(cbrt(Float64(g * 0.5)) * cbrt(Float64(1.0 / a))) end
code[g_, a_] := N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g \cdot 0.5} \cdot \sqrt[3]{\frac{1}{a}}
\end{array}
Initial program 78.6%
pow1/332.5%
associate-/r*32.5%
div-inv32.5%
unpow-prod-down22.6%
pow1/349.7%
div-inv49.7%
metadata-eval49.7%
Applied egg-rr49.7%
*-commutative49.7%
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 78.6%
pow1/332.5%
clear-num31.8%
associate-/r/32.5%
unpow-prod-down22.6%
pow1/346.1%
associate-/r*46.1%
metadata-eval46.1%
pow1/398.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 78.6%
associate-/r*78.6%
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 78.6%
add-log-exp10.7%
*-un-lft-identity10.7%
log-prod10.7%
metadata-eval10.7%
add-log-exp78.6%
*-un-lft-identity78.6%
times-frac78.6%
metadata-eval78.6%
Applied egg-rr78.6%
+-lft-identity78.6%
metadata-eval78.6%
times-frac78.6%
*-commutative78.6%
times-frac78.6%
rem-square-sqrt39.5%
associate-*r/39.5%
/-rgt-identity39.5%
rem-square-sqrt78.6%
Simplified78.6%
Final simplification78.6%
(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 78.6%
Final simplification78.6%
herbie shell --seed 2023325
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))