
(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 8 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 -0.5) (cbrt (/ -1.0 a)))))
double code(double g, double a) {
return cbrt(g) * (cbrt(-0.5) * cbrt((-1.0 / a)));
}
public static double code(double g, double a) {
return Math.cbrt(g) * (Math.cbrt(-0.5) * Math.cbrt((-1.0 / a)));
}
function code(g, a) return Float64(cbrt(g) * Float64(cbrt(-0.5) * cbrt(Float64(-1.0 / a)))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{\frac{-1}{a}}\right)
\end{array}
Initial program 77.4%
Applied rewrites98.8%
lift-*.f64N/A
*-commutativeN/A
lift-cbrt.f64N/A
pow1/3N/A
lift-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f6498.8
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) -1e-306) (pow (cbrt (/ (* 2.0 a) g)) -1.0) (* (cbrt g) (pow (* 2.0 a) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -1e-306) {
tmp = pow(cbrt(((2.0 * a) / g)), -1.0);
} 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-306) {
tmp = Math.pow(Math.cbrt(((2.0 * a) / g)), -1.0);
} 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-306) tmp = cbrt(Float64(Float64(2.0 * a) / g)) ^ -1.0; 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-306], N[Power[N[Power[N[(N[(2.0 * a), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision], -1.0], $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 -1 \cdot 10^{-306}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{2 \cdot a}{g}}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(2 \cdot a\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -1.00000000000000003e-306Initial program 78.8%
Applied rewrites98.7%
lift-*.f64N/A
*-commutativeN/A
lift-cbrt.f64N/A
pow1/3N/A
lift-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
Applied rewrites79.8%
if -1.00000000000000003e-306 < (*.f64 #s(literal 2 binary64) a) Initial program 76.0%
Applied rewrites98.8%
lift-*.f64N/A
*-commutativeN/A
lift-cbrt.f64N/A
pow1/3N/A
lift-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-unprodN/A
pow1/3N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lift-*.f64N/A
pow-powN/A
lower-pow.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval92.2
Applied rewrites92.2%
Final simplification85.9%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) -1e-306) (* (pow (- a) -0.3333333333333333) (cbrt (* -0.5 g))) (* (cbrt g) (pow (* 2.0 a) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -1e-306) {
tmp = pow(-a, -0.3333333333333333) * cbrt((-0.5 * g));
} 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-306) {
tmp = Math.pow(-a, -0.3333333333333333) * Math.cbrt((-0.5 * g));
} 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-306) tmp = Float64((Float64(-a) ^ -0.3333333333333333) * cbrt(Float64(-0.5 * g))); 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-306], N[(N[Power[(-a), -0.3333333333333333], $MachinePrecision] * N[Power[N[(-0.5 * g), $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 -1 \cdot 10^{-306}:\\
\;\;\;\;{\left(-a\right)}^{-0.3333333333333333} \cdot \sqrt[3]{-0.5 \cdot g}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(2 \cdot a\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -1.00000000000000003e-306Initial program 78.8%
Applied rewrites98.7%
lift-cbrt.f64N/A
pow1/3N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lower-neg.f64N/A
metadata-eval92.0
Applied rewrites92.0%
if -1.00000000000000003e-306 < (*.f64 #s(literal 2 binary64) a) Initial program 76.0%
Applied rewrites98.8%
lift-*.f64N/A
*-commutativeN/A
lift-cbrt.f64N/A
pow1/3N/A
lift-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-unprodN/A
pow1/3N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lift-*.f64N/A
pow-powN/A
lower-pow.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval92.2
Applied rewrites92.2%
(FPCore (g a) :precision binary64 (* (cbrt (/ -1.0 a)) (cbrt (* -0.5 g))))
double code(double g, double a) {
return cbrt((-1.0 / a)) * cbrt((-0.5 * g));
}
public static double code(double g, double a) {
return Math.cbrt((-1.0 / a)) * Math.cbrt((-0.5 * g));
}
function code(g, a) return Float64(cbrt(Float64(-1.0 / a)) * cbrt(Float64(-0.5 * g))) end
code[g_, a_] := N[(N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(-0.5 * g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-1}{a}} \cdot \sqrt[3]{-0.5 \cdot g}
\end{array}
Initial program 77.4%
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (pow (cbrt (/ (* 2.0 a) g)) -1.0))
double code(double g, double a) {
return pow(cbrt(((2.0 * a) / g)), -1.0);
}
public static double code(double g, double a) {
return Math.pow(Math.cbrt(((2.0 * a) / g)), -1.0);
}
function code(g, a) return cbrt(Float64(Float64(2.0 * a) / g)) ^ -1.0 end
code[g_, a_] := N[Power[N[Power[N[(N[(2.0 * a), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(\sqrt[3]{\frac{2 \cdot a}{g}}\right)}^{-1}
\end{array}
Initial program 77.4%
Applied rewrites98.8%
lift-*.f64N/A
*-commutativeN/A
lift-cbrt.f64N/A
pow1/3N/A
lift-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
associate-*l*N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-*.f64N/A
pow1/3N/A
lower-cbrt.f6498.8
Applied rewrites98.8%
Applied rewrites78.3%
Final simplification78.3%
(FPCore (g a) :precision binary64 (pow (cbrt (* (/ 2.0 g) a)) -1.0))
double code(double g, double a) {
return pow(cbrt(((2.0 / g) * a)), -1.0);
}
public static double code(double g, double a) {
return Math.pow(Math.cbrt(((2.0 / g) * a)), -1.0);
}
function code(g, a) return cbrt(Float64(Float64(2.0 / g) * a)) ^ -1.0 end
code[g_, a_] := N[Power[N[Power[N[(N[(2.0 / g), $MachinePrecision] * a), $MachinePrecision], 1/3], $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(\sqrt[3]{\frac{2}{g} \cdot a}\right)}^{-1}
\end{array}
Initial program 77.4%
Applied rewrites98.8%
Applied rewrites77.9%
Final simplification77.9%
(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 77.4%
Applied rewrites98.8%
lift-*.f64N/A
lift-cbrt.f64N/A
pow1/3N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*r*N/A
lower-*.f64N/A
lift-cbrt.f64N/A
pow1/3N/A
cbrt-unprodN/A
lift-/.f64N/A
associate-*l/N/A
metadata-evalN/A
metadata-evalN/A
distribute-neg-fracN/A
lift-/.f64N/A
lower-cbrt.f64N/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
metadata-evalN/A
pow1/3N/A
lower-cbrt.f6498.8
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (cbrt (* (/ 0.5 a) g)))
double code(double g, double a) {
return cbrt(((0.5 / a) * g));
}
public static double code(double g, double a) {
return Math.cbrt(((0.5 / a) * g));
}
function code(g, a) return cbrt(Float64(Float64(0.5 / a) * g)) end
code[g_, a_] := N[Power[N[(N[(0.5 / a), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot g}
\end{array}
Initial program 77.4%
Applied rewrites98.8%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-unprodN/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*l/N/A
cbrt-divN/A
*-lft-identityN/A
remove-double-negN/A
lift-*.f64N/A
distribute-rgt-neg-outN/A
lift-neg.f64N/A
cbrt-divN/A
frac-2negN/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cbrt.f6477.4
lift-*.f64N/A
Applied rewrites77.4%
herbie shell --seed 2024318
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))