
(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) (cbrt (/ 1.0 a)))))
double code(double g, double a) {
return cbrt(g) * (cbrt(0.5) * cbrt((1.0 / a)));
}
public static double code(double g, double a) {
return Math.cbrt(g) * (Math.cbrt(0.5) * Math.cbrt((1.0 / a)));
}
function code(g, a) return Float64(cbrt(g) * Float64(cbrt(0.5) * cbrt(Float64(1.0 / a)))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] * N[(N[Power[0.5, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g} \cdot \left(\sqrt[3]{0.5} \cdot \sqrt[3]{\frac{1}{a}}\right)
\end{array}
Initial program 71.3%
div-inv71.3%
cbrt-prod98.8%
associate-/r*98.8%
metadata-eval98.8%
Applied egg-rr98.8%
div-inv98.8%
cbrt-prod98.8%
Applied egg-rr98.8%
Final simplification98.8%
(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 71.3%
div-inv71.3%
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 (* 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(a * Float64(2.0 / g)))) end
code[g_, a_] := N[(1.0 / N[Power[N[(a * N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{a \cdot \frac{2}{g}}}
\end{array}
Initial program 71.3%
clear-num70.6%
cbrt-div72.8%
metadata-eval72.8%
*-un-lft-identity72.8%
times-frac72.7%
metadata-eval72.7%
Applied egg-rr72.7%
associate-*r/72.8%
associate-*l/72.8%
Simplified72.8%
Final simplification72.8%
(FPCore (g a) :precision binary64 (if (<= a -4e-310) (cbrt (/ g -2.0)) (cbrt g)))
double code(double g, double a) {
double tmp;
if (a <= -4e-310) {
tmp = cbrt((g / -2.0));
} else {
tmp = cbrt(g);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if (a <= -4e-310) {
tmp = Math.cbrt((g / -2.0));
} else {
tmp = Math.cbrt(g);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (a <= -4e-310) tmp = cbrt(Float64(g / -2.0)); else tmp = cbrt(g); end return tmp end
code[g_, a_] := If[LessEqual[a, -4e-310], N[Power[N[(g / -2.0), $MachinePrecision], 1/3], $MachinePrecision], N[Power[g, 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\sqrt[3]{\frac{g}{-2}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g}\\
\end{array}
\end{array}
if a < -3.999999999999988e-310Initial program 61.4%
clear-num60.1%
cbrt-div61.8%
metadata-eval61.8%
*-un-lft-identity61.8%
times-frac61.7%
metadata-eval61.7%
Applied egg-rr61.7%
associate-*r/61.8%
associate-*l/61.9%
Simplified61.9%
associate-*l/61.8%
*-commutative61.8%
cbrt-div98.7%
div-inv98.6%
metadata-eval98.6%
div-inv98.6%
add-log-exp2.6%
div-inv2.6%
metadata-eval2.6%
exp-lft-sqr2.6%
log-prod2.6%
add-log-exp12.4%
add-log-exp98.6%
Applied egg-rr98.6%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
clear-num98.7%
cbrt-undiv61.4%
Applied egg-rr61.4%
Simplified7.4%
if -3.999999999999988e-310 < a Initial program 81.8%
expm1-log1p-u55.7%
expm1-udef26.4%
log1p-udef26.4%
add-exp-log52.5%
*-un-lft-identity52.5%
times-frac52.5%
metadata-eval52.5%
Applied egg-rr52.5%
+-commutative52.5%
associate--l+81.8%
metadata-eval81.8%
+-rgt-identity81.8%
associate-*r/81.8%
associate-*l/81.7%
Simplified81.7%
associate-*l/81.8%
associate-/l*81.7%
Applied egg-rr81.7%
associate-/r/81.7%
*-commutative81.7%
cbrt-unprod98.8%
/-rgt-identity98.8%
associate-/r/98.7%
frac-2neg98.7%
div-inv98.7%
add-cube-cbrt97.7%
add-cube-cbrt98.7%
div-inv98.7%
cbrt-unprod98.8%
cbrt-unprod98.7%
div-inv98.7%
clear-num98.7%
cbrt-div98.8%
metadata-eval98.8%
div-inv98.8%
metadata-eval98.8%
*-commutative98.8%
count-298.8%
flip-+0.0%
Applied egg-rr4.8%
Simplified8.0%
Final simplification7.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 71.3%
expm1-log1p-u52.7%
expm1-udef23.8%
log1p-udef23.8%
add-exp-log42.4%
*-un-lft-identity42.4%
times-frac42.4%
metadata-eval42.4%
Applied egg-rr42.4%
+-commutative42.4%
associate--l+71.3%
metadata-eval71.3%
+-rgt-identity71.3%
associate-*r/71.3%
associate-*l/71.3%
Simplified71.3%
Final simplification71.3%
(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 71.3%
Final simplification71.3%
(FPCore (g a) :precision binary64 (cbrt (/ g a)))
double code(double g, double a) {
return cbrt((g / a));
}
public static double code(double g, double a) {
return Math.cbrt((g / a));
}
function code(g, a) return cbrt(Float64(g / a)) end
code[g_, a_] := N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{a}}
\end{array}
Initial program 71.3%
clear-num70.6%
cbrt-div72.8%
metadata-eval72.8%
*-un-lft-identity72.8%
times-frac72.7%
metadata-eval72.7%
Applied egg-rr72.7%
associate-*r/72.8%
associate-*l/72.8%
Simplified72.8%
associate-*l/72.8%
*-commutative72.8%
cbrt-div98.7%
div-inv98.7%
metadata-eval98.7%
div-inv98.7%
add-log-exp4.0%
div-inv4.0%
metadata-eval4.0%
exp-lft-sqr3.9%
log-prod3.9%
add-log-exp13.5%
add-log-exp98.7%
Applied egg-rr98.7%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
clear-num98.8%
count-298.8%
cbrt-prod98.3%
*-commutative98.3%
associate-/l/98.3%
cbrt-undiv98.7%
cbrt-undiv71.3%
div-inv71.3%
metadata-eval71.3%
Applied egg-rr71.3%
Simplified16.3%
Final simplification16.3%
(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 71.3%
expm1-log1p-u52.7%
expm1-udef23.8%
log1p-udef23.8%
add-exp-log42.4%
*-un-lft-identity42.4%
times-frac42.4%
metadata-eval42.4%
Applied egg-rr42.4%
+-commutative42.4%
associate--l+71.3%
metadata-eval71.3%
+-rgt-identity71.3%
associate-*r/71.3%
associate-*l/71.3%
Simplified71.3%
associate-*l/71.3%
associate-/l*70.6%
Applied egg-rr70.6%
associate-/r/71.3%
*-commutative71.3%
cbrt-unprod98.8%
/-rgt-identity98.8%
associate-/r/98.7%
frac-2neg98.7%
div-inv98.8%
add-cube-cbrt97.8%
add-cube-cbrt98.8%
div-inv98.8%
cbrt-unprod98.8%
cbrt-unprod98.8%
div-inv98.8%
clear-num98.8%
cbrt-div98.8%
metadata-eval98.8%
div-inv98.8%
metadata-eval98.8%
*-commutative98.8%
count-298.8%
flip-+0.0%
Applied egg-rr4.6%
Simplified4.7%
Final simplification4.7%
(FPCore (g a) :precision binary64 -2.0)
double code(double g, double a) {
return -2.0;
}
real(8) function code(g, a)
real(8), intent (in) :: g
real(8), intent (in) :: a
code = -2.0d0
end function
public static double code(double g, double a) {
return -2.0;
}
def code(g, a): return -2.0
function code(g, a) return -2.0 end
function tmp = code(g, a) tmp = -2.0; end
code[g_, a_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 71.3%
div-inv71.3%
cbrt-prod98.8%
associate-/r*98.8%
metadata-eval98.8%
Applied egg-rr98.8%
div-inv98.8%
cbrt-prod98.8%
Applied egg-rr98.8%
cbrt-unprod98.8%
div-inv98.8%
/-rgt-identity98.8%
associate-/r/98.7%
clear-num98.7%
Applied egg-rr6.2%
Taylor expanded in a around 0 3.0%
Simplified4.3%
Final simplification4.3%
herbie shell --seed 2023175
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))