
(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%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
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 rewrites98.7%
Applied rewrites98.8%
(FPCore (g a)
:precision binary64
(let* ((t_0 (/ g (* a 2.0))) (t_1 (/ (cbrt (* a (* a (* g 0.5)))) a)))
(if (<= t_0 -1e+255)
t_1
(if (<= t_0 -2e-302)
(/ 1.0 (cbrt (/ a (* g 0.5))))
(if (<= t_0 0.0)
t_1
(if (<= t_0 2e+277)
(cbrt (* (/ g a) (* (sqrt 0.5) (sqrt 0.5))))
t_1))))))
double code(double g, double a) {
double t_0 = g / (a * 2.0);
double t_1 = cbrt((a * (a * (g * 0.5)))) / a;
double tmp;
if (t_0 <= -1e+255) {
tmp = t_1;
} else if (t_0 <= -2e-302) {
tmp = 1.0 / cbrt((a / (g * 0.5)));
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 2e+277) {
tmp = cbrt(((g / a) * (sqrt(0.5) * sqrt(0.5))));
} 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((a * (a * (g * 0.5)))) / a;
double tmp;
if (t_0 <= -1e+255) {
tmp = t_1;
} else if (t_0 <= -2e-302) {
tmp = 1.0 / Math.cbrt((a / (g * 0.5)));
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 2e+277) {
tmp = Math.cbrt(((g / a) * (Math.sqrt(0.5) * Math.sqrt(0.5))));
} else {
tmp = t_1;
}
return tmp;
}
function code(g, a) t_0 = Float64(g / Float64(a * 2.0)) t_1 = Float64(cbrt(Float64(a * Float64(a * Float64(g * 0.5)))) / a) tmp = 0.0 if (t_0 <= -1e+255) tmp = t_1; elseif (t_0 <= -2e-302) tmp = Float64(1.0 / cbrt(Float64(a / Float64(g * 0.5)))); elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 2e+277) tmp = cbrt(Float64(Float64(g / a) * Float64(sqrt(0.5) * sqrt(0.5)))); 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[(a * N[(a * N[(g * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+255], t$95$1, If[LessEqual[t$95$0, -2e-302], N[(1.0 / N[Power[N[(a / N[(g * 0.5), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 2e+277], N[Power[N[(N[(g / a), $MachinePrecision] * N[(N[Sqrt[0.5], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $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]{a \cdot \left(a \cdot \left(g \cdot 0.5\right)\right)}}{a}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+255}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -2 \cdot 10^{-302}:\\
\;\;\;\;\frac{1}{\sqrt[3]{\frac{a}{g \cdot 0.5}}}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+277}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a} \cdot \left(\sqrt{0.5} \cdot \sqrt{0.5}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 g (*.f64 #s(literal 2 binary64) a)) < -9.99999999999999988e254 or -1.9999999999999999e-302 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) < 0.0 or 2.00000000000000001e277 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) Initial program 18.8%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
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.6
Applied rewrites98.6%
Applied rewrites98.6%
Applied rewrites66.2%
if -9.99999999999999988e254 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) < -1.9999999999999999e-302Initial program 99.1%
lift-cbrt.f64N/A
lift-/.f64N/A
clear-numN/A
cbrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-cbrt.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/r*N/A
clear-numN/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval99.0
Applied rewrites99.0%
if 0.0 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) < 2.00000000000000001e277Initial program 98.4%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6497.3
Applied rewrites97.3%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
sqrt-pow1N/A
inv-powN/A
clear-numN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
sqrt-prodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
sqrt-pow1N/A
inv-powN/A
clear-numN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
sqrt-prodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
Applied rewrites98.3%
Final simplification89.4%
herbie shell --seed 2024219
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))