
(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 7 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 (* 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 79.3%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.8
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) -5e-302) (* (pow (- a) -0.3333333333333333) (cbrt (* g -0.5))) (* (cbrt g) (pow (* 2.0 a) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -5e-302) {
tmp = pow(-a, -0.3333333333333333) * cbrt((g * -0.5));
} else {
tmp = cbrt(g) * pow((2.0 * a), -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -5e-302) {
tmp = Math.pow(-a, -0.3333333333333333) * Math.cbrt((g * -0.5));
} else {
tmp = Math.cbrt(g) * Math.pow((2.0 * a), -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= -5e-302) tmp = Float64((Float64(-a) ^ -0.3333333333333333) * cbrt(Float64(g * -0.5))); else tmp = Float64(cbrt(g) * (Float64(2.0 * a) ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], -5e-302], N[(N[Power[(-a), -0.3333333333333333], $MachinePrecision] * N[Power[N[(g * -0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(2.0 * a), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq -5 \cdot 10^{-302}:\\
\;\;\;\;{\left(-a\right)}^{-0.3333333333333333} \cdot \sqrt[3]{g \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(2 \cdot a\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -5.00000000000000033e-302Initial program 83.1%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
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-eval0.0
Applied rewrites0.0%
lift-pow.f64N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
pow1/3N/A
lower-cbrt.f64N/A
lower-/.f6498.7
Applied rewrites98.7%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
metadata-evalN/A
div-invN/A
cbrt-prodN/A
clear-numN/A
lift-/.f64N/A
div-invN/A
frac-2negN/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
distribute-frac-neg2N/A
lift-/.f64N/A
clear-numN/A
lower-*.f64N/A
Applied rewrites92.2%
if -5.00000000000000033e-302 < (*.f64 #s(literal 2 binary64) a) Initial program 75.3%
lift-cbrt.f64N/A
lift-/.f64N/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.f6492.0
Applied rewrites92.0%
Final simplification92.1%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) 1e-305) (cbrt (/ g (* 2.0 a))) (* (cbrt g) (pow (* 2.0 a) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= 1e-305) {
tmp = cbrt((g / (2.0 * a)));
} else {
tmp = cbrt(g) * pow((2.0 * a), -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= 1e-305) {
tmp = Math.cbrt((g / (2.0 * a)));
} else {
tmp = Math.cbrt(g) * Math.pow((2.0 * a), -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= 1e-305) tmp = cbrt(Float64(g / Float64(2.0 * a))); else tmp = Float64(cbrt(g) * (Float64(2.0 * a) ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], 1e-305], N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(2.0 * a), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq 10^{-305}:\\
\;\;\;\;\sqrt[3]{\frac{g}{2 \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(2 \cdot a\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 9.99999999999999996e-306Initial program 83.2%
if 9.99999999999999996e-306 < (*.f64 #s(literal 2 binary64) a) Initial program 75.1%
lift-cbrt.f64N/A
lift-/.f64N/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.f6492.1
Applied rewrites92.1%
Final simplification87.4%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) 1e-305) (cbrt (/ g (* 2.0 a))) (* (pow a -0.3333333333333333) (cbrt (* g 0.5)))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= 1e-305) {
tmp = cbrt((g / (2.0 * a)));
} else {
tmp = pow(a, -0.3333333333333333) * cbrt((g * 0.5));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= 1e-305) {
tmp = Math.cbrt((g / (2.0 * a)));
} else {
tmp = Math.pow(a, -0.3333333333333333) * Math.cbrt((g * 0.5));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= 1e-305) tmp = cbrt(Float64(g / Float64(2.0 * a))); else tmp = Float64((a ^ -0.3333333333333333) * cbrt(Float64(g * 0.5))); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], 1e-305], N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[a, -0.3333333333333333], $MachinePrecision] * N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq 10^{-305}:\\
\;\;\;\;\sqrt[3]{\frac{g}{2 \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;{a}^{-0.3333333333333333} \cdot \sqrt[3]{g \cdot 0.5}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 9.99999999999999996e-306Initial program 83.2%
if 9.99999999999999996e-306 < (*.f64 #s(literal 2 binary64) a) Initial program 75.1%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
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.0
Applied rewrites92.0%
(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.3%
lift-cbrt.f64N/A
lift-/.f64N/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.f6444.2
Applied rewrites44.2%
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
metadata-evalN/A
pow-powN/A
inv-powN/A
clear-numN/A
pow1/3N/A
lower-cbrt.f64N/A
lower-/.f6498.7
Applied rewrites98.7%
Final simplification98.7%
(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 79.3%
(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.3%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval79.3
Applied rewrites79.3%
Final simplification79.3%
herbie shell --seed 2024232
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))