
(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 4 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 79.6%
div-inv79.7%
cbrt-prod98.8%
associate-/r*98.8%
metadata-eval98.8%
Applied egg-rr98.8%
Final simplification98.8%
(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 79.6%
cbrt-div98.8%
div-inv98.7%
Applied egg-rr98.7%
associate-*r/98.8%
*-rgt-identity98.8%
*-commutative98.8%
Simplified98.8%
cbrt-div79.6%
clear-num78.6%
associate-/r/79.7%
*-commutative79.7%
associate-/r*79.7%
metadata-eval79.7%
associate-/r/78.6%
div-inv78.6%
cbrt-prod78.7%
clear-num79.8%
Applied egg-rr79.8%
Final simplification79.8%
(FPCore (g a) :precision binary64 (cbrt (/ (/ 1.0 a) (/ 2.0 g))))
double code(double g, double a) {
return cbrt(((1.0 / a) / (2.0 / g)));
}
public static double code(double g, double a) {
return Math.cbrt(((1.0 / a) / (2.0 / g)));
}
function code(g, a) return cbrt(Float64(Float64(1.0 / a) / Float64(2.0 / g))) end
code[g_, a_] := N[Power[N[(N[(1.0 / a), $MachinePrecision] / N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{\frac{1}{a}}{\frac{2}{g}}}
\end{array}
Initial program 79.6%
expm1-log1p-u60.6%
expm1-udef26.2%
log1p-udef26.2%
add-exp-log45.3%
*-un-lft-identity45.3%
times-frac45.3%
metadata-eval45.3%
Applied egg-rr45.3%
+-commutative45.3%
associate--l+79.6%
metadata-eval79.6%
+-rgt-identity79.6%
associate-*r/79.6%
associate-*l/79.7%
Simplified79.7%
add-cube-cbrt79.5%
cbrt-prod79.5%
cbrt-prod79.4%
*-commutative79.4%
*-commutative79.4%
cbrt-prod79.3%
*-commutative79.3%
pow379.4%
cbrt-unprod79.5%
clear-num79.5%
un-div-inv79.5%
div-inv79.5%
metadata-eval79.5%
Applied egg-rr79.5%
unpow379.5%
add-cube-cbrt79.6%
clear-num78.6%
associate-*r/78.6%
associate-/r*79.7%
Applied egg-rr79.7%
Final simplification79.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 79.6%
expm1-log1p-u60.6%
expm1-udef26.2%
log1p-udef26.2%
add-exp-log45.3%
*-un-lft-identity45.3%
times-frac45.3%
metadata-eval45.3%
Applied egg-rr45.3%
+-commutative45.3%
associate--l+79.6%
metadata-eval79.6%
+-rgt-identity79.6%
associate-*r/79.6%
associate-*l/79.7%
Simplified79.7%
Final simplification79.7%
herbie shell --seed 2023282
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))