
(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 9 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 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 74.4%
div-inv74.4%
cbrt-prod98.8%
associate-/r*98.8%
metadata-eval98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (* 2.0 (/ a g)))))
double code(double g, double a) {
return 1.0 / cbrt((2.0 * (a / g)));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt((2.0 * (a / g)));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(2.0 * Float64(a / g)))) end
code[g_, a_] := N[(1.0 / N[Power[N[(2.0 * N[(a / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{2 \cdot \frac{a}{g}}}
\end{array}
Initial program 74.4%
clear-num73.9%
cbrt-div74.9%
metadata-eval74.9%
*-un-lft-identity74.9%
times-frac74.8%
metadata-eval74.8%
Applied egg-rr74.8%
Final simplification74.8%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (/ (+ a a) g))))
double code(double g, double a) {
return 1.0 / cbrt(((a + a) / g));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((a + a) / g));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(a + a) / g))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(a + a), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{a + a}{g}}}
\end{array}
Initial program 74.4%
clear-num73.9%
cbrt-div74.9%
metadata-eval74.9%
*-un-lft-identity74.9%
times-frac74.8%
metadata-eval74.8%
Applied egg-rr74.8%
associate-*r/74.9%
*-commutative74.9%
add-log-exp5.3%
exp-lft-sqr5.2%
log-prod5.2%
add-log-exp12.8%
add-log-exp74.9%
Applied egg-rr74.9%
Final simplification74.9%
(FPCore (g a) :precision binary64 (if (<= a -5e-310) (cbrt (/ g -8.0)) (cbrt g)))
double code(double g, double a) {
double tmp;
if (a <= -5e-310) {
tmp = cbrt((g / -8.0));
} else {
tmp = cbrt(g);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if (a <= -5e-310) {
tmp = Math.cbrt((g / -8.0));
} else {
tmp = Math.cbrt(g);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (a <= -5e-310) tmp = cbrt(Float64(g / -8.0)); else tmp = cbrt(g); end return tmp end
code[g_, a_] := If[LessEqual[a, -5e-310], N[Power[N[(g / -8.0), $MachinePrecision], 1/3], $MachinePrecision], N[Power[g, 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt[3]{\frac{g}{-8}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g}\\
\end{array}
\end{array}
if a < -4.999999999999985e-310Initial program 76.3%
expm1-log1p-u57.0%
expm1-udef26.0%
log1p-udef26.0%
add-exp-log45.3%
*-un-lft-identity45.3%
times-frac45.3%
metadata-eval45.3%
Applied egg-rr45.3%
+-commutative45.3%
associate--l+76.3%
metadata-eval76.3%
+-rgt-identity76.3%
associate-*r/76.3%
associate-*l/76.3%
Simplified76.3%
*-commutative76.3%
clear-num76.3%
div-inv76.3%
metadata-eval76.3%
div-inv76.3%
associate-/r*76.3%
div-inv76.3%
associate-/l*76.3%
Applied egg-rr76.3%
Applied egg-rr7.8%
if -4.999999999999985e-310 < a Initial program 72.7%
clear-num72.4%
cbrt-div74.0%
metadata-eval74.0%
*-un-lft-identity74.0%
times-frac73.9%
metadata-eval73.9%
Applied egg-rr73.9%
associate-*r/74.0%
*-commutative74.0%
cbrt-div98.8%
div-inv98.8%
metadata-eval98.8%
div-inv98.8%
add-log-exp7.1%
div-inv7.1%
metadata-eval7.1%
exp-lft-sqr7.0%
log-prod7.0%
add-log-exp16.9%
add-log-exp98.8%
Applied egg-rr98.8%
associate-*r/98.8%
*-rgt-identity98.8%
Simplified98.8%
Applied egg-rr2.8%
Simplified8.0%
Final simplification7.9%
(FPCore (g a) :precision binary64 (if (<= a -5e-310) (cbrt (/ g -8.0)) (cbrt (/ g 0.001953125))))
double code(double g, double a) {
double tmp;
if (a <= -5e-310) {
tmp = cbrt((g / -8.0));
} else {
tmp = cbrt((g / 0.001953125));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if (a <= -5e-310) {
tmp = Math.cbrt((g / -8.0));
} else {
tmp = Math.cbrt((g / 0.001953125));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (a <= -5e-310) tmp = cbrt(Float64(g / -8.0)); else tmp = cbrt(Float64(g / 0.001953125)); end return tmp end
code[g_, a_] := If[LessEqual[a, -5e-310], N[Power[N[(g / -8.0), $MachinePrecision], 1/3], $MachinePrecision], N[Power[N[(g / 0.001953125), $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt[3]{\frac{g}{-8}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{g}{0.001953125}}\\
\end{array}
\end{array}
if a < -4.999999999999985e-310Initial program 76.3%
expm1-log1p-u57.0%
expm1-udef26.0%
log1p-udef26.0%
add-exp-log45.3%
*-un-lft-identity45.3%
times-frac45.3%
metadata-eval45.3%
Applied egg-rr45.3%
+-commutative45.3%
associate--l+76.3%
metadata-eval76.3%
+-rgt-identity76.3%
associate-*r/76.3%
associate-*l/76.3%
Simplified76.3%
*-commutative76.3%
clear-num76.3%
div-inv76.3%
metadata-eval76.3%
div-inv76.3%
associate-/r*76.3%
div-inv76.3%
associate-/l*76.3%
Applied egg-rr76.3%
Applied egg-rr7.8%
if -4.999999999999985e-310 < a Initial program 72.7%
expm1-log1p-u53.5%
expm1-udef22.5%
log1p-udef22.5%
add-exp-log41.7%
*-un-lft-identity41.7%
times-frac41.7%
metadata-eval41.7%
Applied egg-rr41.7%
+-commutative41.7%
associate--l+72.7%
metadata-eval72.7%
+-rgt-identity72.7%
associate-*r/72.7%
associate-*l/72.6%
Simplified72.6%
*-commutative72.6%
clear-num72.6%
div-inv72.6%
metadata-eval72.6%
div-inv72.7%
associate-/r*72.7%
div-inv72.6%
associate-/l*72.6%
Applied egg-rr72.6%
Applied egg-rr8.1%
Final simplification8.0%
(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 74.4%
expm1-log1p-u55.1%
expm1-udef24.1%
log1p-udef24.1%
add-exp-log43.4%
*-un-lft-identity43.4%
times-frac43.4%
metadata-eval43.4%
Applied egg-rr43.4%
+-commutative43.4%
associate--l+74.4%
metadata-eval74.4%
+-rgt-identity74.4%
associate-*r/74.4%
associate-*l/74.4%
Simplified74.4%
Final simplification74.4%
(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 74.4%
Final simplification74.4%
(FPCore (g a) :precision binary64 (if (<= a -5e-310) (- (cbrt g)) (cbrt g)))
double code(double g, double a) {
double tmp;
if (a <= -5e-310) {
tmp = -cbrt(g);
} else {
tmp = cbrt(g);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if (a <= -5e-310) {
tmp = -Math.cbrt(g);
} else {
tmp = Math.cbrt(g);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (a <= -5e-310) tmp = Float64(-cbrt(g)); else tmp = cbrt(g); end return tmp end
code[g_, a_] := If[LessEqual[a, -5e-310], (-N[Power[g, 1/3], $MachinePrecision]), N[Power[g, 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-\sqrt[3]{g}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g}\\
\end{array}
\end{array}
if a < -4.999999999999985e-310Initial program 76.3%
clear-num75.6%
cbrt-div75.9%
metadata-eval75.9%
*-un-lft-identity75.9%
times-frac75.9%
metadata-eval75.9%
Applied egg-rr75.9%
associate-*r/75.9%
*-commutative75.9%
cbrt-div98.7%
div-inv98.6%
metadata-eval98.6%
div-inv98.6%
add-log-exp3.2%
div-inv3.2%
metadata-eval3.2%
exp-lft-sqr3.2%
log-prod3.2%
add-log-exp11.7%
add-log-exp98.6%
Applied egg-rr98.6%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
Applied egg-rr1.6%
Simplified7.8%
if -4.999999999999985e-310 < a Initial program 72.7%
clear-num72.4%
cbrt-div74.0%
metadata-eval74.0%
*-un-lft-identity74.0%
times-frac73.9%
metadata-eval73.9%
Applied egg-rr73.9%
associate-*r/74.0%
*-commutative74.0%
cbrt-div98.8%
div-inv98.8%
metadata-eval98.8%
div-inv98.8%
add-log-exp7.1%
div-inv7.1%
metadata-eval7.1%
exp-lft-sqr7.0%
log-prod7.0%
add-log-exp16.9%
add-log-exp98.8%
Applied egg-rr98.8%
associate-*r/98.8%
*-rgt-identity98.8%
Simplified98.8%
Applied egg-rr2.8%
Simplified8.0%
Final simplification7.9%
(FPCore (g a) :precision binary64 (cbrt g))
double code(double g, double a) {
return cbrt(g);
}
public static double code(double g, double a) {
return Math.cbrt(g);
}
function code(g, a) return cbrt(g) end
code[g_, a_] := N[Power[g, 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g}
\end{array}
Initial program 74.4%
clear-num73.9%
cbrt-div74.9%
metadata-eval74.9%
*-un-lft-identity74.9%
times-frac74.8%
metadata-eval74.8%
Applied egg-rr74.8%
associate-*r/74.9%
*-commutative74.9%
cbrt-div98.8%
div-inv98.7%
metadata-eval98.7%
div-inv98.7%
add-log-exp5.3%
div-inv5.3%
metadata-eval5.3%
exp-lft-sqr5.2%
log-prod5.2%
add-log-exp14.4%
add-log-exp98.7%
Applied egg-rr98.7%
associate-*r/98.8%
*-rgt-identity98.8%
Simplified98.8%
Applied egg-rr2.7%
Simplified5.0%
Final simplification5.0%
herbie shell --seed 2023279
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))