
(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 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 (+ 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
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.7
Applied rewrites98.7%
(FPCore (g a)
:precision binary64
(let* ((t_0 (cbrt (/ g (* 2.0 a)))))
(if (<= t_0 4e-104)
(exp
(fma (log (* 0.5 g)) 0.3333333333333333 (* -0.3333333333333333 (log a))))
(if (<= t_0 1e+103)
(cbrt (/ 1.0 (/ (+ a a) g)))
(exp
(-
(* (log g) 0.3333333333333333)
(* (log (+ a a)) 0.3333333333333333)))))))
double code(double g, double a) {
double t_0 = cbrt((g / (2.0 * a)));
double tmp;
if (t_0 <= 4e-104) {
tmp = exp(fma(log((0.5 * g)), 0.3333333333333333, (-0.3333333333333333 * log(a))));
} else if (t_0 <= 1e+103) {
tmp = cbrt((1.0 / ((a + a) / g)));
} else {
tmp = exp(((log(g) * 0.3333333333333333) - (log((a + a)) * 0.3333333333333333)));
}
return tmp;
}
function code(g, a) t_0 = cbrt(Float64(g / Float64(2.0 * a))) tmp = 0.0 if (t_0 <= 4e-104) tmp = exp(fma(log(Float64(0.5 * g)), 0.3333333333333333, Float64(-0.3333333333333333 * log(a)))); elseif (t_0 <= 1e+103) tmp = cbrt(Float64(1.0 / Float64(Float64(a + a) / g))); else tmp = exp(Float64(Float64(log(g) * 0.3333333333333333) - Float64(log(Float64(a + a)) * 0.3333333333333333))); end return tmp end
code[g_, a_] := Block[{t$95$0 = N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[t$95$0, 4e-104], N[Exp[N[(N[Log[N[(0.5 * g), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333 + N[(-0.3333333333333333 * N[Log[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 1e+103], N[Power[N[(1.0 / N[(N[(a + a), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[Exp[N[(N[(N[Log[g], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - N[(N[Log[N[(a + a), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{g}{2 \cdot a}}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-104}:\\
\;\;\;\;e^{\mathsf{fma}\left(\log \left(0.5 \cdot g\right), 0.3333333333333333, -0.3333333333333333 \cdot \log a\right)}\\
\mathbf{elif}\;t\_0 \leq 10^{+103}:\\
\;\;\;\;\sqrt[3]{\frac{1}{\frac{a + a}{g}}}\\
\mathbf{else}:\\
\;\;\;\;e^{\log g \cdot 0.3333333333333333 - \log \left(a + a\right) \cdot 0.3333333333333333}\\
\end{array}
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 3.99999999999999971e-104Initial program 76.6%
lift-cbrt.f64N/A
pow1/3N/A
pow-to-expN/A
lower-unsound-exp.f64N/A
lower-unsound-*.f64N/A
lower-unsound-log.f6435.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6435.9
Applied rewrites35.9%
lift-log.f64N/A
lift-/.f64N/A
mult-flipN/A
lift-+.f64N/A
count-2N/A
associate-/r*N/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
lift-*.f64N/A
log-divN/A
lower-unsound--.f64N/A
lower-unsound-log.f64N/A
lower-unsound-log.f6422.6
Applied rewrites22.6%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
neg-logN/A
log-pow-revN/A
pow1/3N/A
inv-powN/A
cbrt-powN/A
metadata-evalN/A
metadata-evalN/A
log-powN/A
lower-unsound-log.f64N/A
lower-unsound-*.f64N/A
metadata-eval22.6
Applied rewrites22.6%
if 3.99999999999999971e-104 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 1e103Initial program 76.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6476.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.0
Applied rewrites76.0%
if 1e103 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 76.6%
lift-cbrt.f64N/A
pow1/3N/A
pow-to-expN/A
lower-unsound-exp.f64N/A
lower-unsound-*.f64N/A
lower-unsound-log.f6435.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6435.9
Applied rewrites35.9%
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lower-unsound--.f64N/A
lower-unsound-log.f64N/A
lower-unsound-log.f6422.6
Applied rewrites22.6%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
fp-cancel-sub-signN/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6422.6
Applied rewrites22.6%
(FPCore (g a)
:precision binary64
(let* ((t_0 (cbrt (/ g (* 2.0 a))))
(t_1
(exp
(fma
(log (* 0.5 g))
0.3333333333333333
(* -0.3333333333333333 (log a))))))
(if (<= t_0 4e-104)
t_1
(if (<= t_0 1e+103) (cbrt (/ 1.0 (/ (+ a a) g))) t_1))))
double code(double g, double a) {
double t_0 = cbrt((g / (2.0 * a)));
double t_1 = exp(fma(log((0.5 * g)), 0.3333333333333333, (-0.3333333333333333 * log(a))));
double tmp;
if (t_0 <= 4e-104) {
tmp = t_1;
} else if (t_0 <= 1e+103) {
tmp = cbrt((1.0 / ((a + a) / g)));
} else {
tmp = t_1;
}
return tmp;
}
function code(g, a) t_0 = cbrt(Float64(g / Float64(2.0 * a))) t_1 = exp(fma(log(Float64(0.5 * g)), 0.3333333333333333, Float64(-0.3333333333333333 * log(a)))) tmp = 0.0 if (t_0 <= 4e-104) tmp = t_1; elseif (t_0 <= 1e+103) tmp = cbrt(Float64(1.0 / Float64(Float64(a + a) / g))); else tmp = t_1; end return tmp end
code[g_, a_] := Block[{t$95$0 = N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[Log[N[(0.5 * g), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333 + N[(-0.3333333333333333 * N[Log[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 4e-104], t$95$1, If[LessEqual[t$95$0, 1e+103], N[Power[N[(1.0 / N[(N[(a + a), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{g}{2 \cdot a}}\\
t_1 := e^{\mathsf{fma}\left(\log \left(0.5 \cdot g\right), 0.3333333333333333, -0.3333333333333333 \cdot \log a\right)}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-104}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{+103}:\\
\;\;\;\;\sqrt[3]{\frac{1}{\frac{a + a}{g}}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 3.99999999999999971e-104 or 1e103 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 76.6%
lift-cbrt.f64N/A
pow1/3N/A
pow-to-expN/A
lower-unsound-exp.f64N/A
lower-unsound-*.f64N/A
lower-unsound-log.f6435.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6435.9
Applied rewrites35.9%
lift-log.f64N/A
lift-/.f64N/A
mult-flipN/A
lift-+.f64N/A
count-2N/A
associate-/r*N/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
lift-*.f64N/A
log-divN/A
lower-unsound--.f64N/A
lower-unsound-log.f64N/A
lower-unsound-log.f6422.6
Applied rewrites22.6%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
neg-logN/A
log-pow-revN/A
pow1/3N/A
inv-powN/A
cbrt-powN/A
metadata-evalN/A
metadata-evalN/A
log-powN/A
lower-unsound-log.f64N/A
lower-unsound-*.f64N/A
metadata-eval22.6
Applied rewrites22.6%
if 3.99999999999999971e-104 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 1e103Initial program 76.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6476.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.0
Applied rewrites76.0%
(FPCore (g a)
:precision binary64
(let* ((t_0 (cbrt (/ g (* 2.0 a))))
(t_1 (exp (* (- (log (* 0.5 g)) (log a)) 0.3333333333333333))))
(if (<= t_0 4e-104)
t_1
(if (<= t_0 1e+103) (cbrt (/ 1.0 (/ (+ a a) g))) t_1))))
double code(double g, double a) {
double t_0 = cbrt((g / (2.0 * a)));
double t_1 = exp(((log((0.5 * g)) - log(a)) * 0.3333333333333333));
double tmp;
if (t_0 <= 4e-104) {
tmp = t_1;
} else if (t_0 <= 1e+103) {
tmp = cbrt((1.0 / ((a + a) / g)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double g, double a) {
double t_0 = Math.cbrt((g / (2.0 * a)));
double t_1 = Math.exp(((Math.log((0.5 * g)) - Math.log(a)) * 0.3333333333333333));
double tmp;
if (t_0 <= 4e-104) {
tmp = t_1;
} else if (t_0 <= 1e+103) {
tmp = Math.cbrt((1.0 / ((a + a) / g)));
} else {
tmp = t_1;
}
return tmp;
}
function code(g, a) t_0 = cbrt(Float64(g / Float64(2.0 * a))) t_1 = exp(Float64(Float64(log(Float64(0.5 * g)) - log(a)) * 0.3333333333333333)) tmp = 0.0 if (t_0 <= 4e-104) tmp = t_1; elseif (t_0 <= 1e+103) tmp = cbrt(Float64(1.0 / Float64(Float64(a + a) / g))); else tmp = t_1; end return tmp end
code[g_, a_] := Block[{t$95$0 = N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[Log[N[(0.5 * g), $MachinePrecision]], $MachinePrecision] - N[Log[a], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 4e-104], t$95$1, If[LessEqual[t$95$0, 1e+103], N[Power[N[(1.0 / N[(N[(a + a), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{g}{2 \cdot a}}\\
t_1 := e^{\left(\log \left(0.5 \cdot g\right) - \log a\right) \cdot 0.3333333333333333}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-104}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{+103}:\\
\;\;\;\;\sqrt[3]{\frac{1}{\frac{a + a}{g}}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 3.99999999999999971e-104 or 1e103 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 76.6%
lift-cbrt.f64N/A
pow1/3N/A
pow-to-expN/A
lower-unsound-exp.f64N/A
lower-unsound-*.f64N/A
lower-unsound-log.f6435.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6435.9
Applied rewrites35.9%
lift-log.f64N/A
lift-/.f64N/A
mult-flipN/A
lift-+.f64N/A
count-2N/A
associate-/r*N/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
lift-*.f64N/A
log-divN/A
lower-unsound--.f64N/A
lower-unsound-log.f64N/A
lower-unsound-log.f6422.6
Applied rewrites22.6%
if 3.99999999999999971e-104 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 1e103Initial program 76.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6476.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.0
Applied rewrites76.0%
(FPCore (g a)
:precision binary64
(let* ((t_0 (cbrt (/ g (* 2.0 a))))
(t_1 (exp (* (- (log g) (log (+ a a))) 0.3333333333333333))))
(if (<= t_0 4e-104)
t_1
(if (<= t_0 1e+103) (cbrt (/ 1.0 (/ (+ a a) g))) t_1))))
double code(double g, double a) {
double t_0 = cbrt((g / (2.0 * a)));
double t_1 = exp(((log(g) - log((a + a))) * 0.3333333333333333));
double tmp;
if (t_0 <= 4e-104) {
tmp = t_1;
} else if (t_0 <= 1e+103) {
tmp = cbrt((1.0 / ((a + a) / g)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double g, double a) {
double t_0 = Math.cbrt((g / (2.0 * a)));
double t_1 = Math.exp(((Math.log(g) - Math.log((a + a))) * 0.3333333333333333));
double tmp;
if (t_0 <= 4e-104) {
tmp = t_1;
} else if (t_0 <= 1e+103) {
tmp = Math.cbrt((1.0 / ((a + a) / g)));
} else {
tmp = t_1;
}
return tmp;
}
function code(g, a) t_0 = cbrt(Float64(g / Float64(2.0 * a))) t_1 = exp(Float64(Float64(log(g) - log(Float64(a + a))) * 0.3333333333333333)) tmp = 0.0 if (t_0 <= 4e-104) tmp = t_1; elseif (t_0 <= 1e+103) tmp = cbrt(Float64(1.0 / Float64(Float64(a + a) / g))); else tmp = t_1; end return tmp end
code[g_, a_] := Block[{t$95$0 = N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[Log[g], $MachinePrecision] - N[Log[N[(a + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 4e-104], t$95$1, If[LessEqual[t$95$0, 1e+103], N[Power[N[(1.0 / N[(N[(a + a), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{g}{2 \cdot a}}\\
t_1 := e^{\left(\log g - \log \left(a + a\right)\right) \cdot 0.3333333333333333}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-104}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{+103}:\\
\;\;\;\;\sqrt[3]{\frac{1}{\frac{a + a}{g}}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 3.99999999999999971e-104 or 1e103 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 76.6%
lift-cbrt.f64N/A
pow1/3N/A
pow-to-expN/A
lower-unsound-exp.f64N/A
lower-unsound-*.f64N/A
lower-unsound-log.f6435.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6435.9
Applied rewrites35.9%
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lower-unsound--.f64N/A
lower-unsound-log.f64N/A
lower-unsound-log.f6422.6
Applied rewrites22.6%
if 3.99999999999999971e-104 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 1e103Initial program 76.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6476.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.0
Applied rewrites76.0%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (/ (+ a a) g))))
double code(double g, double a) {
return 1.0 / cbrt(((a + a) / g));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((a + a) / g));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(a + a) / g))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(a + a), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{a + a}{g}}}
\end{array}
Initial program 76.6%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-/.f64N/A
pow1/3N/A
pow-to-expN/A
lift-/.f64N/A
lift-+.f64N/A
count-2N/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
mult-flip-revN/A
metadata-evalN/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
lift-*.f64N/A
pow-to-expN/A
pow1/3N/A
cbrt-undivN/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
Applied rewrites98.6%
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-unprodN/A
metadata-evalN/A
cbrt-unprodN/A
lift-+.f64N/A
count-2N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
metadata-evalN/A
mult-flip-revN/A
*-rgt-identityN/A
lift-cbrt.f64N/A
cbrt-divN/A
associate-/r*N/A
count-2N/A
lift-+.f64N/A
lift-/.f64N/A
rem-exp-logN/A
Applied rewrites76.6%
(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 2025164
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))