
(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]
\sqrt[3]{\frac{g}{2 \cdot a}}
Herbie found 5 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]
\sqrt[3]{\frac{g}{2 \cdot a}}
(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]
\frac{\sqrt[3]{g}}{\sqrt[3]{a + a}}
Initial program 75.4%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.7%
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (/ (+ a a) g))))
double code(double g, double a) {
return 1.0 / cbrt(((a + a) / g));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((a + a) / g));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(a + a) / g))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(a + a), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt[3]{\frac{a + a}{g}}}
Initial program 75.4%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.7%
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-+.f64N/A
count-2N/A
cbrt-prodN/A
lift-cbrt.f64N/A
associate-/r*N/A
lift-cbrt.f64N/A
cbrt-divN/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-cbrt.f64N/A
div-flip-revN/A
lift-/.f64N/A
lift-/.f6498.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
div-flip-revN/A
lift-/.f64N/A
Applied rewrites75.1%
(FPCore (g a) :precision binary64 (/ 0.7937005259840998 (cbrt (/ a g))))
double code(double g, double a) {
return 0.7937005259840998 / cbrt((a / g));
}
public static double code(double g, double a) {
return 0.7937005259840998 / Math.cbrt((a / g));
}
function code(g, a) return Float64(0.7937005259840998 / cbrt(Float64(a / g))) end
code[g_, a_] := N[(0.7937005259840998 / N[Power[N[(a / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\frac{0.7937005259840998}{\sqrt[3]{\frac{a}{g}}}
Initial program 75.4%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
mult-flipN/A
cbrt-prodN/A
cbrt-undivN/A
lower-*.f64N/A
cbrt-undivN/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
metadata-eval75.3%
Applied rewrites75.3%
Evaluated real constant75.3%
lift-*.f64N/A
*-commutativeN/A
lift-cbrt.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-/.f64N/A
cbrt-undivN/A
metadata-evalN/A
lift-cbrt.f64N/A
mult-flip-revN/A
lower-/.f6475.0%
Applied rewrites75.0%
(FPCore (g a) :precision binary64 (* (cbrt (/ g a)) 0.7937005259840998))
double code(double g, double a) {
return cbrt((g / a)) * 0.7937005259840998;
}
public static double code(double g, double a) {
return Math.cbrt((g / a)) * 0.7937005259840998;
}
function code(g, a) return Float64(cbrt(Float64(g / a)) * 0.7937005259840998) end
code[g_, a_] := N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * 0.7937005259840998), $MachinePrecision]
\sqrt[3]{\frac{g}{a}} \cdot 0.7937005259840998
Initial program 75.4%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
mult-flipN/A
cbrt-prodN/A
cbrt-undivN/A
lower-*.f64N/A
cbrt-undivN/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
metadata-eval75.3%
Applied rewrites75.3%
Evaluated real constant75.3%
(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]
\sqrt[3]{\frac{g}{a + a}}
Initial program 75.4%
lift-*.f64N/A
count-2-revN/A
lower-+.f6475.4%
Applied rewrites75.4%
herbie shell --seed 2025191
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))