
(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 (/ 1.0 (/ (cbrt (* 2.0 a)) (cbrt g))))
double code(double g, double a) {
return 1.0 / (cbrt((2.0 * a)) / cbrt(g));
}
public static double code(double g, double a) {
return 1.0 / (Math.cbrt((2.0 * a)) / Math.cbrt(g));
}
function code(g, a) return Float64(1.0 / Float64(cbrt(Float64(2.0 * a)) / cbrt(g))) end
code[g_, a_] := N[(1.0 / N[(N[Power[N[(2.0 * a), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\sqrt[3]{2 \cdot a}}{\sqrt[3]{g}}}
\end{array}
Initial program 69.9%
cbrt-div98.8%
clear-num98.9%
Applied egg-rr98.9%
Final simplification98.9%
(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 69.9%
pow1/332.0%
clear-num31.8%
associate-/r/32.0%
unpow-prod-down23.2%
pow1/343.1%
associate-/r*43.1%
metadata-eval43.1%
pow1/398.7%
Applied egg-rr98.7%
Final simplification98.7%
(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 69.9%
cbrt-div98.8%
clear-num98.9%
Applied egg-rr98.9%
associate-/l*98.8%
*-lft-identity98.8%
*-commutative98.8%
Simplified98.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 69.9%
clear-num69.6%
cbrt-div69.9%
metadata-eval69.9%
associate-/l*69.5%
Applied egg-rr69.5%
associate-/r/69.9%
Simplified69.9%
Final simplification69.9%
(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 69.9%
add-log-exp9.3%
*-un-lft-identity9.3%
log-prod9.3%
metadata-eval9.3%
add-log-exp69.9%
*-un-lft-identity69.9%
times-frac69.9%
metadata-eval69.9%
Applied egg-rr69.9%
+-lft-identity69.9%
metadata-eval69.9%
times-frac69.9%
*-commutative69.9%
times-frac69.8%
rem-square-sqrt32.1%
associate-*r/32.1%
/-rgt-identity32.1%
rem-square-sqrt69.8%
Simplified69.8%
Final simplification69.8%
(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}
Initial program 69.9%
Final simplification69.9%
herbie shell --seed 2023331
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))