
(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 9 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 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(Float64(-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.5%
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied egg-rr98.7%
Applied egg-rr98.8%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) -4e-294) (* (cbrt (- g)) (pow (* a -2.0) -0.3333333333333333)) (* (cbrt (* g 0.5)) (pow a -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -4e-294) {
tmp = cbrt(-g) * pow((a * -2.0), -0.3333333333333333);
} else {
tmp = cbrt((g * 0.5)) * pow(a, -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -4e-294) {
tmp = Math.cbrt(-g) * Math.pow((a * -2.0), -0.3333333333333333);
} else {
tmp = Math.cbrt((g * 0.5)) * Math.pow(a, -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= -4e-294) tmp = Float64(cbrt(Float64(-g)) * (Float64(a * -2.0) ^ -0.3333333333333333)); else tmp = Float64(cbrt(Float64(g * 0.5)) * (a ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], -4e-294], N[(N[Power[(-g), 1/3], $MachinePrecision] * N[Power[N[(a * -2.0), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq -4 \cdot 10^{-294}:\\
\;\;\;\;\sqrt[3]{-g} \cdot {\left(a \cdot -2\right)}^{-0.3333333333333333}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g \cdot 0.5} \cdot {a}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -4.00000000000000007e-294Initial program 78.2%
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.8
Applied egg-rr98.8%
Applied egg-rr98.9%
lift-neg.f64N/A
lift-cbrt.f64N/A
lift-/.f64N/A
lift-cbrt.f64N/A
*-commutativeN/A
lower-*.f6498.9
lift-cbrt.f64N/A
pow1/3N/A
lift-/.f64N/A
clear-numN/A
inv-powN/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
lift-*.f64N/A
pow-powN/A
lower-pow.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval92.3
Applied egg-rr92.3%
if -4.00000000000000007e-294 < (*.f64 #s(literal 2 binary64) a) Initial program 80.7%
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.4
Applied egg-rr92.4%
Final simplification92.4%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) 4e-276) (cbrt (* (* g (sqrt 0.5)) (/ (sqrt 0.5) a))) (* (cbrt (* g 0.5)) (pow a -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 4e-276) {
tmp = cbrt(((g * sqrt(0.5)) * (sqrt(0.5) / a)));
} else {
tmp = cbrt((g * 0.5)) * pow(a, -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 4e-276) {
tmp = Math.cbrt(((g * Math.sqrt(0.5)) * (Math.sqrt(0.5) / a)));
} else {
tmp = Math.cbrt((g * 0.5)) * Math.pow(a, -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= 4e-276) tmp = cbrt(Float64(Float64(g * sqrt(0.5)) * Float64(sqrt(0.5) / a))); else tmp = Float64(cbrt(Float64(g * 0.5)) * (a ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], 4e-276], N[Power[N[(N[(g * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[0.5], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq 4 \cdot 10^{-276}:\\
\;\;\;\;\sqrt[3]{\left(g \cdot \sqrt{0.5}\right) \cdot \frac{\sqrt{0.5}}{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g \cdot 0.5} \cdot {a}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 4e-276Initial program 78.7%
associate-/l/N/A
clear-numN/A
associate-/l/N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6478.7
Applied egg-rr78.7%
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
Applied egg-rr78.7%
if 4e-276 < (*.f64 #s(literal 2 binary64) a) Initial program 80.3%
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.5
Applied egg-rr92.5%
Final simplification85.5%
(FPCore (g a) :precision binary64 (/ (cbrt (* g 0.5)) (cbrt a)))
double code(double g, double a) {
return cbrt((g * 0.5)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((g * 0.5)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(g * 0.5)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g \cdot 0.5}}{\sqrt[3]{a}}
\end{array}
Initial program 79.5%
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied egg-rr98.7%
(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 79.5%
lift-*.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a)
:precision binary64
(let* ((t_0 (/ g (* a 2.0))) (t_1 (/ (cbrt (* 0.5 (* g (* a a)))) a)))
(if (<= t_0 -2e+290)
t_1
(if (<= t_0 2e+277) (cbrt (* (* g (sqrt 0.5)) (/ (sqrt 0.5) a))) t_1))))
double code(double g, double a) {
double t_0 = g / (a * 2.0);
double t_1 = cbrt((0.5 * (g * (a * a)))) / a;
double tmp;
if (t_0 <= -2e+290) {
tmp = t_1;
} else if (t_0 <= 2e+277) {
tmp = cbrt(((g * sqrt(0.5)) * (sqrt(0.5) / a)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double g, double a) {
double t_0 = g / (a * 2.0);
double t_1 = Math.cbrt((0.5 * (g * (a * a)))) / a;
double tmp;
if (t_0 <= -2e+290) {
tmp = t_1;
} else if (t_0 <= 2e+277) {
tmp = Math.cbrt(((g * Math.sqrt(0.5)) * (Math.sqrt(0.5) / a)));
} else {
tmp = t_1;
}
return tmp;
}
function code(g, a) t_0 = Float64(g / Float64(a * 2.0)) t_1 = Float64(cbrt(Float64(0.5 * Float64(g * Float64(a * a)))) / a) tmp = 0.0 if (t_0 <= -2e+290) tmp = t_1; elseif (t_0 <= 2e+277) tmp = cbrt(Float64(Float64(g * sqrt(0.5)) * Float64(sqrt(0.5) / a))); else tmp = t_1; end return tmp end
code[g_, a_] := Block[{t$95$0 = N[(g / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(0.5 * N[(g * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+290], t$95$1, If[LessEqual[t$95$0, 2e+277], N[Power[N[(N[(g * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[0.5], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{g}{a \cdot 2}\\
t_1 := \frac{\sqrt[3]{0.5 \cdot \left(g \cdot \left(a \cdot a\right)\right)}}{a}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+290}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+277}:\\
\;\;\;\;\sqrt[3]{\left(g \cdot \sqrt{0.5}\right) \cdot \frac{\sqrt{0.5}}{a}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 g (*.f64 #s(literal 2 binary64) a)) < -2.00000000000000012e290 or 2.00000000000000001e277 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) Initial program 10.7%
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.2
Applied egg-rr98.2%
Applied egg-rr98.6%
lift-neg.f64N/A
lift-/.f64N/A
cbrt-unprodN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
metadata-evalN/A
div-invN/A
lift-neg.f64N/A
frac-2negN/A
clear-numN/A
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
inv-powN/A
metadata-evalN/A
pow-divN/A
pow2N/A
lift-*.f64N/A
cube-unmultN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
Applied egg-rr39.2%
if -2.00000000000000012e290 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) < 2.00000000000000001e277Initial program 89.0%
associate-/l/N/A
clear-numN/A
associate-/l/N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6488.5
Applied egg-rr88.5%
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
Applied egg-rr89.0%
Final simplification83.0%
(FPCore (g a) :precision binary64 (let* ((t_0 (/ g (* a 2.0))) (t_1 (/ (cbrt (* 0.5 (* g (* a a)))) a))) (if (<= t_0 (- INFINITY)) t_1 (if (<= t_0 2e+277) (cbrt t_0) t_1))))
double code(double g, double a) {
double t_0 = g / (a * 2.0);
double t_1 = cbrt((0.5 * (g * (a * a)))) / a;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= 2e+277) {
tmp = cbrt(t_0);
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double g, double a) {
double t_0 = g / (a * 2.0);
double t_1 = Math.cbrt((0.5 * (g * (a * a)))) / a;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_0 <= 2e+277) {
tmp = Math.cbrt(t_0);
} else {
tmp = t_1;
}
return tmp;
}
function code(g, a) t_0 = Float64(g / Float64(a * 2.0)) t_1 = Float64(cbrt(Float64(0.5 * Float64(g * Float64(a * a)))) / a) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= 2e+277) tmp = cbrt(t_0); else tmp = t_1; end return tmp end
code[g_, a_] := Block[{t$95$0 = N[(g / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(0.5 * N[(g * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 2e+277], N[Power[t$95$0, 1/3], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{g}{a \cdot 2}\\
t_1 := \frac{\sqrt[3]{0.5 \cdot \left(g \cdot \left(a \cdot a\right)\right)}}{a}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+277}:\\
\;\;\;\;\sqrt[3]{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 g (*.f64 #s(literal 2 binary64) a)) < -inf.0 or 2.00000000000000001e277 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) Initial program 7.7%
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.2
Applied egg-rr98.2%
Applied egg-rr98.6%
lift-neg.f64N/A
lift-/.f64N/A
cbrt-unprodN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
metadata-evalN/A
div-invN/A
lift-neg.f64N/A
frac-2negN/A
clear-numN/A
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
inv-powN/A
metadata-evalN/A
pow-divN/A
pow2N/A
lift-*.f64N/A
cube-unmultN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
Applied egg-rr37.2%
if -inf.0 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) < 2.00000000000000001e277Initial program 89.0%
Final simplification82.9%
(FPCore (g a) :precision binary64 (cbrt (/ g (* a 2.0))))
double code(double g, double a) {
return cbrt((g / (a * 2.0)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (a * 2.0)));
}
function code(g, a) return cbrt(Float64(g / Float64(a * 2.0))) end
code[g_, a_] := N[Power[N[(g / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{a \cdot 2}}
\end{array}
Initial program 79.5%
Final simplification79.5%
(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.5%
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.5
Applied egg-rr79.5%
Final simplification79.5%
herbie shell --seed 2024219
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))