
(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}
Sampling outcomes in binary64 precision:
Herbie found 8 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}
h_m = (fabs.f64 h)
(FPCore (g h_m a)
:precision binary64
(let* ((t_0 (cbrt (/ -1.0 a))))
(if (<= h_m 2e-229)
(fma (cbrt g) t_0 (cbrt (* a (* -0.25 (/ (pow h_m 2.0) g)))))
(fma (cbrt g) t_0 (* (pow (cbrt h_m) 2.0) (cbrt (/ (/ -0.25 g) a)))))))h_m = fabs(h);
double code(double g, double h_m, double a) {
double t_0 = cbrt((-1.0 / a));
double tmp;
if (h_m <= 2e-229) {
tmp = fma(cbrt(g), t_0, cbrt((a * (-0.25 * (pow(h_m, 2.0) / g)))));
} else {
tmp = fma(cbrt(g), t_0, (pow(cbrt(h_m), 2.0) * cbrt(((-0.25 / g) / a))));
}
return tmp;
}
h_m = abs(h) function code(g, h_m, a) t_0 = cbrt(Float64(-1.0 / a)) tmp = 0.0 if (h_m <= 2e-229) tmp = fma(cbrt(g), t_0, cbrt(Float64(a * Float64(-0.25 * Float64((h_m ^ 2.0) / g))))); else tmp = fma(cbrt(g), t_0, Float64((cbrt(h_m) ^ 2.0) * cbrt(Float64(Float64(-0.25 / g) / a)))); end return tmp end
h_m = N[Abs[h], $MachinePrecision]
code[g_, h$95$m_, a_] := Block[{t$95$0 = N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[h$95$m, 2e-229], N[(N[Power[g, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(a * N[(-0.25 * N[(N[Power[h$95$m, 2.0], $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * t$95$0 + N[(N[Power[N[Power[h$95$m, 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[(N[(-0.25 / g), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
h_m = \left|h\right|
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{-1}{a}}\\
\mathbf{if}\;h\_m \leq 2 \cdot 10^{-229}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, t\_0, \sqrt[3]{a \cdot \left(-0.25 \cdot \frac{{h\_m}^{2}}{g}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, t\_0, {\left(\sqrt[3]{h\_m}\right)}^{2} \cdot \sqrt[3]{\frac{\frac{-0.25}{g}}{a}}\right)\\
\end{array}
\end{array}
if h < 2.00000000000000014e-229Initial program 48.4%
Simplified49.0%
Taylor expanded in h around 0 70.3%
pow1/332.2%
div-inv32.2%
unpow-prod-down22.6%
pow1/340.1%
Applied egg-rr40.1%
unpow1/384.2%
Simplified84.2%
associate-*l*84.1%
fma-define84.1%
cbrt-unprod84.6%
metadata-eval84.6%
cbrt-unprod84.6%
associate-/l/90.4%
cbrt-unprod90.4%
metadata-eval90.4%
cbrt-prod90.4%
associate-/l/84.6%
*-commutative84.6%
Applied egg-rr84.6%
associate-*l/84.6%
metadata-eval84.6%
associate-*l/84.6%
Simplified84.6%
Applied egg-rr82.4%
*-lft-identity82.4%
*-commutative82.4%
associate-*l*82.4%
*-commutative82.4%
Simplified82.4%
if 2.00000000000000014e-229 < h Initial program 42.2%
Simplified42.2%
Taylor expanded in h around 0 65.9%
pow1/330.4%
div-inv30.4%
unpow-prod-down17.9%
pow1/336.0%
Applied egg-rr36.0%
unpow1/388.1%
Simplified88.1%
associate-*l*88.1%
fma-define88.1%
cbrt-unprod88.6%
metadata-eval88.6%
cbrt-unprod88.6%
associate-/l/89.2%
cbrt-unprod89.2%
metadata-eval89.2%
cbrt-prod89.2%
associate-/l/88.6%
*-commutative88.6%
Applied egg-rr88.6%
associate-*l/88.6%
metadata-eval88.6%
associate-*l/88.6%
Simplified88.6%
Applied egg-rr61.6%
unpow1/395.2%
associate-/r*95.2%
Simplified95.2%
h_m = (fabs.f64 h)
(FPCore (g h_m a)
:precision binary64
(let* ((t_0 (cbrt (/ -1.0 a))))
(if (<= h_m 3.34e-237)
(fma (cbrt g) t_0 (cbrt (* a (* -0.25 (/ (pow h_m 2.0) g)))))
(if (<= h_m 1.9e+159)
(fma (cbrt g) t_0 (cbrt (/ (* -0.25 (* h_m h_m)) (* g a))))
(* (cbrt (/ g a)) (cbrt -1.0))))))h_m = fabs(h);
double code(double g, double h_m, double a) {
double t_0 = cbrt((-1.0 / a));
double tmp;
if (h_m <= 3.34e-237) {
tmp = fma(cbrt(g), t_0, cbrt((a * (-0.25 * (pow(h_m, 2.0) / g)))));
} else if (h_m <= 1.9e+159) {
tmp = fma(cbrt(g), t_0, cbrt(((-0.25 * (h_m * h_m)) / (g * a))));
} else {
tmp = cbrt((g / a)) * cbrt(-1.0);
}
return tmp;
}
h_m = abs(h) function code(g, h_m, a) t_0 = cbrt(Float64(-1.0 / a)) tmp = 0.0 if (h_m <= 3.34e-237) tmp = fma(cbrt(g), t_0, cbrt(Float64(a * Float64(-0.25 * Float64((h_m ^ 2.0) / g))))); elseif (h_m <= 1.9e+159) tmp = fma(cbrt(g), t_0, cbrt(Float64(Float64(-0.25 * Float64(h_m * h_m)) / Float64(g * a)))); else tmp = Float64(cbrt(Float64(g / a)) * cbrt(-1.0)); end return tmp end
h_m = N[Abs[h], $MachinePrecision]
code[g_, h$95$m_, a_] := Block[{t$95$0 = N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[h$95$m, 3.34e-237], N[(N[Power[g, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(a * N[(-0.25 * N[(N[Power[h$95$m, 2.0], $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[h$95$m, 1.9e+159], N[(N[Power[g, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(N[(-0.25 * N[(h$95$m * h$95$m), $MachinePrecision]), $MachinePrecision] / N[(g * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
h_m = \left|h\right|
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{-1}{a}}\\
\mathbf{if}\;h\_m \leq 3.34 \cdot 10^{-237}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, t\_0, \sqrt[3]{a \cdot \left(-0.25 \cdot \frac{{h\_m}^{2}}{g}\right)}\right)\\
\mathbf{elif}\;h\_m \leq 1.9 \cdot 10^{+159}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, t\_0, \sqrt[3]{\frac{-0.25 \cdot \left(h\_m \cdot h\_m\right)}{g \cdot a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}\\
\end{array}
\end{array}
if h < 3.3400000000000002e-237Initial program 48.1%
Simplified48.7%
Taylor expanded in h around 0 70.1%
pow1/332.4%
div-inv32.4%
unpow-prod-down22.7%
pow1/339.7%
Applied egg-rr39.7%
unpow1/384.1%
Simplified84.1%
associate-*l*84.0%
fma-define84.1%
cbrt-unprod84.5%
metadata-eval84.5%
cbrt-unprod84.5%
associate-/l/90.3%
cbrt-unprod90.3%
metadata-eval90.3%
cbrt-prod90.3%
associate-/l/84.5%
*-commutative84.5%
Applied egg-rr84.5%
associate-*l/84.5%
metadata-eval84.5%
associate-*l/84.5%
Simplified84.5%
Applied egg-rr82.3%
*-lft-identity82.3%
*-commutative82.3%
associate-*l*82.3%
*-commutative82.3%
Simplified82.3%
if 3.3400000000000002e-237 < h < 1.89999999999999983e159Initial program 46.1%
Simplified46.1%
Taylor expanded in h around 0 71.2%
pow1/332.3%
div-inv32.3%
unpow-prod-down19.1%
pow1/339.3%
Applied egg-rr39.3%
unpow1/394.8%
Simplified94.8%
associate-*l*94.9%
fma-define94.9%
cbrt-unprod95.3%
metadata-eval95.3%
cbrt-unprod95.3%
associate-/l/95.9%
cbrt-unprod95.9%
metadata-eval95.9%
cbrt-prod95.9%
associate-/l/95.3%
*-commutative95.3%
Applied egg-rr95.3%
associate-*l/95.3%
metadata-eval95.3%
associate-*l/95.3%
Simplified95.3%
Applied egg-rr95.3%
if 1.89999999999999983e159 < h Initial program 0.0%
Simplified0.0%
Taylor expanded in h around 0 1.8%
pow1/30.7%
div-inv0.7%
unpow-prod-down0.0%
pow1/30.6%
Applied egg-rr0.6%
unpow1/31.8%
Simplified1.8%
associate-*l*1.8%
fma-define1.8%
cbrt-unprod1.8%
metadata-eval1.8%
cbrt-unprod1.8%
associate-/l/3.8%
cbrt-unprod3.8%
metadata-eval3.8%
cbrt-prod3.8%
associate-/l/1.8%
*-commutative1.8%
Applied egg-rr1.8%
associate-*l/1.8%
metadata-eval1.8%
associate-*l/1.8%
Simplified1.8%
Taylor expanded in g around inf 55.5%
Final simplification86.2%
h_m = (fabs.f64 h) (FPCore (g h_m a) :precision binary64 (if (<= (* h_m h_m) 2e+298) (fma (cbrt g) (cbrt (/ -1.0 a)) (cbrt (/ (* -0.25 (* h_m h_m)) (* g a)))) (* (cbrt (/ g a)) (cbrt -1.0))))
h_m = fabs(h);
double code(double g, double h_m, double a) {
double tmp;
if ((h_m * h_m) <= 2e+298) {
tmp = fma(cbrt(g), cbrt((-1.0 / a)), cbrt(((-0.25 * (h_m * h_m)) / (g * a))));
} else {
tmp = cbrt((g / a)) * cbrt(-1.0);
}
return tmp;
}
h_m = abs(h) function code(g, h_m, a) tmp = 0.0 if (Float64(h_m * h_m) <= 2e+298) tmp = fma(cbrt(g), cbrt(Float64(-1.0 / a)), cbrt(Float64(Float64(-0.25 * Float64(h_m * h_m)) / Float64(g * a)))); else tmp = Float64(cbrt(Float64(g / a)) * cbrt(-1.0)); end return tmp end
h_m = N[Abs[h], $MachinePrecision] code[g_, h$95$m_, a_] := If[LessEqual[N[(h$95$m * h$95$m), $MachinePrecision], 2e+298], N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-0.25 * N[(h$95$m * h$95$m), $MachinePrecision]), $MachinePrecision] / N[(g * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
h_m = \left|h\right|
\\
\begin{array}{l}
\mathbf{if}\;h\_m \cdot h\_m \leq 2 \cdot 10^{+298}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{g}, \sqrt[3]{\frac{-1}{a}}, \sqrt[3]{\frac{-0.25 \cdot \left(h\_m \cdot h\_m\right)}{g \cdot a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}\\
\end{array}
\end{array}
if (*.f64 h h) < 1.9999999999999999e298Initial program 49.8%
Simplified50.2%
Taylor expanded in h around 0 73.9%
pow1/334.0%
div-inv34.0%
unpow-prod-down22.5%
pow1/341.5%
Applied egg-rr41.5%
unpow1/392.3%
Simplified92.3%
associate-*l*92.3%
fma-define92.3%
cbrt-unprod92.8%
metadata-eval92.8%
cbrt-unprod92.8%
associate-/l/96.8%
cbrt-unprod96.8%
metadata-eval96.8%
cbrt-prod96.8%
associate-/l/92.8%
*-commutative92.8%
Applied egg-rr92.8%
associate-*l/92.8%
metadata-eval92.8%
associate-*l/92.8%
Simplified92.8%
Applied egg-rr92.8%
if 1.9999999999999999e298 < (*.f64 h h) Initial program 0.0%
Simplified0.0%
Taylor expanded in h around 0 2.6%
pow1/30.7%
div-inv0.7%
unpow-prod-down0.0%
pow1/31.0%
Applied egg-rr1.0%
unpow1/32.6%
Simplified2.6%
associate-*l*2.6%
fma-define2.6%
cbrt-unprod2.6%
metadata-eval2.6%
cbrt-unprod2.6%
associate-/l/4.0%
cbrt-unprod4.0%
metadata-eval4.0%
cbrt-prod4.0%
associate-/l/2.6%
*-commutative2.6%
Applied egg-rr2.6%
associate-*l/2.6%
metadata-eval2.6%
associate-*l/2.6%
Simplified2.6%
Taylor expanded in g around inf 53.5%
Final simplification89.9%
h_m = (fabs.f64 h)
(FPCore (g h_m a)
:precision binary64
(if (<= a 9.2e-305)
(* (cbrt (/ g a)) (cbrt -1.0))
(+
(* (cbrt (- g)) (pow (/ 1.0 a) 0.3333333333333333))
(cbrt (* (- g g) (/ -0.5 a))))))h_m = fabs(h);
double code(double g, double h_m, double a) {
double tmp;
if (a <= 9.2e-305) {
tmp = cbrt((g / a)) * cbrt(-1.0);
} else {
tmp = (cbrt(-g) * pow((1.0 / a), 0.3333333333333333)) + cbrt(((g - g) * (-0.5 / a)));
}
return tmp;
}
h_m = Math.abs(h);
public static double code(double g, double h_m, double a) {
double tmp;
if (a <= 9.2e-305) {
tmp = Math.cbrt((g / a)) * Math.cbrt(-1.0);
} else {
tmp = (Math.cbrt(-g) * Math.pow((1.0 / a), 0.3333333333333333)) + Math.cbrt(((g - g) * (-0.5 / a)));
}
return tmp;
}
h_m = abs(h) function code(g, h_m, a) tmp = 0.0 if (a <= 9.2e-305) tmp = Float64(cbrt(Float64(g / a)) * cbrt(-1.0)); else tmp = Float64(Float64(cbrt(Float64(-g)) * (Float64(1.0 / a) ^ 0.3333333333333333)) + cbrt(Float64(Float64(g - g) * Float64(-0.5 / a)))); end return tmp end
h_m = N[Abs[h], $MachinePrecision] code[g_, h$95$m_, a_] := If[LessEqual[a, 9.2e-305], N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[(-g), 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
h_m = \left|h\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 9.2 \cdot 10^{-305}:\\
\;\;\;\;\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-g} \cdot {\left(\frac{1}{a}\right)}^{0.3333333333333333} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}\\
\end{array}
\end{array}
if a < 9.1999999999999998e-305Initial program 44.0%
Simplified44.7%
Taylor expanded in h around 0 72.0%
pow1/329.5%
div-inv29.5%
unpow-prod-down0.0%
pow1/30.0%
Applied egg-rr0.0%
unpow1/388.7%
Simplified88.7%
associate-*l*88.6%
fma-define88.6%
cbrt-unprod89.2%
metadata-eval89.2%
cbrt-unprod89.2%
associate-/l/92.1%
cbrt-unprod92.1%
metadata-eval92.1%
cbrt-prod92.1%
associate-/l/89.2%
*-commutative89.2%
Applied egg-rr89.2%
associate-*l/89.2%
metadata-eval89.2%
associate-*l/89.2%
Simplified89.2%
Taylor expanded in g around inf 76.7%
if 9.1999999999999998e-305 < a Initial program 48.2%
Simplified48.2%
Taylor expanded in g around -inf 27.0%
associate-*r/27.0%
neg-mul-127.0%
Simplified27.0%
pow1/319.0%
div-inv19.0%
unpow-prod-down20.2%
pow1/330.3%
Applied egg-rr30.3%
Taylor expanded in g around -inf 88.2%
neg-mul-188.2%
Simplified88.2%
Final simplification82.4%
h_m = (fabs.f64 h) (FPCore (g h_m a) :precision binary64 (* (cbrt (/ g a)) (cbrt -1.0)))
h_m = fabs(h);
double code(double g, double h_m, double a) {
return cbrt((g / a)) * cbrt(-1.0);
}
h_m = Math.abs(h);
public static double code(double g, double h_m, double a) {
return Math.cbrt((g / a)) * Math.cbrt(-1.0);
}
h_m = abs(h) function code(g, h_m, a) return Float64(cbrt(Float64(g / a)) * cbrt(-1.0)) end
h_m = N[Abs[h], $MachinePrecision] code[g_, h$95$m_, a_] := N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
h_m = \left|h\right|
\\
\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}
\end{array}
Initial program 46.1%
Simplified46.4%
Taylor expanded in h around 0 68.6%
pow1/331.5%
div-inv31.5%
unpow-prod-down20.8%
pow1/338.5%
Applied egg-rr38.5%
unpow1/385.7%
Simplified85.7%
associate-*l*85.6%
fma-define85.7%
cbrt-unprod86.1%
metadata-eval86.1%
cbrt-unprod86.1%
associate-/l/89.9%
cbrt-unprod89.9%
metadata-eval89.9%
cbrt-prod89.9%
associate-/l/86.1%
*-commutative86.1%
Applied egg-rr86.1%
associate-*l/86.1%
metadata-eval86.1%
associate-*l/86.1%
Simplified86.1%
Taylor expanded in g around inf 75.5%
h_m = (fabs.f64 h) (FPCore (g h_m a) :precision binary64 (* (/ 1.0 (cbrt (/ a g))) -2.0))
h_m = fabs(h);
double code(double g, double h_m, double a) {
return (1.0 / cbrt((a / g))) * -2.0;
}
h_m = Math.abs(h);
public static double code(double g, double h_m, double a) {
return (1.0 / Math.cbrt((a / g))) * -2.0;
}
h_m = abs(h) function code(g, h_m, a) return Float64(Float64(1.0 / cbrt(Float64(a / g))) * -2.0) end
h_m = N[Abs[h], $MachinePrecision] code[g_, h$95$m_, a_] := N[(N[(1.0 / N[Power[N[(a / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]
\begin{array}{l}
h_m = \left|h\right|
\\
\frac{1}{\sqrt[3]{\frac{a}{g}}} \cdot -2
\end{array}
Initial program 46.1%
Simplified46.4%
Taylor expanded in g around -inf 27.5%
associate-*r/27.5%
neg-mul-127.5%
Simplified27.5%
Taylor expanded in g around inf 15.6%
Taylor expanded in g around -inf 15.6%
*-commutative15.6%
Simplified15.6%
clear-num15.6%
cbrt-div15.9%
metadata-eval15.9%
Applied egg-rr15.9%
h_m = (fabs.f64 h) (FPCore (g h_m a) :precision binary64 (* (cbrt (/ g a)) -2.0))
h_m = fabs(h);
double code(double g, double h_m, double a) {
return cbrt((g / a)) * -2.0;
}
h_m = Math.abs(h);
public static double code(double g, double h_m, double a) {
return Math.cbrt((g / a)) * -2.0;
}
h_m = abs(h) function code(g, h_m, a) return Float64(cbrt(Float64(g / a)) * -2.0) end
h_m = N[Abs[h], $MachinePrecision] code[g_, h$95$m_, a_] := N[(N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision] * -2.0), $MachinePrecision]
\begin{array}{l}
h_m = \left|h\right|
\\
\sqrt[3]{\frac{g}{a}} \cdot -2
\end{array}
Initial program 46.1%
Simplified46.4%
Taylor expanded in g around -inf 27.5%
associate-*r/27.5%
neg-mul-127.5%
Simplified27.5%
Taylor expanded in g around inf 15.6%
Taylor expanded in g around -inf 15.6%
*-commutative15.6%
Simplified15.6%
h_m = (fabs.f64 h) (FPCore (g h_m a) :precision binary64 (* -2.0 (cbrt (* g a))))
h_m = fabs(h);
double code(double g, double h_m, double a) {
return -2.0 * cbrt((g * a));
}
h_m = Math.abs(h);
public static double code(double g, double h_m, double a) {
return -2.0 * Math.cbrt((g * a));
}
h_m = abs(h) function code(g, h_m, a) return Float64(-2.0 * cbrt(Float64(g * a))) end
h_m = N[Abs[h], $MachinePrecision] code[g_, h$95$m_, a_] := N[(-2.0 * N[Power[N[(g * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
h_m = \left|h\right|
\\
-2 \cdot \sqrt[3]{g \cdot a}
\end{array}
Initial program 46.1%
Simplified46.4%
Taylor expanded in g around -inf 27.5%
associate-*r/27.5%
neg-mul-127.5%
Simplified27.5%
Taylor expanded in g around inf 15.6%
Taylor expanded in g around -inf 15.6%
*-commutative15.6%
Simplified15.6%
Applied egg-rr5.8%
unpow15.8%
*-commutative5.8%
*-commutative5.8%
Simplified5.8%
Final simplification5.8%
herbie shell --seed 2024137
(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))))))))