
(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 2 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)) (* (cbrt -1.0) (cbrt -0.5))))
double code(double g, double a) {
return (cbrt(g) / cbrt(a)) * (cbrt(-1.0) * cbrt(-0.5));
}
public static double code(double g, double a) {
return (Math.cbrt(g) / Math.cbrt(a)) * (Math.cbrt(-1.0) * Math.cbrt(-0.5));
}
function code(g, a) return Float64(Float64(cbrt(g) / cbrt(a)) * Float64(cbrt(-1.0) * cbrt(-0.5))) end
code[g_, a_] := N[(N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[-1.0, 1/3], $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{a}} \cdot \left(\sqrt[3]{-1} \cdot \sqrt[3]{-0.5}\right)
\end{array}
Initial program 75.9%
lift-*.f64N/A
count-2-revN/A
flip3-+N/A
lower-/.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6426.5
Applied rewrites26.5%
lift-+.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
flip3-+N/A
lower-/.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites10.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6476.1
Applied rewrites76.1%
lift-/.f64N/A
lift-cbrt.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.6
Applied rewrites98.6%
(FPCore (g a) :precision binary64 (* (cbrt (/ g a)) (* (cbrt -1.0) (cbrt -0.5))))
double code(double g, double a) {
return cbrt((g / a)) * (cbrt(-1.0) * cbrt(-0.5));
}
public static double code(double g, double a) {
return Math.cbrt((g / a)) * (Math.cbrt(-1.0) * Math.cbrt(-0.5));
}
function code(g, a) return Float64(cbrt(Float64(g / a)) * Float64(cbrt(-1.0) * cbrt(-0.5))) end
code[g_, a_] := N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[(N[Power[-1.0, 1/3], $MachinePrecision] * N[Power[-0.5, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{a}} \cdot \left(\sqrt[3]{-1} \cdot \sqrt[3]{-0.5}\right)
\end{array}
Initial program 75.9%
lift-*.f64N/A
count-2-revN/A
flip3-+N/A
lower-/.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6426.5
Applied rewrites26.5%
lift-+.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
flip3-+N/A
lower-/.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites10.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6476.1
Applied rewrites76.1%
herbie shell --seed 2025065
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))