
(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 (/ 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]
\frac{\sqrt[3]{\frac{1}{a}}}{\sqrt[3]{\frac{2}{g}}}
Initial program 76.1%
lift-cbrt.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
cbrt-prodN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7%
Applied rewrites98.7%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
associate-/r*N/A
count-2N/A
lift-+.f64N/A
lift-cbrt.f64N/A
cbrt-prodN/A
associate-/r/N/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
mult-flipN/A
associate-/r*N/A
lift-+.f64N/A
count-2N/A
associate-/r*N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
Applied rewrites98.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
metadata-evalN/A
lower-/.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]
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g}
Initial program 76.1%
lift-cbrt.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
cbrt-prodN/A
lower-*.f64N/A
lower-cbrt.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7%
Applied rewrites98.7%
(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 76.1%
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 (cbrt (* (* (/ g (+ a a)) (/ 1.0 g)) g)))
double code(double g, double a) {
return cbrt((((g / (a + a)) * (1.0 / g)) * g));
}
public static double code(double g, double a) {
return Math.cbrt((((g / (a + a)) * (1.0 / g)) * g));
}
function code(g, a) return cbrt(Float64(Float64(Float64(g / Float64(a + a)) * Float64(1.0 / g)) * g)) end
code[g_, a_] := N[Power[N[(N[(N[(g / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[(1.0 / g), $MachinePrecision]), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision]
\sqrt[3]{\left(\frac{g}{a + a} \cdot \frac{1}{g}\right) \cdot g}
Initial program 76.1%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval76.1%
Applied rewrites76.1%
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
count-2N/A
lift-+.f64N/A
*-inversesN/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6476.1%
Applied rewrites76.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]
\sqrt[3]{\frac{g}{a + a}}
Initial program 76.1%
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.1%
Applied rewrites76.1%
herbie shell --seed 2025185
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))