
(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 7 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 (/ 2.0 g)) (cbrt a))))
double code(double g, double a) {
return 1.0 / (cbrt((2.0 / g)) * cbrt(a));
}
public static double code(double g, double a) {
return 1.0 / (Math.cbrt((2.0 / g)) * Math.cbrt(a));
}
function code(g, a) return Float64(1.0 / Float64(cbrt(Float64(2.0 / g)) * cbrt(a))) end
code[g_, a_] := N[(1.0 / N[(N[Power[N[(2.0 / g), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{2}{g}} \cdot \sqrt[3]{a}}
\end{array}
Initial program 80.0%
clear-num79.5%
cbrt-div80.4%
metadata-eval80.4%
*-un-lft-identity80.4%
times-frac80.4%
metadata-eval80.4%
Applied egg-rr80.4%
associate-*r/80.4%
associate-*l/80.5%
Simplified80.5%
cbrt-prod98.7%
Applied egg-rr98.7%
Final simplification98.7%
(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 80.0%
div-inv80.0%
cbrt-prod98.5%
associate-/r*98.5%
metadata-eval98.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (* 2.0 a))))
double code(double g, double a) {
return cbrt(g) / cbrt((2.0 * a));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((2.0 * a));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(2.0 * a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(2.0 * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{2 \cdot a}}
\end{array}
Initial program 80.0%
cbrt-div98.6%
div-inv98.6%
Applied egg-rr98.6%
associate-*r/98.6%
*-rgt-identity98.6%
*-commutative98.6%
Simplified98.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 80.0%
associate-/r*80.0%
cbrt-div98.6%
div-inv98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Final simplification98.6%
(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 80.0%
clear-num79.5%
cbrt-div80.4%
metadata-eval80.4%
*-un-lft-identity80.4%
times-frac80.4%
metadata-eval80.4%
Applied egg-rr80.4%
Final simplification80.4%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (* (/ 2.0 g) a))))
double code(double g, double a) {
return 1.0 / cbrt(((2.0 / g) * a));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((2.0 / g) * a));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(2.0 / g) * a))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(2.0 / g), $MachinePrecision] * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{2}{g} \cdot a}}
\end{array}
Initial program 80.0%
clear-num79.5%
cbrt-div80.4%
metadata-eval80.4%
*-un-lft-identity80.4%
times-frac80.4%
metadata-eval80.4%
Applied egg-rr80.4%
associate-*r/80.4%
associate-*l/80.5%
Simplified80.5%
Final simplification80.5%
(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 80.0%
expm1-log1p-u59.9%
expm1-udef21.8%
log1p-udef21.8%
add-exp-log41.9%
*-un-lft-identity41.9%
times-frac41.9%
metadata-eval41.9%
Applied egg-rr41.9%
+-commutative41.9%
associate--l+79.9%
metadata-eval79.9%
+-rgt-identity79.9%
associate-*r/80.0%
associate-*l/80.0%
Simplified80.0%
Final simplification80.0%
herbie shell --seed 2023283
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))