
(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}
(FPCore (g h a) :precision binary64 (+ (/ (* (/ (pow (cbrt h) 2.0) (cbrt g)) (cbrt -0.25)) (cbrt a)) (* (* (cbrt g) (cbrt (/ 1.0 a))) (* (cbrt -0.5) (cbrt 2.0)))))
double code(double g, double h, double a) {
return (((pow(cbrt(h), 2.0) / cbrt(g)) * cbrt(-0.25)) / cbrt(a)) + ((cbrt(g) * cbrt((1.0 / a))) * (cbrt(-0.5) * cbrt(2.0)));
}
public static double code(double g, double h, double a) {
return (((Math.pow(Math.cbrt(h), 2.0) / Math.cbrt(g)) * Math.cbrt(-0.25)) / Math.cbrt(a)) + ((Math.cbrt(g) * Math.cbrt((1.0 / a))) * (Math.cbrt(-0.5) * Math.cbrt(2.0)));
}
function code(g, h, a) return Float64(Float64(Float64(Float64((cbrt(h) ^ 2.0) / cbrt(g)) * cbrt(-0.25)) / cbrt(a)) + Float64(Float64(cbrt(g) * cbrt(Float64(1.0 / a))) * Float64(cbrt(-0.5) * cbrt(2.0)))) end
code[g_, h_, a_] := N[(N[(N[(N[(N[Power[N[Power[h, 1/3], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[-0.25, 1/3], $MachinePrecision]), $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{{\left(\sqrt[3]{h}\right)}^{2}}{\sqrt[3]{g}} \cdot \sqrt[3]{-0.25}}{\sqrt[3]{a}} + \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)
\end{array}
Initial program 45.6%
Simplified45.6%
Taylor expanded in g around inf 27.6%
Taylor expanded in g around inf 73.3%
associate-*r/73.3%
Simplified73.3%
pow1/337.9%
div-inv37.8%
unpow-prod-down24.1%
pow1/339.1%
Applied egg-rr39.1%
unpow1/388.3%
Simplified88.3%
frac-times83.9%
*-commutative83.9%
cbrt-div84.3%
associate-*r*84.3%
metadata-eval84.3%
*-commutative84.3%
cbrt-prod84.3%
cbrt-prod88.7%
times-frac88.7%
unpow288.7%
cbrt-prod97.0%
pow297.0%
Applied egg-rr97.0%
associate-*r/97.0%
Simplified97.0%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (* (cbrt g) (cbrt (/ 1.0 a)))))
(if (<= h 2.8e+100)
(+
(cbrt (* (/ 0.5 a) (/ (* -0.5 (pow h 2.0)) g)))
(* t_0 (* (cbrt -0.5) (pow 2.0 0.3333333333333333))))
(+
(* t_0 (* (cbrt -0.5) (cbrt 2.0)))
(/ (* (pow (cbrt h) 2.0) (cbrt -0.25)) (cbrt (* g a)))))))
double code(double g, double h, double a) {
double t_0 = cbrt(g) * cbrt((1.0 / a));
double tmp;
if (h <= 2.8e+100) {
tmp = cbrt(((0.5 / a) * ((-0.5 * pow(h, 2.0)) / g))) + (t_0 * (cbrt(-0.5) * pow(2.0, 0.3333333333333333)));
} else {
tmp = (t_0 * (cbrt(-0.5) * cbrt(2.0))) + ((pow(cbrt(h), 2.0) * cbrt(-0.25)) / cbrt((g * a)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(g) * Math.cbrt((1.0 / a));
double tmp;
if (h <= 2.8e+100) {
tmp = Math.cbrt(((0.5 / a) * ((-0.5 * Math.pow(h, 2.0)) / g))) + (t_0 * (Math.cbrt(-0.5) * Math.pow(2.0, 0.3333333333333333)));
} else {
tmp = (t_0 * (Math.cbrt(-0.5) * Math.cbrt(2.0))) + ((Math.pow(Math.cbrt(h), 2.0) * Math.cbrt(-0.25)) / Math.cbrt((g * a)));
}
return tmp;
}
function code(g, h, a) t_0 = Float64(cbrt(g) * cbrt(Float64(1.0 / a))) tmp = 0.0 if (h <= 2.8e+100) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(Float64(-0.5 * (h ^ 2.0)) / g))) + Float64(t_0 * Float64(cbrt(-0.5) * (2.0 ^ 0.3333333333333333)))); else tmp = Float64(Float64(t_0 * Float64(cbrt(-0.5) * cbrt(2.0))) + Float64(Float64((cbrt(h) ^ 2.0) * cbrt(-0.25)) / cbrt(Float64(g * a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, 2.8e+100], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(N[(-0.5 * N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(t$95$0 * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[N[Power[h, 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[-0.25, 1/3], $MachinePrecision]), $MachinePrecision] / N[Power[N[(g * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\\
\mathbf{if}\;h \leq 2.8 \cdot 10^{+100}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \frac{-0.5 \cdot {h}^{2}}{g}} + t\_0 \cdot \left(\sqrt[3]{-0.5} \cdot {2}^{0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) + \frac{{\left(\sqrt[3]{h}\right)}^{2} \cdot \sqrt[3]{-0.25}}{\sqrt[3]{g \cdot a}}\\
\end{array}
\end{array}
if h < 2.7999999999999998e100Initial program 49.0%
Simplified49.0%
Taylor expanded in g around inf 29.7%
Taylor expanded in g around inf 77.7%
associate-*r/77.7%
Simplified77.7%
pow1/340.0%
div-inv40.0%
unpow-prod-down25.6%
pow1/341.0%
Applied egg-rr41.0%
unpow1/393.1%
Simplified93.1%
pow1/393.6%
Applied egg-rr93.6%
if 2.7999999999999998e100 < h Initial program 3.9%
Simplified3.9%
Taylor expanded in g around inf 1.6%
Taylor expanded in g around inf 18.6%
associate-*r/18.6%
Simplified18.6%
pow1/311.1%
div-inv11.1%
unpow-prod-down5.2%
pow1/315.8%
Applied egg-rr15.8%
unpow1/328.7%
Simplified28.7%
frac-times27.3%
*-commutative27.3%
cbrt-div27.3%
associate-*r*27.3%
metadata-eval27.3%
*-commutative27.3%
cbrt-prod27.3%
associate-/l*27.3%
unpow227.3%
cbrt-prod89.3%
pow289.3%
*-commutative89.3%
Applied egg-rr89.3%
associate-*r/89.3%
*-commutative89.3%
Simplified89.3%
Final simplification93.3%
(FPCore (g h a)
:precision binary64
(if (<= h 1.35e+154)
(+
(cbrt (* (/ 0.5 a) (/ (* -0.5 (pow h 2.0)) g)))
(*
(* (cbrt g) (cbrt (/ 1.0 a)))
(* (cbrt -0.5) (pow 2.0 0.3333333333333333))))
(- (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ g a)))))
double code(double g, double h, double a) {
double tmp;
if (h <= 1.35e+154) {
tmp = cbrt(((0.5 / a) * ((-0.5 * pow(h, 2.0)) / g))) + ((cbrt(g) * cbrt((1.0 / a))) * (cbrt(-0.5) * pow(2.0, 0.3333333333333333)));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) - cbrt((g / a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (h <= 1.35e+154) {
tmp = Math.cbrt(((0.5 / a) * ((-0.5 * Math.pow(h, 2.0)) / g))) + ((Math.cbrt(g) * Math.cbrt((1.0 / a))) * (Math.cbrt(-0.5) * Math.pow(2.0, 0.3333333333333333)));
} else {
tmp = Math.cbrt(((0.5 / a) * (g - g))) - Math.cbrt((g / a));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (h <= 1.35e+154) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(Float64(-0.5 * (h ^ 2.0)) / g))) + Float64(Float64(cbrt(g) * cbrt(Float64(1.0 / a))) * Float64(cbrt(-0.5) * (2.0 ^ 0.3333333333333333)))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) - cbrt(Float64(g / a))); end return tmp end
code[g_, h_, a_] := If[LessEqual[h, 1.35e+154], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(N[(-0.5 * N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;h \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \frac{-0.5 \cdot {h}^{2}}{g}} + \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot {2}^{0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{\frac{g}{a}}\\
\end{array}
\end{array}
if h < 1.35000000000000003e154Initial program 48.3%
Simplified48.3%
Taylor expanded in g around inf 29.2%
Taylor expanded in g around inf 77.3%
associate-*r/77.3%
Simplified77.3%
pow1/339.9%
div-inv39.9%
unpow-prod-down25.5%
pow1/341.3%
Applied egg-rr41.3%
unpow1/393.2%
Simplified93.2%
pow1/393.7%
Applied egg-rr93.7%
if 1.35000000000000003e154 < h Initial program 0.0%
Simplified0.0%
Taylor expanded in g around inf 0.0%
Taylor expanded in g around inf 63.1%
Taylor expanded in g around 0 63.1%
Simplified63.1%
Final simplification92.0%
(FPCore (g h a)
:precision binary64
(if (<= h 1.35e+154)
(+
(* (* (cbrt g) (cbrt (/ 1.0 a))) (* (cbrt -0.5) (cbrt 2.0)))
(cbrt (* (/ 0.5 a) (/ (* -0.5 (pow h 2.0)) g))))
(- (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ g a)))))
double code(double g, double h, double a) {
double tmp;
if (h <= 1.35e+154) {
tmp = ((cbrt(g) * cbrt((1.0 / a))) * (cbrt(-0.5) * cbrt(2.0))) + cbrt(((0.5 / a) * ((-0.5 * pow(h, 2.0)) / g)));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) - cbrt((g / a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (h <= 1.35e+154) {
tmp = ((Math.cbrt(g) * Math.cbrt((1.0 / a))) * (Math.cbrt(-0.5) * Math.cbrt(2.0))) + Math.cbrt(((0.5 / a) * ((-0.5 * Math.pow(h, 2.0)) / g)));
} else {
tmp = Math.cbrt(((0.5 / a) * (g - g))) - Math.cbrt((g / a));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (h <= 1.35e+154) tmp = Float64(Float64(Float64(cbrt(g) * cbrt(Float64(1.0 / a))) * Float64(cbrt(-0.5) * cbrt(2.0))) + cbrt(Float64(Float64(0.5 / a) * Float64(Float64(-0.5 * (h ^ 2.0)) / g)))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) - cbrt(Float64(g / a))); end return tmp end
code[g_, h_, a_] := If[LessEqual[h, 1.35e+154], N[(N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(N[(-0.5 * N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;h \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) + \sqrt[3]{\frac{0.5}{a} \cdot \frac{-0.5 \cdot {h}^{2}}{g}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{\frac{g}{a}}\\
\end{array}
\end{array}
if h < 1.35000000000000003e154Initial program 48.3%
Simplified48.3%
Taylor expanded in g around inf 29.2%
Taylor expanded in g around inf 77.3%
associate-*r/77.3%
Simplified77.3%
pow1/339.9%
div-inv39.9%
unpow-prod-down25.5%
pow1/341.3%
Applied egg-rr41.3%
unpow1/393.2%
Simplified93.2%
if 1.35000000000000003e154 < h Initial program 0.0%
Simplified0.0%
Taylor expanded in g around inf 0.0%
Taylor expanded in g around inf 63.1%
Taylor expanded in g around 0 63.1%
Simplified63.1%
Final simplification91.6%
(FPCore (g h a)
:precision binary64
(if (<= h 1.35e+154)
(+
(cbrt (* (/ 0.5 a) (/ (* -0.5 (pow h 2.0)) g)))
(* (* (cbrt -0.5) (cbrt 2.0)) (/ (cbrt g) (cbrt a))))
(- (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ g a)))))
double code(double g, double h, double a) {
double tmp;
if (h <= 1.35e+154) {
tmp = cbrt(((0.5 / a) * ((-0.5 * pow(h, 2.0)) / g))) + ((cbrt(-0.5) * cbrt(2.0)) * (cbrt(g) / cbrt(a)));
} else {
tmp = cbrt(((0.5 / a) * (g - g))) - cbrt((g / a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (h <= 1.35e+154) {
tmp = Math.cbrt(((0.5 / a) * ((-0.5 * Math.pow(h, 2.0)) / g))) + ((Math.cbrt(-0.5) * Math.cbrt(2.0)) * (Math.cbrt(g) / Math.cbrt(a)));
} else {
tmp = Math.cbrt(((0.5 / a) * (g - g))) - Math.cbrt((g / a));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (h <= 1.35e+154) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(Float64(-0.5 * (h ^ 2.0)) / g))) + Float64(Float64(cbrt(-0.5) * cbrt(2.0)) * Float64(cbrt(g) / cbrt(a)))); else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) - cbrt(Float64(g / a))); end return tmp end
code[g_, h_, a_] := If[LessEqual[h, 1.35e+154], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(N[(-0.5 * N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;h \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \frac{-0.5 \cdot {h}^{2}}{g}} + \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \cdot \frac{\sqrt[3]{g}}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{\frac{g}{a}}\\
\end{array}
\end{array}
if h < 1.35000000000000003e154Initial program 48.3%
Simplified48.3%
Taylor expanded in g around inf 29.2%
Taylor expanded in g around inf 77.3%
associate-*r/77.3%
Simplified77.3%
cbrt-div92.9%
div-inv92.9%
Applied egg-rr92.9%
associate-*r/92.9%
*-rgt-identity92.9%
Simplified92.9%
if 1.35000000000000003e154 < h Initial program 0.0%
Simplified0.0%
Taylor expanded in g around inf 0.0%
Taylor expanded in g around inf 63.1%
Taylor expanded in g around 0 63.1%
Simplified63.1%
Final simplification91.3%
(FPCore (g h a) :precision binary64 (- (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ g a))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) - cbrt((g / a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) - Math.cbrt((g / a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) - cbrt(Float64(g / a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[N[(g / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{\frac{g}{a}}
\end{array}
Initial program 45.6%
Simplified45.6%
Taylor expanded in g around inf 24.3%
Taylor expanded in g around inf 78.5%
Taylor expanded in g around 0 78.5%
Simplified78.5%
Final simplification78.5%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (/ -1.0 (cbrt a))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + (-1.0 / cbrt(a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + (-1.0 / Math.cbrt(a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(-1.0 / cbrt(a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(-1.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{-1}{\sqrt[3]{a}}
\end{array}
Initial program 45.6%
Simplified45.6%
Taylor expanded in g around inf 24.3%
Taylor expanded in g around inf 78.5%
associate-*r/78.5%
cbrt-div95.0%
flip-+0.0%
unpow20.0%
unpow20.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified4.8%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) -1.0))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + -1.0;
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + -1.0;
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + -1.0) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + -1
\end{array}
Initial program 45.6%
Simplified45.6%
Taylor expanded in g around inf 24.3%
Taylor expanded in g around inf 78.5%
expm1-log1p-u53.5%
expm1-undefine28.5%
flip-+0.0%
frac-times0.0%
unpow20.0%
unpow20.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified4.7%
herbie shell --seed 2024108
(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))))))))