
(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 (/ 1.0 a)) (cbrt (/ 2.0 g))))
double code(double g, double a) {
return cbrt((1.0 / a)) / cbrt((2.0 / g));
}
public static double code(double g, double a) {
return Math.cbrt((1.0 / a)) / Math.cbrt((2.0 / g));
}
function code(g, a) return Float64(cbrt(Float64(1.0 / a)) / cbrt(Float64(2.0 / g))) end
code[g_, a_] := N[(N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(2.0 / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{\frac{1}{a}}}{\sqrt[3]{\frac{2}{g}}}
\end{array}
Initial program 77.6%
expm1-log1p-u58.7%
expm1-udef26.6%
log1p-udef26.6%
add-exp-log45.5%
*-un-lft-identity45.5%
times-frac45.5%
metadata-eval45.5%
Applied egg-rr45.5%
+-commutative45.5%
associate--l+77.6%
metadata-eval77.6%
+-rgt-identity77.6%
associate-*r/77.6%
associate-*l/77.6%
Simplified77.6%
Taylor expanded in a around 0 77.6%
associate-*r/77.6%
associate-/l*77.0%
Simplified77.0%
cbrt-div77.2%
clear-num77.1%
cbrt-div98.6%
associate-/r*98.6%
cbrt-prod98.6%
div-inv98.6%
metadata-eval98.6%
metadata-eval98.6%
div-inv98.6%
cbrt-div98.7%
clear-num98.7%
/-rgt-identity98.7%
clear-num98.6%
div-inv98.6%
clear-num98.7%
associate-/l/98.7%
associate-/r*98.8%
Applied egg-rr98.8%
add-cbrt-cube98.6%
un-div-inv98.5%
frac-times98.5%
metadata-eval98.5%
associate-/r*98.6%
add-cube-cbrt98.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 77.6%
div-inv77.6%
cbrt-prod98.7%
associate-/r*98.7%
metadata-eval98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (* a 2.0))))
double code(double g, double a) {
return cbrt(g) / cbrt((a * 2.0));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((a * 2.0));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(a * 2.0))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a * 2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{a \cdot 2}}
\end{array}
Initial program 77.6%
cbrt-div98.7%
div-inv98.6%
Applied egg-rr98.6%
associate-*r/98.7%
*-rgt-identity98.7%
*-commutative98.7%
Simplified98.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 77.6%
expm1-log1p-u58.7%
expm1-udef26.6%
log1p-udef26.6%
add-exp-log45.5%
*-un-lft-identity45.5%
times-frac45.5%
metadata-eval45.5%
Applied egg-rr45.5%
+-commutative45.5%
associate--l+77.6%
metadata-eval77.6%
+-rgt-identity77.6%
associate-*r/77.6%
associate-*l/77.6%
Simplified77.6%
Final simplification77.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 77.6%
Final simplification77.6%
(FPCore (g a) :precision binary64 (* (cbrt g) 0.0))
double code(double g, double a) {
return cbrt(g) * 0.0;
}
public static double code(double g, double a) {
return Math.cbrt(g) * 0.0;
}
function code(g, a) return Float64(cbrt(g) * 0.0) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] * 0.0), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g} \cdot 0
\end{array}
Initial program 77.6%
expm1-log1p-u58.7%
expm1-udef26.6%
log1p-udef26.6%
add-exp-log45.5%
*-un-lft-identity45.5%
times-frac45.5%
metadata-eval45.5%
Applied egg-rr45.5%
+-commutative45.5%
associate--l+77.6%
metadata-eval77.6%
+-rgt-identity77.6%
associate-*r/77.6%
associate-*l/77.6%
Simplified77.6%
Taylor expanded in a around 0 77.6%
associate-*r/77.6%
associate-/l*77.0%
Simplified77.0%
cbrt-div77.2%
clear-num77.1%
cbrt-div98.6%
associate-/r*98.6%
cbrt-prod98.6%
div-inv98.6%
metadata-eval98.6%
metadata-eval98.6%
div-inv98.6%
cbrt-div98.7%
clear-num98.7%
/-rgt-identity98.7%
clear-num98.6%
div-inv98.6%
clear-num98.7%
associate-/l/98.7%
associate-/r*98.8%
Applied egg-rr98.8%
associate-/l/98.7%
inv-pow98.7%
Applied egg-rr6.2%
Simplified3.2%
Final simplification3.2%
herbie shell --seed 2023213
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))