
(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 3 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 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 81.9%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (if (<= g 1.3e-304) (cbrt (/ g (+ a a))) (/ (pow g 0.3333333333333333) (cbrt (+ a a)))))
double code(double g, double a) {
double tmp;
if (g <= 1.3e-304) {
tmp = cbrt((g / (a + a)));
} else {
tmp = pow(g, 0.3333333333333333) / cbrt((a + a));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if (g <= 1.3e-304) {
tmp = Math.cbrt((g / (a + a)));
} else {
tmp = Math.pow(g, 0.3333333333333333) / Math.cbrt((a + a));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (g <= 1.3e-304) tmp = cbrt(Float64(g / Float64(a + a))); else tmp = Float64((g ^ 0.3333333333333333) / cbrt(Float64(a + a))); end return tmp end
code[g_, a_] := If[LessEqual[g, 1.3e-304], N[Power[N[(g / N[(a + a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[g, 0.3333333333333333], $MachinePrecision] / N[Power[N[(a + a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;g \leq 1.3 \cdot 10^{-304}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a + a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{g}^{0.3333333333333333}}{\sqrt[3]{a + a}}\\
\end{array}
\end{array}
if g < 1.29999999999999998e-304Initial program 86.1%
lift-*.f64N/A
count-2-revN/A
lower-+.f6486.1
Applied rewrites86.1%
if 1.29999999999999998e-304 < g Initial program 77.0%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
lift-cbrt.f64N/A
pow1/3N/A
lower-pow.f6492.1
Applied rewrites92.1%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6492.1
Applied rewrites92.1%
(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 81.9%
lift-*.f64N/A
count-2-revN/A
lower-+.f6481.9
Applied rewrites81.9%
herbie shell --seed 2025083
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))