
(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}
g\_m = (fabs.f64 g) g\_s = (copysign.f64 #s(literal 1 binary64) g) a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g_s g_m a_m) :precision binary64 (* a_s (* g_s (* (fabs (cbrt (* 0.5 g_m))) (cbrt (fabs (/ 1.0 a_m)))))))
g\_m = fabs(g);
g\_s = copysign(1.0, g);
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * (fabs(cbrt((0.5 * g_m))) * cbrt(fabs((1.0 / a_m)))));
}
g\_m = Math.abs(g);
g\_s = Math.copySign(1.0, g);
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * (Math.abs(Math.cbrt((0.5 * g_m))) * Math.cbrt(Math.abs((1.0 / a_m)))));
}
g\_m = abs(g) g\_s = copysign(1.0, g) a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g_s, g_m, a_m) return Float64(a_s * Float64(g_s * Float64(abs(cbrt(Float64(0.5 * g_m))) * cbrt(abs(Float64(1.0 / a_m)))))) end
g\_m = N[Abs[g], $MachinePrecision]
g\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[g]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g$95$s_, g$95$m_, a$95$m_] := N[(a$95$s * N[(g$95$s * N[(N[Abs[N[Power[N[(0.5 * g$95$m), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision] * N[Power[N[Abs[N[(1.0 / a$95$m), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
g\_m = \left|g\right|
\\
g\_s = \mathsf{copysign}\left(1, g\right)
\\
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \left(g\_s \cdot \left(\left|\sqrt[3]{0.5 \cdot g\_m}\right| \cdot \sqrt[3]{\left|\frac{1}{a\_m}\right|}\right)\right)
\end{array}
Initial program 76.8%
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%
Applied rewrites98.7%
g\_m = (fabs.f64 g) g\_s = (copysign.f64 #s(literal 1 binary64) g) a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g_s g_m a_m) :precision binary64 (* a_s (* g_s (/ 1.0 (/ (cbrt (+ a_m a_m)) (cbrt g_m))))))
g\_m = fabs(g);
g\_s = copysign(1.0, g);
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * (1.0 / (cbrt((a_m + a_m)) / cbrt(g_m))));
}
g\_m = Math.abs(g);
g\_s = Math.copySign(1.0, g);
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * (1.0 / (Math.cbrt((a_m + a_m)) / Math.cbrt(g_m))));
}
g\_m = abs(g) g\_s = copysign(1.0, g) a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g_s, g_m, a_m) return Float64(a_s * Float64(g_s * Float64(1.0 / Float64(cbrt(Float64(a_m + a_m)) / cbrt(g_m))))) end
g\_m = N[Abs[g], $MachinePrecision]
g\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[g]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g$95$s_, g$95$m_, a$95$m_] := N[(a$95$s * N[(g$95$s * N[(1.0 / N[(N[Power[N[(a$95$m + a$95$m), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[g$95$m, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
g\_m = \left|g\right|
\\
g\_s = \mathsf{copysign}\left(1, g\right)
\\
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \left(g\_s \cdot \frac{1}{\frac{\sqrt[3]{a\_m + a\_m}}{\sqrt[3]{g\_m}}}\right)
\end{array}
Initial program 76.8%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-cbrt.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
g\_m = (fabs.f64 g) g\_s = (copysign.f64 #s(literal 1 binary64) g) a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g_s g_m a_m) :precision binary64 (* a_s (* g_s (/ (cbrt (* 0.5 g_m)) (cbrt a_m)))))
g\_m = fabs(g);
g\_s = copysign(1.0, g);
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * (cbrt((0.5 * g_m)) / cbrt(a_m)));
}
g\_m = Math.abs(g);
g\_s = Math.copySign(1.0, g);
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * (Math.cbrt((0.5 * g_m)) / Math.cbrt(a_m)));
}
g\_m = abs(g) g\_s = copysign(1.0, g) a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g_s, g_m, a_m) return Float64(a_s * Float64(g_s * Float64(cbrt(Float64(0.5 * g_m)) / cbrt(a_m)))) end
g\_m = N[Abs[g], $MachinePrecision]
g\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[g]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g$95$s_, g$95$m_, a$95$m_] := N[(a$95$s * N[(g$95$s * N[(N[Power[N[(0.5 * g$95$m), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a$95$m, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
g\_m = \left|g\right|
\\
g\_s = \mathsf{copysign}\left(1, g\right)
\\
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \left(g\_s \cdot \frac{\sqrt[3]{0.5 \cdot g\_m}}{\sqrt[3]{a\_m}}\right)
\end{array}
Initial program 76.8%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied rewrites98.7%
g\_m = (fabs.f64 g) g\_s = (copysign.f64 #s(literal 1 binary64) g) a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g_s g_m a_m) :precision binary64 (* a_s (* g_s (/ (cbrt g_m) (cbrt (+ a_m a_m))))))
g\_m = fabs(g);
g\_s = copysign(1.0, g);
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * (cbrt(g_m) / cbrt((a_m + a_m))));
}
g\_m = Math.abs(g);
g\_s = Math.copySign(1.0, g);
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * (Math.cbrt(g_m) / Math.cbrt((a_m + a_m))));
}
g\_m = abs(g) g\_s = copysign(1.0, g) a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g_s, g_m, a_m) return Float64(a_s * Float64(g_s * Float64(cbrt(g_m) / cbrt(Float64(a_m + a_m))))) end
g\_m = N[Abs[g], $MachinePrecision]
g\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[g]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g$95$s_, g$95$m_, a$95$m_] := N[(a$95$s * N[(g$95$s * N[(N[Power[g$95$m, 1/3], $MachinePrecision] / N[Power[N[(a$95$m + a$95$m), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
g\_m = \left|g\right|
\\
g\_s = \mathsf{copysign}\left(1, g\right)
\\
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \left(g\_s \cdot \frac{\sqrt[3]{g\_m}}{\sqrt[3]{a\_m + a\_m}}\right)
\end{array}
Initial program 76.8%
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%
g\_m = (fabs.f64 g)
g\_s = (copysign.f64 #s(literal 1 binary64) g)
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g_s g_m a_m)
:precision binary64
(let* ((t_0 (exp (* (- (log g_m) (log (+ a_m a_m))) 0.3333333333333333)))
(t_1 (cbrt (/ g_m (* 2.0 a_m)))))
(*
a_s
(*
g_s
(if (<= t_1 2e-104)
t_0
(if (<= t_1 5e+96) (cbrt (/ g_m (+ a_m a_m))) t_0))))))g\_m = fabs(g);
g\_s = copysign(1.0, g);
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g_s, double g_m, double a_m) {
double t_0 = exp(((log(g_m) - log((a_m + a_m))) * 0.3333333333333333));
double t_1 = cbrt((g_m / (2.0 * a_m)));
double tmp;
if (t_1 <= 2e-104) {
tmp = t_0;
} else if (t_1 <= 5e+96) {
tmp = cbrt((g_m / (a_m + a_m)));
} else {
tmp = t_0;
}
return a_s * (g_s * tmp);
}
g\_m = Math.abs(g);
g\_s = Math.copySign(1.0, g);
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g_s, double g_m, double a_m) {
double t_0 = Math.exp(((Math.log(g_m) - Math.log((a_m + a_m))) * 0.3333333333333333));
double t_1 = Math.cbrt((g_m / (2.0 * a_m)));
double tmp;
if (t_1 <= 2e-104) {
tmp = t_0;
} else if (t_1 <= 5e+96) {
tmp = Math.cbrt((g_m / (a_m + a_m)));
} else {
tmp = t_0;
}
return a_s * (g_s * tmp);
}
g\_m = abs(g) g\_s = copysign(1.0, g) a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g_s, g_m, a_m) t_0 = exp(Float64(Float64(log(g_m) - log(Float64(a_m + a_m))) * 0.3333333333333333)) t_1 = cbrt(Float64(g_m / Float64(2.0 * a_m))) tmp = 0.0 if (t_1 <= 2e-104) tmp = t_0; elseif (t_1 <= 5e+96) tmp = cbrt(Float64(g_m / Float64(a_m + a_m))); else tmp = t_0; end return Float64(a_s * Float64(g_s * tmp)) end
g\_m = N[Abs[g], $MachinePrecision]
g\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[g]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g$95$s_, g$95$m_, a$95$m_] := Block[{t$95$0 = N[Exp[N[(N[(N[Log[g$95$m], $MachinePrecision] - N[Log[N[(a$95$m + a$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(g$95$m / N[(2.0 * a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, N[(a$95$s * N[(g$95$s * If[LessEqual[t$95$1, 2e-104], t$95$0, If[LessEqual[t$95$1, 5e+96], N[Power[N[(g$95$m / N[(a$95$m + a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$0]]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
g\_m = \left|g\right|
\\
g\_s = \mathsf{copysign}\left(1, g\right)
\\
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
\begin{array}{l}
t_0 := e^{\left(\log g\_m - \log \left(a\_m + a\_m\right)\right) \cdot 0.3333333333333333}\\
t_1 := \sqrt[3]{\frac{g\_m}{2 \cdot a\_m}}\\
a\_s \cdot \left(g\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-104}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+96}:\\
\;\;\;\;\sqrt[3]{\frac{g\_m}{a\_m + a\_m}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\right)
\end{array}
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 1.99999999999999985e-104 or 5.0000000000000004e96 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 76.8%
lift-cbrt.f64N/A
pow1/3N/A
pow-to-expN/A
lower-unsound-exp.f64N/A
lower-unsound-*.f64N/A
lower-unsound-log.f6472.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.0
Applied rewrites72.0%
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lower-unsound--.f64N/A
lower-unsound-log.f64N/A
lower-unsound-log.f6491.0
Applied rewrites91.0%
if 1.99999999999999985e-104 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 5.0000000000000004e96Initial program 76.8%
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.8
Applied rewrites76.8%
g\_m = (fabs.f64 g) g\_s = (copysign.f64 #s(literal 1 binary64) g) a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g_s g_m a_m) :precision binary64 (* a_s (* g_s (cbrt (/ g_m (+ a_m a_m))))))
g\_m = fabs(g);
g\_s = copysign(1.0, g);
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * cbrt((g_m / (a_m + a_m))));
}
g\_m = Math.abs(g);
g\_s = Math.copySign(1.0, g);
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g_s, double g_m, double a_m) {
return a_s * (g_s * Math.cbrt((g_m / (a_m + a_m))));
}
g\_m = abs(g) g\_s = copysign(1.0, g) a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g_s, g_m, a_m) return Float64(a_s * Float64(g_s * cbrt(Float64(g_m / Float64(a_m + a_m))))) end
g\_m = N[Abs[g], $MachinePrecision]
g\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[g]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, g$95$s_, g$95$m_, a$95$m_] := N[(a$95$s * N[(g$95$s * N[Power[N[(g$95$m / N[(a$95$m + a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
g\_m = \left|g\right|
\\
g\_s = \mathsf{copysign}\left(1, g\right)
\\
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \left(g\_s \cdot \sqrt[3]{\frac{g\_m}{a\_m + a\_m}}\right)
\end{array}
Initial program 76.8%
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.8
Applied rewrites76.8%
herbie shell --seed 2025154
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))