
(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 5 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 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 81.4%
associate-/r*81.4%
cbrt-div98.8%
div-inv98.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 81.4%
add-log-exp9.1%
*-un-lft-identity9.1%
log-prod9.1%
metadata-eval9.1%
add-log-exp81.4%
*-un-lft-identity81.4%
times-frac81.4%
metadata-eval81.4%
Applied egg-rr81.4%
+-lft-identity81.4%
associate-*r/81.4%
associate-/l*80.6%
associate-/r/81.4%
Simplified81.4%
associate-*l/81.4%
associate-/l*80.6%
Applied egg-rr80.6%
pow1/337.3%
div-inv37.3%
unpow-prod-down37.3%
pow1/337.3%
clear-num37.8%
Applied egg-rr37.8%
unpow1/381.4%
Simplified81.4%
Final simplification81.4%
(FPCore (g a) :precision binary64 (* (cbrt (/ 0.5 a)) (cbrt g)))
double code(double g, double a) {
return cbrt((0.5 / a)) * cbrt(g);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 / a)) * Math.cbrt(g);
}
function code(g, a) return Float64(cbrt(Float64(0.5 / a)) * cbrt(g)) end
code[g_, a_] := N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g}
\end{array}
Initial program 81.4%
pow1/337.7%
clear-num37.3%
associate-/r/37.7%
unpow-prod-down22.4%
pow1/345.4%
associate-/r*45.8%
metadata-eval45.8%
pow1/398.6%
Applied egg-rr98.6%
Final simplification98.6%
(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 81.4%
add-log-exp9.1%
*-un-lft-identity9.1%
log-prod9.1%
metadata-eval9.1%
add-log-exp81.4%
*-un-lft-identity81.4%
times-frac81.4%
metadata-eval81.4%
Applied egg-rr81.4%
+-lft-identity81.4%
associate-*r/81.4%
associate-/l*80.6%
associate-/r/81.4%
Simplified81.4%
Final simplification81.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 81.4%
Final simplification81.4%
herbie shell --seed 2024031
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))