
(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}
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 (/ (cbrt (* 0.5 g)) (cbrt a)))
double code(double g, double a) {
return cbrt((0.5 * g)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 * g)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(0.5 * g)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{0.5 \cdot g}}{\sqrt[3]{a}}
\end{array}
Initial program 71.3%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f6498.8
Applied rewrites98.8%
Taylor expanded in g around 0
lower-*.f6498.8
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (if (<= a 3e-288) (cbrt (/ g (+ a a))) (/ (cbrt g) (pow (+ a a) 0.3333333333333333))))
double code(double g, double a) {
double tmp;
if (a <= 3e-288) {
tmp = cbrt((g / (a + a)));
} else {
tmp = cbrt(g) / pow((a + a), 0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if (a <= 3e-288) {
tmp = Math.cbrt((g / (a + a)));
} else {
tmp = Math.cbrt(g) / Math.pow((a + a), 0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (a <= 3e-288) tmp = cbrt(Float64(g / Float64(a + a))); else tmp = Float64(cbrt(g) / (Float64(a + a) ^ 0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[a, 3e-288], N[Power[N[(g / N[(a + a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a + a), $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3 \cdot 10^{-288}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a + a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{g}}{{\left(a + a\right)}^{0.3333333333333333}}\\
\end{array}
\end{array}
if a < 2.99999999999999999e-288Initial program 72.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.2
Applied rewrites72.2%
if 2.99999999999999999e-288 < a Initial program 70.2%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
lift-*.f64N/A
lift-cbrt.f64N/A
pow1/3N/A
lower-pow.f64N/A
lift-*.f6491.9
Applied rewrites91.9%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6491.9
Applied rewrites91.9%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (* a 2.0))))
double code(double g, double a) {
return cbrt(g) / cbrt((a * 2.0));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((a * 2.0));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(a * 2.0))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a * 2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{a \cdot 2}}
\end{array}
Initial program 71.3%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
(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]{\frac{g}{a + a}}
\end{array}
Initial program 71.3%
lift-*.f64N/A
count-2-revN/A
lower-+.f6471.3
Applied rewrites71.3%
(FPCore (g a) :precision binary64 (cbrt (* 0.5 g)))
double code(double g, double a) {
return cbrt((0.5 * g));
}
public static double code(double g, double a) {
return Math.cbrt((0.5 * g));
}
function code(g, a) return cbrt(Float64(0.5 * g)) end
code[g_, a_] := N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{0.5 \cdot g}
\end{array}
Initial program 71.3%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f6498.8
Applied rewrites98.8%
lift-/.f64N/A
lift-cbrt.f64N/A
cbrt-divN/A
lower-/.f64N/A
lift-cbrt.f64N/A
lower-cbrt.f6498.1
Applied rewrites98.1%
lift-/.f64N/A
lift-cbrt.f64N/A
*-rgt-identityN/A
lift-cbrt.f64N/A
associate-*r/N/A
inv-powN/A
lift-pow.f64N/A
lift-cbrt.f64N/A
lower-*.f64N/A
lift-cbrt.f6498.1
lift-cbrt.f64N/A
lift-pow.f64N/A
inv-powN/A
metadata-evalN/A
metadata-evalN/A
cbrt-unprodN/A
associate-*r/N/A
cbrt-undivN/A
metadata-evalN/A
cbrt-unprodN/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
associate-*l/N/A
cbrt-divN/A
cbrt-unprodN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
count-2-revN/A
flip-+N/A
+-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
metadata-evalN/A
associate-*r/N/A
metadata-evalN/A
Applied rewrites4.1%
herbie shell --seed 2025082
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))