
(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 9 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 -1.0) (* (cbrt (/ -2.0 g)) (cbrt a))))
double code(double g, double a) {
return cbrt(-1.0) / (cbrt((-2.0 / g)) * cbrt(a));
}
public static double code(double g, double a) {
return Math.cbrt(-1.0) / (Math.cbrt((-2.0 / g)) * Math.cbrt(a));
}
function code(g, a) return Float64(cbrt(-1.0) / Float64(cbrt(Float64(-2.0 / g)) * cbrt(a))) end
code[g_, a_] := N[(N[Power[-1.0, 1/3], $MachinePrecision] / N[(N[Power[N[(-2.0 / g), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{-1}}{\sqrt[3]{\frac{-2}{g}} \cdot \sqrt[3]{a}}
\end{array}
Initial program 73.0%
associate-/r*N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval40.3
Applied rewrites40.3%
metadata-evalN/A
pow-powN/A
inv-powN/A
pow1/3N/A
lower-cbrt.f64N/A
lower-/.f6498.7
Applied rewrites98.7%
lift-*.f6498.7
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6498.7
Applied rewrites98.7%
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (* (cbrt (/ 1.0 a)) (cbrt (/ 1.0 (/ 2.0 g)))))
double code(double g, double a) {
return cbrt((1.0 / a)) * cbrt((1.0 / (2.0 / g)));
}
public static double code(double g, double a) {
return Math.cbrt((1.0 / a)) * Math.cbrt((1.0 / (2.0 / g)));
}
function code(g, a) return Float64(cbrt(Float64(1.0 / a)) * cbrt(Float64(1.0 / Float64(2.0 / g)))) end
code[g_, a_] := N[(N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(1.0 / N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{1}{a}} \cdot \sqrt[3]{\frac{1}{\frac{2}{g}}}
\end{array}
Initial program 73.0%
associate-/r*N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval40.3
Applied rewrites40.3%
metadata-evalN/A
pow-powN/A
inv-powN/A
pow1/3N/A
lower-cbrt.f64N/A
lower-/.f6498.7
Applied rewrites98.7%
lift-*.f6498.7
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6498.7
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) 4e-308) (cbrt (* (/ 1.0 a) (* g 0.5))) (* (cbrt (* g 0.5)) (pow a -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 4e-308) {
tmp = cbrt(((1.0 / a) * (g * 0.5)));
} else {
tmp = cbrt((g * 0.5)) * pow(a, -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 4e-308) {
tmp = Math.cbrt(((1.0 / a) * (g * 0.5)));
} else {
tmp = Math.cbrt((g * 0.5)) * Math.pow(a, -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= 4e-308) tmp = cbrt(Float64(Float64(1.0 / a) * Float64(g * 0.5))); else tmp = Float64(cbrt(Float64(g * 0.5)) * (a ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], 4e-308], N[Power[N[(N[(1.0 / a), $MachinePrecision] * N[(g * 0.5), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq 4 \cdot 10^{-308}:\\
\;\;\;\;\sqrt[3]{\frac{1}{a} \cdot \left(g \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g \cdot 0.5} \cdot {a}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 4.00000000000000013e-308Initial program 72.6%
associate-/r*N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval73.3
Applied rewrites73.3%
if 4.00000000000000013e-308 < (*.f64 #s(literal 2 binary64) a) Initial program 73.5%
associate-/r*N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval92.1
Applied rewrites92.1%
Final simplification81.5%
(FPCore (g a) :precision binary64 (* (cbrt (/ 1.0 a)) (cbrt (* g 0.5))))
double code(double g, double a) {
return cbrt((1.0 / a)) * cbrt((g * 0.5));
}
public static double code(double g, double a) {
return Math.cbrt((1.0 / a)) * Math.cbrt((g * 0.5));
}
function code(g, a) return Float64(cbrt(Float64(1.0 / a)) * cbrt(Float64(g * 0.5))) end
code[g_, a_] := N[(N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{1}{a}} \cdot \sqrt[3]{g \cdot 0.5}
\end{array}
Initial program 73.0%
associate-/r*N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval40.3
Applied rewrites40.3%
metadata-evalN/A
pow-powN/A
inv-powN/A
pow1/3N/A
lower-cbrt.f64N/A
lower-/.f6498.7
Applied rewrites98.7%
(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 73.0%
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
(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 73.0%
associate-/r*N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval40.3
Applied rewrites40.3%
metadata-evalN/A
pow-powN/A
inv-powN/A
pow1/3N/A
lower-cbrt.f64N/A
lower-/.f6498.7
Applied rewrites98.7%
lift-*.f6498.7
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
associate-/r/N/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
cbrt-prodN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
associate-/r/N/A
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
metadata-evalN/A
associate-*r*N/A
cbrt-prodN/A
lift-/.f64N/A
associate-*l/N/A
metadata-evalN/A
pow1/3N/A
Applied rewrites98.7%
(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 73.0%
associate-/r*N/A
clear-numN/A
associate-/r*N/A
associate-/l/N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6473.4
Applied rewrites73.4%
(FPCore (g a) :precision binary64 (cbrt (* (/ 1.0 a) (* g 0.5))))
double code(double g, double a) {
return cbrt(((1.0 / a) * (g * 0.5)));
}
public static double code(double g, double a) {
return Math.cbrt(((1.0 / a) * (g * 0.5)));
}
function code(g, a) return cbrt(Float64(Float64(1.0 / a) * Float64(g * 0.5))) end
code[g_, a_] := N[Power[N[(N[(1.0 / a), $MachinePrecision] * N[(g * 0.5), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{1}{a} \cdot \left(g \cdot 0.5\right)}
\end{array}
Initial program 73.0%
associate-/r*N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval73.4
Applied rewrites73.4%
(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 73.0%
lift-*.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval73.4
Applied rewrites73.4%
Final simplification73.4%
herbie shell --seed 2024216
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))