
(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 0.5) (cbrt a)) (cbrt g)))
double code(double g, double a) {
return (cbrt(0.5) / cbrt(a)) * cbrt(g);
}
public static double code(double g, double a) {
return (Math.cbrt(0.5) / Math.cbrt(a)) * Math.cbrt(g);
}
function code(g, a) return Float64(Float64(cbrt(0.5) / cbrt(a)) * cbrt(g)) end
code[g_, a_] := N[(N[(N[Power[0.5, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{0.5}}{\sqrt[3]{a}} \cdot \sqrt[3]{g}
\end{array}
Initial program 73.5%
pow1/332.5%
clear-num32.4%
associate-/r/32.5%
unpow-prod-down23.2%
pow1/347.5%
associate-/r*47.5%
metadata-eval47.5%
pow1/398.7%
Applied egg-rr98.7%
cbrt-div98.8%
div-inv98.6%
Applied egg-rr98.6%
associate-*r/98.8%
*-rgt-identity98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (* (/ 1.0 (cbrt a)) (cbrt (* 0.5 g))))
double code(double g, double a) {
return (1.0 / cbrt(a)) * cbrt((0.5 * g));
}
public static double code(double g, double a) {
return (1.0 / Math.cbrt(a)) * Math.cbrt((0.5 * g));
}
function code(g, a) return Float64(Float64(1.0 / cbrt(a)) * cbrt(Float64(0.5 * g))) end
code[g_, a_] := N[(N[(1.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{a}} \cdot \sqrt[3]{0.5 \cdot g}
\end{array}
Initial program 73.5%
add-log-exp8.7%
*-un-lft-identity8.7%
log-prod8.7%
metadata-eval8.7%
add-log-exp73.5%
*-un-lft-identity73.5%
times-frac73.5%
metadata-eval73.5%
Applied egg-rr73.5%
+-lft-identity73.5%
metadata-eval73.5%
times-frac73.5%
*-commutative73.5%
times-frac73.5%
rem-square-sqrt35.4%
associate-*r/35.4%
/-rgt-identity35.4%
rem-square-sqrt73.5%
Simplified73.5%
associate-*r/73.5%
*-commutative73.5%
cbrt-div98.7%
*-un-lft-identity98.7%
associate-*l/98.7%
*-commutative98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (* (cbrt 0.5) (cbrt (/ g a))))
double code(double g, double a) {
return cbrt(0.5) * cbrt((g / a));
}
public static double code(double g, double a) {
return Math.cbrt(0.5) * Math.cbrt((g / a));
}
function code(g, a) return Float64(cbrt(0.5) * cbrt(Float64(g / a))) end
code[g_, a_] := N[(N[Power[0.5, 1/3], $MachinePrecision] * N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{0.5} \cdot \sqrt[3]{\frac{g}{a}}
\end{array}
Initial program 73.5%
pow1/332.5%
*-un-lft-identity32.5%
times-frac32.5%
metadata-eval32.5%
unpow-prod-down32.5%
Applied egg-rr32.5%
unpow1/332.5%
unpow1/373.6%
Simplified73.6%
Final simplification73.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.5%
pow1/332.5%
clear-num32.4%
associate-/r/32.5%
unpow-prod-down23.2%
pow1/347.5%
associate-/r*47.5%
metadata-eval47.5%
pow1/398.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 73.5%
add-log-exp8.7%
*-un-lft-identity8.7%
log-prod8.7%
metadata-eval8.7%
add-log-exp73.5%
*-un-lft-identity73.5%
times-frac73.5%
metadata-eval73.5%
Applied egg-rr73.5%
+-lft-identity73.5%
metadata-eval73.5%
times-frac73.5%
*-commutative73.5%
times-frac73.5%
rem-square-sqrt35.4%
associate-*r/35.4%
/-rgt-identity35.4%
rem-square-sqrt73.5%
Simplified73.5%
Final simplification73.5%
(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 73.5%
Final simplification73.5%
herbie shell --seed 2024010
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))