
(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 g) (pow 2.0 0.3333333333333333)) (cbrt a)))
double code(double g, double a) {
return (cbrt(g) / pow(2.0, 0.3333333333333333)) / cbrt(a);
}
public static double code(double g, double a) {
return (Math.cbrt(g) / Math.pow(2.0, 0.3333333333333333)) / Math.cbrt(a);
}
function code(g, a) return Float64(Float64(cbrt(g) / (2.0 ^ 0.3333333333333333)) / cbrt(a)) end
code[g_, a_] := N[(N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[2.0, 0.3333333333333333], $MachinePrecision]), $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\sqrt[3]{g}}{{2}^{0.3333333333333333}}}{\sqrt[3]{a}}
\end{array}
Initial program 76.6%
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.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
cbrt-divN/A
lower-/.f64N/A
lift-cbrt.f64N/A
lower-cbrt.f6498.2
Applied rewrites98.2%
lift-cbrt.f64N/A
pow1/3N/A
lower-pow.f6498.7
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (+ a a))))
double code(double g, double a) {
return cbrt(g) / cbrt((a + a));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((a + a));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(a + a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a + a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{a + a}}
\end{array}
Initial program 76.6%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
count-2-revN/A
lower-+.f6498.7
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (if (<= (cbrt (/ g (* 2.0 a))) 5e+101) (cbrt (/ g (+ a a))) (exp (* (- (- (log g) (log 2.0)) (log a)) 0.3333333333333333))))
double code(double g, double a) {
double tmp;
if (cbrt((g / (2.0 * a))) <= 5e+101) {
tmp = cbrt((g / (a + a)));
} else {
tmp = exp((((log(g) - log(2.0)) - log(a)) * 0.3333333333333333));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if (Math.cbrt((g / (2.0 * a))) <= 5e+101) {
tmp = Math.cbrt((g / (a + a)));
} else {
tmp = Math.exp((((Math.log(g) - Math.log(2.0)) - Math.log(a)) * 0.3333333333333333));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (cbrt(Float64(g / Float64(2.0 * a))) <= 5e+101) tmp = cbrt(Float64(g / Float64(a + a))); else tmp = exp(Float64(Float64(Float64(log(g) - log(2.0)) - log(a)) * 0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 5e+101], N[Power[N[(g / N[(a + a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[Exp[N[(N[(N[(N[Log[g], $MachinePrecision] - N[Log[2.0], $MachinePrecision]), $MachinePrecision] - N[Log[a], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{\frac{g}{2 \cdot a}} \leq 5 \cdot 10^{+101}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a + a}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(\left(\log g - \log 2\right) - \log a\right) \cdot 0.3333333333333333}\\
\end{array}
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 4.99999999999999989e101Initial program 81.3%
lift-*.f64N/A
count-2-revN/A
lower-+.f6481.3
Applied rewrites81.3%
if 4.99999999999999989e101 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 6.9%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow1/3N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lift-/.f64N/A
count-2-revN/A
lower-+.f646.7
Applied rewrites6.7%
lift-log.f64N/A
lift-+.f64N/A
lift-/.f64N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lift-+.f6445.5
Applied rewrites45.5%
lift--.f64N/A
lift-log.f64N/A
lift-+.f64N/A
lift-log.f64N/A
count-2-revN/A
sum-logN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f64N/A
lower-log.f64N/A
lower-log.f6445.6
Applied rewrites45.6%
(FPCore (g a) :precision binary64 (if (<= (cbrt (/ g (* 2.0 a))) 5e+101) (cbrt (/ g (+ a a))) (exp (* (- (log g) (log (+ a a))) 0.3333333333333333))))
double code(double g, double a) {
double tmp;
if (cbrt((g / (2.0 * a))) <= 5e+101) {
tmp = cbrt((g / (a + a)));
} else {
tmp = exp(((log(g) - log((a + a))) * 0.3333333333333333));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if (Math.cbrt((g / (2.0 * a))) <= 5e+101) {
tmp = Math.cbrt((g / (a + a)));
} else {
tmp = Math.exp(((Math.log(g) - Math.log((a + a))) * 0.3333333333333333));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (cbrt(Float64(g / Float64(2.0 * a))) <= 5e+101) tmp = cbrt(Float64(g / Float64(a + a))); else tmp = exp(Float64(Float64(log(g) - log(Float64(a + a))) * 0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 5e+101], N[Power[N[(g / N[(a + a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[Exp[N[(N[(N[Log[g], $MachinePrecision] - N[Log[N[(a + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sqrt[3]{\frac{g}{2 \cdot a}} \leq 5 \cdot 10^{+101}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a + a}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(\log g - \log \left(a + a\right)\right) \cdot 0.3333333333333333}\\
\end{array}
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 4.99999999999999989e101Initial program 81.3%
lift-*.f64N/A
count-2-revN/A
lower-+.f6481.3
Applied rewrites81.3%
if 4.99999999999999989e101 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 6.9%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow1/3N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lift-/.f64N/A
count-2-revN/A
lower-+.f646.7
Applied rewrites6.7%
lift-log.f64N/A
lift-+.f64N/A
lift-/.f64N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lift-+.f6445.5
Applied rewrites45.5%
(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 76.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.6
Applied rewrites76.6%
herbie shell --seed 2025114
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))