
(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 (/ 1.0 (/ (/ 1.0 (cbrt g)) (cbrt (/ 0.5 a)))))
double code(double g, double a) {
return 1.0 / ((1.0 / cbrt(g)) / cbrt((0.5 / a)));
}
public static double code(double g, double a) {
return 1.0 / ((1.0 / Math.cbrt(g)) / Math.cbrt((0.5 / a)));
}
function code(g, a) return Float64(1.0 / Float64(Float64(1.0 / cbrt(g)) / cbrt(Float64(0.5 / a)))) end
code[g_, a_] := N[(1.0 / N[(N[(1.0 / N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision] / N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\frac{1}{\sqrt[3]{g}}}{\sqrt[3]{\frac{0.5}{a}}}}
\end{array}
Initial program 74.2%
clear-num73.2%
cbrt-div73.6%
metadata-eval73.6%
*-un-lft-identity73.6%
times-frac73.6%
metadata-eval73.6%
Applied egg-rr73.6%
associate-*r/73.6%
associate-*l/73.2%
Simplified73.2%
associate-*l/73.6%
cbrt-undiv98.7%
clear-num98.7%
div-inv98.7%
associate-/r*98.6%
*-commutative98.6%
metadata-eval98.6%
metadata-eval98.6%
div-inv98.6%
cbrt-div98.8%
clear-num98.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 74.2%
div-inv74.2%
cbrt-prod98.7%
associate-/r*98.7%
metadata-eval98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (cbrt (* g (+ a a))))
double code(double g, double a) {
return cbrt((g * (a + a)));
}
public static double code(double g, double a) {
return Math.cbrt((g * (a + a)));
}
function code(g, a) return cbrt(Float64(g * Float64(a + a))) end
code[g_, a_] := N[Power[N[(g * N[(a + a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g \cdot \left(a + a\right)}
\end{array}
Initial program 74.2%
div-inv74.2%
cbrt-prod98.7%
associate-/r*98.7%
metadata-eval98.7%
Applied egg-rr98.7%
clear-num98.7%
cbrt-div98.7%
metadata-eval98.7%
div-inv98.7%
metadata-eval98.7%
div-inv98.7%
clear-num98.7%
*-commutative98.7%
div-inv98.7%
associate-/r*98.7%
*-commutative98.7%
metadata-eval98.7%
metadata-eval98.7%
div-inv98.7%
cbrt-div98.7%
clear-num98.7%
Applied egg-rr98.7%
associate-/r/98.7%
/-rgt-identity98.7%
clear-num98.7%
cbrt-div98.7%
metadata-eval98.7%
div-inv98.7%
metadata-eval98.7%
metadata-eval98.7%
distribute-rgt-out98.7%
*-un-lft-identity98.7%
*-un-lft-identity98.7%
add-cbrt-cube98.5%
cbrt-unprod73.9%
Applied egg-rr5.8%
Final simplification5.8%
(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 74.2%
expm1-log1p-u55.1%
expm1-udef24.5%
log1p-udef24.5%
add-exp-log43.7%
*-un-lft-identity43.7%
times-frac43.7%
metadata-eval43.7%
Applied egg-rr43.7%
+-commutative43.7%
associate--l+74.2%
metadata-eval74.2%
+-rgt-identity74.2%
associate-*r/74.2%
associate-*l/74.2%
Simplified74.2%
Final simplification74.2%
(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 74.2%
Final simplification74.2%
herbie shell --seed 2023171
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))