
(FPCore (g h a) :precision binary64 (let* ((t_0 (/ 1.0 (* 2.0 a))) (t_1 (sqrt (- (* g g) (* h h))))) (+ (cbrt (* t_0 (+ (- g) t_1))) (cbrt (* t_0 (- (- g) t_1))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = sqrt(((g * g) - (h * h)));
return cbrt((t_0 * (-g + t_1))) + cbrt((t_0 * (-g - t_1)));
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = Math.sqrt(((g * g) - (h * h)));
return Math.cbrt((t_0 * (-g + t_1))) + Math.cbrt((t_0 * (-g - t_1)));
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) return Float64(cbrt(Float64(t_0 * Float64(Float64(-g) + t_1))) + cbrt(Float64(t_0 * Float64(Float64(-g) - t_1)))) end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(t$95$0 * N[((-g) + t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$0 * N[((-g) - t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\sqrt[3]{t\_0 \cdot \left(\left(-g\right) + t\_1\right)} + \sqrt[3]{t\_0 \cdot \left(\left(-g\right) - t\_1\right)}
\end{array}
\end{array}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (g h a) :precision binary64 (let* ((t_0 (/ 1.0 (* 2.0 a))) (t_1 (sqrt (- (* g g) (* h h))))) (+ (cbrt (* t_0 (+ (- g) t_1))) (cbrt (* t_0 (- (- g) t_1))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = sqrt(((g * g) - (h * h)));
return cbrt((t_0 * (-g + t_1))) + cbrt((t_0 * (-g - t_1)));
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = Math.sqrt(((g * g) - (h * h)));
return Math.cbrt((t_0 * (-g + t_1))) + Math.cbrt((t_0 * (-g - t_1)));
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) return Float64(cbrt(Float64(t_0 * Float64(Float64(-g) + t_1))) + cbrt(Float64(t_0 * Float64(Float64(-g) - t_1)))) end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(t$95$0 * N[((-g) + t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$0 * N[((-g) - t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\sqrt[3]{t\_0 \cdot \left(\left(-g\right) + t\_1\right)} + \sqrt[3]{t\_0 \cdot \left(\left(-g\right) - t\_1\right)}
\end{array}
\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 h a_m)
:precision binary64
(let* ((t_0 (* (cbrt -0.5) (cbrt 2.0)))
(t_1 (sqrt (- (* g_m g_m) (* h h))))
(t_2 (/ 1.0 (* 2.0 a_m))))
(*
a_s
(*
g_s
(if (<=
(+ (cbrt (* t_2 (+ (- g_m) t_1))) (cbrt (* t_2 (- (- g_m) t_1))))
-5e+68)
(*
g_m
(fma
(cbrt (/ 1.0 (* a_m (pow g_m 2.0))))
t_0
(*
(cbrt (/ (pow h 2.0) (* a_m (pow g_m 4.0))))
(* (cbrt -0.5) (cbrt 0.5)))))
(* (cbrt (/ g_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 h, double a_m) {
double t_0 = cbrt(-0.5) * cbrt(2.0);
double t_1 = sqrt(((g_m * g_m) - (h * h)));
double t_2 = 1.0 / (2.0 * a_m);
double tmp;
if ((cbrt((t_2 * (-g_m + t_1))) + cbrt((t_2 * (-g_m - t_1)))) <= -5e+68) {
tmp = g_m * fma(cbrt((1.0 / (a_m * pow(g_m, 2.0)))), t_0, (cbrt((pow(h, 2.0) / (a_m * pow(g_m, 4.0)))) * (cbrt(-0.5) * cbrt(0.5))));
} else {
tmp = cbrt((g_m / a_m)) * 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, h, a_m) t_0 = Float64(cbrt(-0.5) * cbrt(2.0)) t_1 = sqrt(Float64(Float64(g_m * g_m) - Float64(h * h))) t_2 = Float64(1.0 / Float64(2.0 * a_m)) tmp = 0.0 if (Float64(cbrt(Float64(t_2 * Float64(Float64(-g_m) + t_1))) + cbrt(Float64(t_2 * Float64(Float64(-g_m) - t_1)))) <= -5e+68) tmp = Float64(g_m * fma(cbrt(Float64(1.0 / Float64(a_m * (g_m ^ 2.0)))), t_0, Float64(cbrt(Float64((h ^ 2.0) / Float64(a_m * (g_m ^ 4.0)))) * Float64(cbrt(-0.5) * cbrt(0.5))))); else tmp = Float64(cbrt(Float64(g_m / a_m)) * 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_, h_, a$95$m_] := Block[{t$95$0 = N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g$95$m * g$95$m), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[(2.0 * a$95$m), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * N[(g$95$s * If[LessEqual[N[(N[Power[N[(t$95$2 * N[((-g$95$m) + t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$2 * N[((-g$95$m) - t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], -5e+68], N[(g$95$m * N[(N[Power[N[(1.0 / N[(a$95$m * N[Power[g$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * t$95$0 + N[(N[Power[N[(N[Power[h, 2.0], $MachinePrecision] / N[(a$95$m * N[Power[g$95$m, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[0.5, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(g$95$m / a$95$m), $MachinePrecision], 1/3], $MachinePrecision] * t$95$0), $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)
\\
\begin{array}{l}
t_0 := \sqrt[3]{-0.5} \cdot \sqrt[3]{2}\\
t_1 := \sqrt{g\_m \cdot g\_m - h \cdot h}\\
t_2 := \frac{1}{2 \cdot a\_m}\\
a\_s \cdot \left(g\_s \cdot \begin{array}{l}
\mathbf{if}\;\sqrt[3]{t\_2 \cdot \left(\left(-g\_m\right) + t\_1\right)} + \sqrt[3]{t\_2 \cdot \left(\left(-g\_m\right) - t\_1\right)} \leq -5 \cdot 10^{+68}:\\
\;\;\;\;g\_m \cdot \mathsf{fma}\left(\sqrt[3]{\frac{1}{a\_m \cdot {g\_m}^{2}}}, t\_0, \sqrt[3]{\frac{{h}^{2}}{a\_m \cdot {g\_m}^{4}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{0.5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{g\_m}{a\_m}} \cdot t\_0\\
\end{array}\right)
\end{array}
\end{array}
if (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < -5.0000000000000004e68Initial program 43.4%
Taylor expanded in g around inf
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites31.7%
if -5.0000000000000004e68 < (+.f64 (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 43.4%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6473.2
Applied rewrites73.2%
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 h a_m)
:precision binary64
(let* ((t_0 (/ 1.0 (* 2.0 a_m))))
(*
a_s
(*
g_s
(if (<= h 6.8e+133)
(+
(cbrt (* t_0 (* -0.5 (/ (pow h 2.0) g_m))))
(cbrt (* t_0 (* -2.0 g_m))))
(* (cbrt (/ g_m a_m)) (* (cbrt -0.5) (cbrt 2.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 h, double a_m) {
double t_0 = 1.0 / (2.0 * a_m);
double tmp;
if (h <= 6.8e+133) {
tmp = cbrt((t_0 * (-0.5 * (pow(h, 2.0) / g_m)))) + cbrt((t_0 * (-2.0 * g_m)));
} else {
tmp = cbrt((g_m / a_m)) * (cbrt(-0.5) * cbrt(2.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 h, double a_m) {
double t_0 = 1.0 / (2.0 * a_m);
double tmp;
if (h <= 6.8e+133) {
tmp = Math.cbrt((t_0 * (-0.5 * (Math.pow(h, 2.0) / g_m)))) + Math.cbrt((t_0 * (-2.0 * g_m)));
} else {
tmp = Math.cbrt((g_m / a_m)) * (Math.cbrt(-0.5) * Math.cbrt(2.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, h, a_m) t_0 = Float64(1.0 / Float64(2.0 * a_m)) tmp = 0.0 if (h <= 6.8e+133) tmp = Float64(cbrt(Float64(t_0 * Float64(-0.5 * Float64((h ^ 2.0) / g_m)))) + cbrt(Float64(t_0 * Float64(-2.0 * g_m)))); else tmp = Float64(cbrt(Float64(g_m / a_m)) * Float64(cbrt(-0.5) * cbrt(2.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_, h_, a$95$m_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a$95$m), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * N[(g$95$s * If[LessEqual[h, 6.8e+133], N[(N[Power[N[(t$95$0 * N[(-0.5 * N[(N[Power[h, 2.0], $MachinePrecision] / g$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$0 * N[(-2.0 * g$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(g$95$m / a$95$m), $MachinePrecision], 1/3], $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 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)
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a\_m}\\
a\_s \cdot \left(g\_s \cdot \begin{array}{l}
\mathbf{if}\;h \leq 6.8 \cdot 10^{+133}:\\
\;\;\;\;\sqrt[3]{t\_0 \cdot \left(-0.5 \cdot \frac{{h}^{2}}{g\_m}\right)} + \sqrt[3]{t\_0 \cdot \left(-2 \cdot g\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{g\_m}{a\_m}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)\\
\end{array}\right)
\end{array}
\end{array}
if h < 6.79999999999999975e133Initial program 43.4%
Taylor expanded in g around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6445.7
Applied rewrites45.7%
Taylor expanded in g around inf
lower-*.f6471.6
Applied rewrites71.6%
if 6.79999999999999975e133 < h Initial program 43.4%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6473.2
Applied rewrites73.2%
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 h a_m)
:precision binary64
(*
a_s
(*
g_s
(if (<= (* h h) 2e+264)
(+
(cbrt (* (/ 0.5 a_m) (* -0.5 (/ (pow h 2.0) g_m))))
(cbrt (* -1.0 (/ g_m a_m))))
(* (cbrt (/ g_m a_m)) (* (cbrt -0.5) (cbrt 2.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 h, double a_m) {
double tmp;
if ((h * h) <= 2e+264) {
tmp = cbrt(((0.5 / a_m) * (-0.5 * (pow(h, 2.0) / g_m)))) + cbrt((-1.0 * (g_m / a_m)));
} else {
tmp = cbrt((g_m / a_m)) * (cbrt(-0.5) * cbrt(2.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 h, double a_m) {
double tmp;
if ((h * h) <= 2e+264) {
tmp = Math.cbrt(((0.5 / a_m) * (-0.5 * (Math.pow(h, 2.0) / g_m)))) + Math.cbrt((-1.0 * (g_m / a_m)));
} else {
tmp = Math.cbrt((g_m / a_m)) * (Math.cbrt(-0.5) * Math.cbrt(2.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, h, a_m) tmp = 0.0 if (Float64(h * h) <= 2e+264) tmp = Float64(cbrt(Float64(Float64(0.5 / a_m) * Float64(-0.5 * Float64((h ^ 2.0) / g_m)))) + cbrt(Float64(-1.0 * Float64(g_m / a_m)))); else tmp = Float64(cbrt(Float64(g_m / a_m)) * Float64(cbrt(-0.5) * cbrt(2.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_, h_, a$95$m_] := N[(a$95$s * N[(g$95$s * If[LessEqual[N[(h * h), $MachinePrecision], 2e+264], N[(N[Power[N[(N[(0.5 / a$95$m), $MachinePrecision] * N[(-0.5 * N[(N[Power[h, 2.0], $MachinePrecision] / g$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(-1.0 * N[(g$95$m / a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(g$95$m / a$95$m), $MachinePrecision], 1/3], $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 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 \begin{array}{l}
\mathbf{if}\;h \cdot h \leq 2 \cdot 10^{+264}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a\_m} \cdot \left(-0.5 \cdot \frac{{h}^{2}}{g\_m}\right)} + \sqrt[3]{-1 \cdot \frac{g\_m}{a\_m}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{g\_m}{a\_m}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)\\
\end{array}\right)
\end{array}
if (*.f64 h h) < 2.00000000000000009e264Initial program 43.4%
Taylor expanded in g around inf
lower-*.f64N/A
lower-/.f6443.3
Applied rewrites43.3%
Taylor expanded in g around inf
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6471.7
Applied rewrites71.7%
Taylor expanded in a around 0
lower-/.f6471.7
Applied rewrites71.7%
if 2.00000000000000009e264 < (*.f64 h h) Initial program 43.4%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6473.2
Applied rewrites73.2%
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 h a_m) :precision binary64 (* a_s (* g_s (* (cbrt (/ g_m a_m)) (* (cbrt -0.5) (cbrt 2.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 h, double a_m) {
return a_s * (g_s * (cbrt((g_m / a_m)) * (cbrt(-0.5) * cbrt(2.0))));
}
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 h, double a_m) {
return a_s * (g_s * (Math.cbrt((g_m / a_m)) * (Math.cbrt(-0.5) * Math.cbrt(2.0))));
}
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, h, a_m) return Float64(a_s * Float64(g_s * Float64(cbrt(Float64(g_m / a_m)) * Float64(cbrt(-0.5) * cbrt(2.0))))) 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_, h_, a$95$m_] := N[(a$95$s * N[(g$95$s * N[(N[Power[N[(g$95$m / a$95$m), $MachinePrecision], 1/3], $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 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 \left(\sqrt[3]{\frac{g\_m}{a\_m}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)\right)\right)
\end{array}
Initial program 43.4%
Taylor expanded in g around inf
lower-*.f64N/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6473.2
Applied rewrites73.2%
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 h a_m) :precision binary64 (* a_s (* g_s (+ (cbrt (* 0.5 (/ (* h (sqrt -1.0)) a_m))) (cbrt (* -1.0 (/ g_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 h, double a_m) {
return a_s * (g_s * (cbrt((0.5 * ((h * sqrt(-1.0)) / a_m))) + cbrt((-1.0 * (g_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 h, double a_m) {
return a_s * (g_s * (Math.cbrt((0.5 * ((h * Math.sqrt(-1.0)) / a_m))) + Math.cbrt((-1.0 * (g_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, h, a_m) return Float64(a_s * Float64(g_s * Float64(cbrt(Float64(0.5 * Float64(Float64(h * sqrt(-1.0)) / a_m))) + cbrt(Float64(-1.0 * Float64(g_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_, h_, a$95$m_] := N[(a$95$s * N[(g$95$s * N[(N[Power[N[(0.5 * N[(N[(h * N[Sqrt[-1.0], $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(-1.0 * N[(g$95$m / 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(\sqrt[3]{0.5 \cdot \frac{h \cdot \sqrt{-1}}{a\_m}} + \sqrt[3]{-1 \cdot \frac{g\_m}{a\_m}}\right)\right)
\end{array}
Initial program 43.4%
Taylor expanded in g around inf
lower-*.f64N/A
lower-/.f6443.3
Applied rewrites43.3%
Taylor expanded in g around 0
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
herbie shell --seed 2025132
(FPCore (g h a)
:name "2-ancestry mixing, positive discriminant"
:precision binary64
(+ (cbrt (* (/ 1.0 (* 2.0 a)) (+ (- g) (sqrt (- (* g g) (* h h)))))) (cbrt (* (/ 1.0 (* 2.0 a)) (- (- g) (sqrt (- (* g g) (* h h))))))))