
(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 (/ (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(cbrt(g) / Float64((2.0 ^ 0.3333333333333333) * cbrt(a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[(N[Power[2.0, 0.3333333333333333], $MachinePrecision] * N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{{2}^{0.3333333333333333} \cdot \sqrt[3]{a}}
\end{array}
Initial program 77.2%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.8
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.8
Applied rewrites98.8%
lift-cbrt.f64N/A
pow1/3N/A
lift-+.f64N/A
count-2N/A
unpow-prod-downN/A
pow1/3N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-cbrt.f6498.9
Applied rewrites98.9%
(FPCore (g a) :precision binary64 (/ (cbrt (/ -1.0 a)) (cbrt (/ -2.0 g))))
double code(double g, double a) {
return cbrt((-1.0 / a)) / cbrt((-2.0 / g));
}
public static double code(double g, double a) {
return Math.cbrt((-1.0 / a)) / Math.cbrt((-2.0 / g));
}
function code(g, a) return Float64(cbrt(Float64(-1.0 / a)) / cbrt(Float64(-2.0 / g))) end
code[g_, a_] := N[(N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(-2.0 / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{\frac{-1}{a}}}{\sqrt[3]{\frac{-2}{g}}}
\end{array}
Initial program 77.2%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.8
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.8
Applied rewrites98.8%
lift-cbrt.f64N/A
pow1/3N/A
lift-+.f64N/A
count-2N/A
unpow-prod-downN/A
pow1/3N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-cbrt.f6498.9
Applied rewrites98.9%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-pow.f64N/A
unpow1/3N/A
lift-cbrt.f64N/A
cbrt-divN/A
lift-/.f64N/A
associate-/l/N/A
metadata-evalN/A
lift-cbrt.f64N/A
cbrt-divN/A
lift-/.f64N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
lower-/.f64N/A
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) 1e-298) (cbrt (* g (/ 0.5 a))) (* (cbrt g) (pow (+ a a) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= 1e-298) {
tmp = cbrt((g * (0.5 / a)));
} else {
tmp = cbrt(g) * pow((a + a), -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= 1e-298) {
tmp = Math.cbrt((g * (0.5 / a)));
} else {
tmp = Math.cbrt(g) * Math.pow((a + a), -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= 1e-298) tmp = cbrt(Float64(g * Float64(0.5 / a))); else tmp = Float64(cbrt(g) * (Float64(a + a) ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], 1e-298], N[Power[N[(g * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(a + a), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq 10^{-298}:\\
\;\;\;\;\sqrt[3]{g \cdot \frac{0.5}{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(a + a\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 9.99999999999999912e-299Initial program 78.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lift-*.f64N/A
count-2-revN/A
flip-+N/A
clear-num-revN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2-revN/A
lift-*.f64N/A
lower-*.f645.6
lift-*.f64N/A
count-2-revN/A
lower-+.f645.6
Applied rewrites5.6%
lift-+.f64N/A
flip-+N/A
clear-numN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2N/A
metadata-evalN/A
associate-/r/N/A
clear-num-revN/A
clear-numN/A
lift-/.f6478.2
Applied rewrites78.2%
if 9.99999999999999912e-299 < (*.f64 #s(literal 2 binary64) a) Initial program 76.2%
lift-cbrt.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
cbrt-prodN/A
lift-*.f64N/A
count-2-revN/A
flip-+N/A
clear-num-revN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2-revN/A
lift-*.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lower-cbrt.f646.3
Applied rewrites6.3%
lift-cbrt.f64N/A
lift-+.f64N/A
flip-+N/A
clear-numN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2N/A
metadata-evalN/A
associate-/r/N/A
clear-num-revN/A
cbrt-divN/A
metadata-evalN/A
clear-num-revN/A
associate-/r/N/A
metadata-evalN/A
count-2N/A
lift-+.f64N/A
pow1/3N/A
pow-flipN/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
metadata-eval92.1
Applied rewrites92.1%
Final simplification85.3%
(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 77.2%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.8
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.8
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (cbrt (/ (/ 1.0 a) (/ 2.0 g))))
double code(double g, double a) {
return cbrt(((1.0 / a) / (2.0 / g)));
}
public static double code(double g, double a) {
return Math.cbrt(((1.0 / a) / (2.0 / g)));
}
function code(g, a) return cbrt(Float64(Float64(1.0 / a) / Float64(2.0 / g))) end
code[g_, a_] := N[Power[N[(N[(1.0 / a), $MachinePrecision] / N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{\frac{1}{a}}{\frac{2}{g}}}
\end{array}
Initial program 77.2%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6477.2
Applied rewrites77.2%
(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 77.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lift-*.f64N/A
count-2-revN/A
flip-+N/A
clear-num-revN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2-revN/A
lift-*.f64N/A
lower-*.f645.7
lift-*.f64N/A
count-2-revN/A
lower-+.f645.7
Applied rewrites5.7%
lift-+.f64N/A
flip-+N/A
clear-numN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2N/A
metadata-evalN/A
associate-/r/N/A
clear-num-revN/A
clear-numN/A
lift-/.f6477.2
Applied rewrites77.2%
Final simplification77.2%
(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 77.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6477.2
Applied rewrites77.2%
(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]{g \cdot \left(a + a\right)}
\end{array}
Initial program 77.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lift-*.f64N/A
count-2-revN/A
flip-+N/A
clear-num-revN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2-revN/A
lift-*.f64N/A
lower-*.f645.7
lift-*.f64N/A
count-2-revN/A
lower-+.f645.7
Applied rewrites5.7%
Final simplification5.7%
herbie shell --seed 2024278
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))