
(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 6 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 (let* ((t_0 (pow (/ 1.0 (fabs g)) (/ 1.0 2.0)))) (* (copysign 1.0 g) (/ (cbrt (/ 1.0 (* t_0 t_0))) (cbrt (+ a a))))))
double code(double g, double a) {
double t_0 = pow((1.0 / fabs(g)), (1.0 / 2.0));
return copysign(1.0, g) * (cbrt((1.0 / (t_0 * t_0))) / cbrt((a + a)));
}
public static double code(double g, double a) {
double t_0 = Math.pow((1.0 / Math.abs(g)), (1.0 / 2.0));
return Math.copySign(1.0, g) * (Math.cbrt((1.0 / (t_0 * t_0))) / Math.cbrt((a + a)));
}
function code(g, a) t_0 = Float64(1.0 / abs(g)) ^ Float64(1.0 / 2.0) return Float64(copysign(1.0, g) * Float64(cbrt(Float64(1.0 / Float64(t_0 * t_0))) / cbrt(Float64(a + a)))) end
code[g_, a_] := Block[{t$95$0 = N[Power[N[(1.0 / N[Abs[g], $MachinePrecision]), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[g]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[Power[N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(a + a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := {\left(\frac{1}{\left|g\right|}\right)}^{\left(\frac{1}{2}\right)}\\
\mathsf{copysign}\left(1, g\right) \cdot \frac{\sqrt[3]{\frac{1}{t\_0 \cdot t\_0}}}{\sqrt[3]{a + a}}
\end{array}
Initial program 76.2%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.6%
Applied rewrites98.6%
lift-cbrt.f64N/A
pow1/3N/A
metadata-evalN/A
metadata-evalN/A
pow-flipN/A
metadata-evalN/A
metadata-evalN/A
cbrt-powN/A
inv-powN/A
metadata-evalN/A
cbrt-undivN/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-/.f6498.6%
Applied rewrites98.6%
unpow1N/A
sqr-powN/A
lower-unsound-*.f64N/A
lower-unsound-pow.f64N/A
lower-unsound-/.f64N/A
lower-unsound-pow.f64N/A
lower-unsound-/.f6448.9%
Applied rewrites48.9%
(FPCore (g a) :precision binary64 (/ (cbrt (/ 1.0 (/ 1.0 g))) (cbrt (+ a a))))
double code(double g, double a) {
return cbrt((1.0 / (1.0 / g))) / cbrt((a + a));
}
public static double code(double g, double a) {
return Math.cbrt((1.0 / (1.0 / g))) / Math.cbrt((a + a));
}
function code(g, a) return Float64(cbrt(Float64(1.0 / Float64(1.0 / g))) / cbrt(Float64(a + a))) end
code[g_, a_] := N[(N[Power[N[(1.0 / N[(1.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(a + a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt[3]{\frac{1}{\frac{1}{g}}}}{\sqrt[3]{a + a}}
Initial program 76.2%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.6%
Applied rewrites98.6%
lift-cbrt.f64N/A
pow1/3N/A
metadata-evalN/A
metadata-evalN/A
pow-flipN/A
metadata-evalN/A
metadata-evalN/A
cbrt-powN/A
inv-powN/A
metadata-evalN/A
cbrt-undivN/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-/.f6498.6%
Applied rewrites98.6%
(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.2%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.6%
Applied rewrites98.6%
(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 76.2%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.6%
Applied rewrites98.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f32N/A
lower-/.f32N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-divN/A
lift-/.f64N/A
lower-unsound-/.f64N/A
lower-cbrt.f6476.2%
Applied rewrites76.2%
(FPCore (g a) :precision binary64 (cbrt (/ (* 0.5 g) a)))
double code(double g, double a) {
return cbrt(((0.5 * g) / a));
}
public static double code(double g, double a) {
return Math.cbrt(((0.5 * g) / a));
}
function code(g, a) return cbrt(Float64(Float64(0.5 * g) / a)) end
code[g_, a_] := N[Power[N[(N[(0.5 * g), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]
\sqrt[3]{\frac{0.5 \cdot g}{a}}
Initial program 76.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval76.2%
Applied rewrites76.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]
\sqrt[3]{\frac{g}{a + a}}
Initial program 76.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.2%
Applied rewrites76.2%
herbie shell --seed 2025214
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))