
(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 8 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}
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g a_m) :precision binary64 (let* ((t_0 (pow (/ 1.0 a_m) (/ -1.0 2.0)))) (* a_s (/ (cbrt (* 0.5 g)) (cbrt (* t_0 t_0))))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
double t_0 = pow((1.0 / a_m), (-1.0 / 2.0));
return a_s * (cbrt((0.5 * g)) / cbrt((t_0 * t_0)));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
double t_0 = Math.pow((1.0 / a_m), (-1.0 / 2.0));
return a_s * (Math.cbrt((0.5 * g)) / Math.cbrt((t_0 * t_0)));
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g, a_m) t_0 = Float64(1.0 / a_m) ^ Float64(-1.0 / 2.0) return Float64(a_s * Float64(cbrt(Float64(0.5 * g)) / cbrt(Float64(t_0 * t_0)))) end
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_, a$95$m_] := Block[{t$95$0 = N[Power[N[(1.0 / a$95$m), $MachinePrecision], N[(-1.0 / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(a$95$s * N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(t$95$0 * t$95$0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
\begin{array}{l}
t_0 := {\left(\frac{1}{a\_m}\right)}^{\left(\frac{-1}{2}\right)}\\
a\_s \cdot \frac{\sqrt[3]{0.5 \cdot g}}{\sqrt[3]{t\_0 \cdot t\_0}}
\end{array}
\end{array}
Initial program 75.8%
Applied rewrites98.7%
Taylor expanded in g around 0
Applied rewrites98.7%
Applied rewrites98.7%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g a_m) :precision binary64 (* a_s (/ (cbrt g) (cbrt (+ a_m a_m)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
return a_s * (cbrt(g) / cbrt((a_m + a_m)));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
return a_s * (Math.cbrt(g) / Math.cbrt((a_m + a_m)));
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g, a_m) return Float64(a_s * Float64(cbrt(g) / cbrt(Float64(a_m + a_m)))) end
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_, a$95$m_] := N[(a$95$s * N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a$95$m + a$95$m), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \frac{\sqrt[3]{g}}{\sqrt[3]{a\_m + a\_m}}
\end{array}
Initial program 75.8%
Applied rewrites98.7%
Applied rewrites98.7%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s g a_m)
:precision binary64
(let* ((t_0 (cbrt (/ g (* 2.0 a_m)))) (t_1 (/ (cbrt g) (cbrt a_m))))
(*
a_s
(if (<= t_0 0.0) t_1 (if (<= t_0 2e+100) (cbrt (/ g (+ a_m a_m))) t_1)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
double t_0 = cbrt((g / (2.0 * a_m)));
double t_1 = cbrt(g) / cbrt(a_m);
double tmp;
if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 2e+100) {
tmp = cbrt((g / (a_m + a_m)));
} else {
tmp = t_1;
}
return a_s * tmp;
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
double t_0 = Math.cbrt((g / (2.0 * a_m)));
double t_1 = Math.cbrt(g) / Math.cbrt(a_m);
double tmp;
if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 2e+100) {
tmp = Math.cbrt((g / (a_m + a_m)));
} else {
tmp = t_1;
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g, a_m) t_0 = cbrt(Float64(g / Float64(2.0 * a_m))) t_1 = Float64(cbrt(g) / cbrt(a_m)) tmp = 0.0 if (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 2e+100) tmp = cbrt(Float64(g / Float64(a_m + a_m))); else tmp = t_1; end return Float64(a_s * tmp) end
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_, a$95$m_] := Block[{t$95$0 = N[Power[N[(g / N[(2.0 * a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[a$95$m, 1/3], $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 2e+100], N[Power[N[(g / N[(a$95$m + a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], t$95$1]]), $MachinePrecision]]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{g}{2 \cdot a\_m}}\\
t_1 := \frac{\sqrt[3]{g}}{\sqrt[3]{a\_m}}\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+100}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a\_m + a\_m}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 0.0 or 2.00000000000000003e100 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) Initial program 75.8%
Applied rewrites98.7%
Applied rewrites98.7%
Applied rewrites21.2%
if 0.0 < (cbrt.f64 (/.f64 g (*.f64 #s(literal 2 binary64) a))) < 2.00000000000000003e100Initial program 75.8%
Applied rewrites75.8%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g a_m) :precision binary64 (* a_s (cbrt (/ g (+ a_m a_m)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
return a_s * cbrt((g / (a_m + a_m)));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
return a_s * Math.cbrt((g / (a_m + a_m)));
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g, a_m) return Float64(a_s * cbrt(Float64(g / Float64(a_m + a_m)))) end
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_, a$95$m_] := N[(a$95$s * N[Power[N[(g / N[(a$95$m + a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \sqrt[3]{\frac{g}{a\_m + a\_m}}
\end{array}
Initial program 75.8%
Applied rewrites75.8%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g a_m) :precision binary64 (* a_s (cbrt (/ g a_m))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
return a_s * cbrt((g / a_m));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
return a_s * Math.cbrt((g / a_m));
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g, a_m) return Float64(a_s * cbrt(Float64(g / a_m))) end
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_, a$95$m_] := N[(a$95$s * N[Power[N[(g / a$95$m), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \sqrt[3]{\frac{g}{a\_m}}
\end{array}
Initial program 75.8%
Applied rewrites98.7%
Applied rewrites98.7%
Applied rewrites17.2%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g a_m) :precision binary64 (* a_s (/ (cbrt g) 1.0)))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
return a_s * (cbrt(g) / 1.0);
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
return a_s * (Math.cbrt(g) / 1.0);
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g, a_m) return Float64(a_s * Float64(cbrt(g) / 1.0)) end
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_, a$95$m_] := N[(a$95$s * N[(N[Power[g, 1/3], $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \frac{\sqrt[3]{g}}{1}
\end{array}
Initial program 75.8%
Applied rewrites98.7%
Applied rewrites98.7%
Taylor expanded in a around 0
Applied rewrites7.9%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g a_m) :precision binary64 (* a_s (cbrt (* -0.5 g))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
return a_s * cbrt((-0.5 * g));
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
return a_s * Math.cbrt((-0.5 * g));
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g, a_m) return Float64(a_s * cbrt(Float64(-0.5 * g))) end
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_, a$95$m_] := N[(a$95$s * N[Power[N[(-0.5 * g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \sqrt[3]{-0.5 \cdot g}
\end{array}
Initial program 75.8%
Applied rewrites3.9%
Taylor expanded in g around 0
Applied rewrites1.6%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s g a_m) :precision binary64 (* a_s (- (cbrt g))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double g, double a_m) {
return a_s * -cbrt(g);
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double g, double a_m) {
return a_s * -Math.cbrt(g);
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, g, a_m) return Float64(a_s * Float64(-cbrt(g))) end
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_, a$95$m_] := N[(a$95$s * (-N[Power[g, 1/3], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \left(-\sqrt[3]{g}\right)
\end{array}
Initial program 75.8%
Applied rewrites3.9%
Taylor expanded in g around -inf
Applied rewrites1.6%
herbie shell --seed 2025135
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))