
(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}
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]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{2 \cdot a}}
\end{array}
(FPCore (g a) :precision binary64 (/ (- (* (cbrt -0.5) (cbrt g))) (cbrt a)))
double code(double g, double a) {
return -(cbrt(-0.5) * cbrt(g)) / cbrt(a);
}
public static double code(double g, double a) {
return -(Math.cbrt(-0.5) * Math.cbrt(g)) / Math.cbrt(a);
}
function code(g, a) return Float64(Float64(-Float64(cbrt(-0.5) * cbrt(g))) / cbrt(a)) end
code[g_, a_] := N[((-N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]) / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-\sqrt[3]{-0.5} \cdot \sqrt[3]{g}}{\sqrt[3]{a}}
\end{array}
Initial program 76.1%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
cbrt-divN/A
lower-/.f64N/A
lift-cbrt.f64N/A
lower-cbrt.f6498.2
Applied rewrites98.2%
lift-cbrt.f64N/A
pow1/3N/A
lower-pow.f6498.7
Applied rewrites98.7%
Taylor expanded in g around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
cbrt-undivN/A
metadata-evalN/A
lower-cbrt.f64N/A
lift-cbrt.f6498.6
Applied rewrites98.6%
(FPCore (g a) :precision binary64 (/ (cbrt g) (* (cbrt a) (pow 2.0 0.3333333333333333))))
double code(double g, double a) {
return cbrt(g) / (cbrt(a) * pow(2.0, 0.3333333333333333));
}
public static double code(double g, double a) {
return Math.cbrt(g) / (Math.cbrt(a) * Math.pow(2.0, 0.3333333333333333));
}
function code(g, a) return Float64(cbrt(g) / Float64(cbrt(a) * (2.0 ^ 0.3333333333333333))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[(N[Power[a, 1/3], $MachinePrecision] * N[Power[2.0, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{a} \cdot {2}^{0.3333333333333333}}
\end{array}
Initial program 76.1%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
count-2-revN/A
lower-+.f6498.7
Applied rewrites98.7%
lift-+.f64N/A
lift-cbrt.f64N/A
count-2-revN/A
*-commutativeN/A
cbrt-unprodN/A
lower-*.f64N/A
lift-cbrt.f64N/A
lower-cbrt.f6498.2
Applied rewrites98.2%
lift-cbrt.f64N/A
pow1/3N/A
lower-pow.f6498.7
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (/ (cbrt (* 0.5 g)) (cbrt a)))
double code(double g, double a) {
return cbrt((0.5 * g)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 * g)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(0.5 * g)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{0.5 \cdot g}}{\sqrt[3]{a}}
\end{array}
Initial program 76.1%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
Taylor expanded in g around 0
lower-*.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]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{a + a}}
\end{array}
Initial program 76.1%
lift-cbrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f64N/A
count-2-revN/A
lower-+.f6498.7
Applied rewrites98.7%
(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(0.5 * Float64(g / a))) end
code[g_, a_] := N[Power[N[(0.5 * N[(g / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{0.5 \cdot \frac{g}{a}}
\end{array}
Initial program 76.1%
Taylor expanded in g around 0
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]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{a + a}}
\end{array}
Initial program 76.1%
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.1
Applied rewrites76.1%
herbie shell --seed 2025130
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))