
(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 4 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)) (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(Float64(cbrt(g) / cbrt(a)) / (2.0 ^ 0.3333333333333333)) end
code[g_, a_] := N[(N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] / N[Power[2.0, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\sqrt[3]{g}}{\sqrt[3]{a}}}{{2}^{0.3333333333333333}}
\end{array}
Initial program 76.0%
Applied rewrites75.3%
Applied rewrites98.2%
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.0%
Applied rewrites98.7%
Applied rewrites98.7%
(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.0%
Applied rewrites76.0%
(FPCore (g a) :precision binary64 (cbrt (* 0.5 g)))
double code(double g, double a) {
return cbrt((0.5 * g));
}
public static double code(double g, double a) {
return Math.cbrt((0.5 * g));
}
function code(g, a) return cbrt(Float64(0.5 * g)) end
code[g_, a_] := N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{0.5 \cdot g}
\end{array}
Initial program 76.0%
Applied rewrites2.3%
Taylor expanded in g around 0
Applied rewrites4.7%
herbie shell --seed 2025121
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))