
(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 8 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 (pow (/ (cbrt (/ -1.0 g)) (cbrt (/ -0.5 a))) -1.0))
double code(double g, double a) {
return pow((cbrt((-1.0 / g)) / cbrt((-0.5 / a))), -1.0);
}
public static double code(double g, double a) {
return Math.pow((Math.cbrt((-1.0 / g)) / Math.cbrt((-0.5 / a))), -1.0);
}
function code(g, a) return Float64(cbrt(Float64(-1.0 / g)) / cbrt(Float64(-0.5 / a))) ^ -1.0 end
code[g_, a_] := N[Power[N[(N[Power[N[(-1.0 / g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(-0.5 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{\sqrt[3]{\frac{-1}{g}}}{\sqrt[3]{\frac{-0.5}{a}}}\right)}^{-1}
\end{array}
Initial program 80.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
cbrt-divN/A
pow1/3N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-/.f6479.9
Applied rewrites79.9%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (/ (cbrt (/ 0.5 (/ -1.0 g))) (cbrt (- a))))
double code(double g, double a) {
return cbrt((0.5 / (-1.0 / g))) / cbrt(-a);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 / (-1.0 / g))) / Math.cbrt(-a);
}
function code(g, a) return Float64(cbrt(Float64(0.5 / Float64(-1.0 / g))) / cbrt(Float64(-a))) end
code[g_, a_] := N[(N[Power[N[(0.5 / N[(-1.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[(-a), 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{\frac{0.5}{\frac{-1}{g}}}}{\sqrt[3]{-a}}
\end{array}
Initial program 80.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/A
sqr-powN/A
pow-prod-downN/A
sqr-negN/A
remove-double-negN/A
remove-double-negN/A
pow-prod-downN/A
sqr-powN/A
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-*.f64N/A
metadata-evalN/A
associate-/r/N/A
unpow-1N/A
lift-pow.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
unpow-1N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6498.7
Applied rewrites98.7%
(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 80.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/A
sqr-powN/A
pow-prod-downN/A
sqr-negN/A
remove-double-negN/A
remove-double-negN/A
pow-prod-downN/A
sqr-powN/A
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
frac-2negN/A
lift-*.f64N/A
distribute-rgt-neg-outN/A
lift-neg.f64N/A
cbrt-divN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (* (cbrt (/ 0.5 a)) (cbrt g)))
double code(double g, double a) {
return cbrt((0.5 / a)) * cbrt(g);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 / a)) * Math.cbrt(g);
}
function code(g, a) return Float64(cbrt(Float64(0.5 / a)) * cbrt(g)) end
code[g_, a_] := N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g}
\end{array}
Initial program 80.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/A
sqr-powN/A
pow-prod-downN/A
sqr-negN/A
remove-double-negN/A
remove-double-negN/A
pow-prod-downN/A
sqr-powN/A
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
frac-2negN/A
lift-*.f64N/A
distribute-rgt-neg-outN/A
lift-neg.f64N/A
cbrt-divN/A
lift-neg.f64N/A
remove-double-negN/A
cbrt-divN/A
associate-*l/N/A
lift-/.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
cbrt-prodN/A
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (if (<= (/ g (* 2.0 a)) (- INFINITY)) (/ (cbrt (* (* (* a a) 0.5) g)) a) (cbrt (/ g (/ -1.0 (/ -0.5 a))))))
double code(double g, double a) {
double tmp;
if ((g / (2.0 * a)) <= -((double) INFINITY)) {
tmp = cbrt((((a * a) * 0.5) * g)) / a;
} else {
tmp = cbrt((g / (-1.0 / (-0.5 / a))));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((g / (2.0 * a)) <= -Double.POSITIVE_INFINITY) {
tmp = Math.cbrt((((a * a) * 0.5) * g)) / a;
} else {
tmp = Math.cbrt((g / (-1.0 / (-0.5 / a))));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(g / Float64(2.0 * a)) <= Float64(-Inf)) tmp = Float64(cbrt(Float64(Float64(Float64(a * a) * 0.5) * g)) / a); else tmp = cbrt(Float64(g / Float64(-1.0 / Float64(-0.5 / a)))); end return tmp end
code[g_, a_] := If[LessEqual[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[Power[N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision] / a), $MachinePrecision], N[Power[N[(g / N[(-1.0 / N[(-0.5 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{g}{2 \cdot a} \leq -\infty:\\
\;\;\;\;\frac{\sqrt[3]{\left(\left(a \cdot a\right) \cdot 0.5\right) \cdot g}}{a}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{g}{\frac{-1}{\frac{-0.5}{a}}}}\\
\end{array}
\end{array}
if (/.f64 g (*.f64 #s(literal 2 binary64) a)) < -inf.0Initial program 4.4%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
cbrt-divN/A
pow1/3N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-/.f644.4
Applied rewrites4.4%
Applied rewrites98.5%
Applied rewrites50.7%
if -inf.0 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) Initial program 85.8%
remove-double-divN/A
frac-2negN/A
metadata-evalN/A
distribute-frac-neg2N/A
inv-powN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
sqr-negN/A
remove-double-negN/A
remove-double-negN/A
pow-prod-downN/A
pow-sqrN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
Applied rewrites85.8%
(FPCore (g a) :precision binary64 (let* ((t_0 (/ g (* 2.0 a)))) (if (<= t_0 (- INFINITY)) (/ (cbrt (* (* (* a a) 0.5) g)) a) (cbrt t_0))))
double code(double g, double a) {
double t_0 = g / (2.0 * a);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = cbrt((((a * a) * 0.5) * g)) / a;
} else {
tmp = cbrt(t_0);
}
return tmp;
}
public static double code(double g, double a) {
double t_0 = g / (2.0 * a);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = Math.cbrt((((a * a) * 0.5) * g)) / a;
} else {
tmp = Math.cbrt(t_0);
}
return tmp;
}
function code(g, a) t_0 = Float64(g / Float64(2.0 * a)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(cbrt(Float64(Float64(Float64(a * a) * 0.5) * g)) / a); else tmp = cbrt(t_0); end return tmp end
code[g_, a_] := Block[{t$95$0 = N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[Power[N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision] / a), $MachinePrecision], N[Power[t$95$0, 1/3], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{g}{2 \cdot a}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\frac{\sqrt[3]{\left(\left(a \cdot a\right) \cdot 0.5\right) \cdot g}}{a}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{t\_0}\\
\end{array}
\end{array}
if (/.f64 g (*.f64 #s(literal 2 binary64) a)) < -inf.0Initial program 4.4%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
cbrt-divN/A
pow1/3N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
pow1/3N/A
lower-cbrt.f64N/A
lower-/.f644.4
Applied rewrites4.4%
Applied rewrites98.5%
Applied rewrites50.7%
if -inf.0 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) Initial program 85.8%
(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}
Initial program 80.7%
(FPCore (g a) :precision binary64 (cbrt (* (/ 0.5 a) g)))
double code(double g, double a) {
return cbrt(((0.5 / a) * g));
}
public static double code(double g, double a) {
return Math.cbrt(((0.5 / a) * g));
}
function code(g, a) return cbrt(Float64(Float64(0.5 / a) * g)) end
code[g_, a_] := N[Power[N[(N[(0.5 / a), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot g}
\end{array}
Initial program 80.7%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/A
sqr-powN/A
pow-prod-downN/A
sqr-negN/A
remove-double-negN/A
remove-double-negN/A
pow-prod-downN/A
sqr-powN/A
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
metadata-evalN/A
associate-/r/N/A
unpow-1N/A
lift-pow.f64N/A
lift-cbrt.f64N/A
cbrt-divN/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cbrt.f6479.9
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow-1N/A
un-div-invN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites80.7%
herbie shell --seed 2024323
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))