
(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 11 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 (+ (cbrt (* (/ 0.5 a) (- g g))) (* (* (cbrt g) (/ 1.0 (cbrt a))) (* (cbrt -0.5) (pow 2.0 0.3333333333333333)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + ((cbrt(g) * (1.0 / cbrt(a))) * (cbrt(-0.5) * pow(2.0, 0.3333333333333333)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + ((Math.cbrt(g) * (1.0 / Math.cbrt(a))) * (Math.cbrt(-0.5) * Math.pow(2.0, 0.3333333333333333)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(Float64(cbrt(g) * Float64(1.0 / cbrt(a))) * Float64(cbrt(-0.5) * (2.0 ^ 0.3333333333333333)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[(1.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot {2}^{0.3333333333333333}\right)
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around inf 27.0%
cbrt-div31.3%
div-inv31.4%
Applied egg-rr31.4%
Taylor expanded in g around inf 94.6%
pow1/395.1%
Applied egg-rr95.1%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (- (* g g) (* h h))))
(t_1 (+ g t_0))
(t_2
(+
(cbrt (* (/ 1.0 (* a 2.0)) (- t_0 g)))
(cbrt (* t_1 (/ -1.0 (* a 2.0))))))
(t_3 (* -0.5 (/ (pow h 2.0) g)))
(t_4
(+ (cbrt (* (/ 0.5 a) t_3)) (cbrt (* (+ t_3 (* g 2.0)) (/ -0.5 a))))))
(if (<= t_2 -4e-89)
t_4
(if (<= t_2 0.0)
(+ (* (cbrt (/ 0.5 a)) (cbrt (- (- g) g))) (cbrt (* (/ -0.5 a) t_1)))
(if (<= t_2 5e+99)
t_4
(+
(cbrt (* (/ 0.5 a) (- g g)))
(* (* (cbrt -0.5) (cbrt 2.0)) (/ 1.0 (cbrt (/ a g))))))))))
double code(double g, double h, double a) {
double t_0 = sqrt(((g * g) - (h * h)));
double t_1 = g + t_0;
double t_2 = cbrt(((1.0 / (a * 2.0)) * (t_0 - g))) + cbrt((t_1 * (-1.0 / (a * 2.0))));
double t_3 = -0.5 * (pow(h, 2.0) / g);
double t_4 = cbrt(((0.5 / a) * t_3)) + cbrt(((t_3 + (g * 2.0)) * (-0.5 / a)));
double tmp;
if (t_2 <= -4e-89) {
tmp = t_4;
} else if (t_2 <= 0.0) {
tmp = (cbrt((0.5 / a)) * cbrt((-g - g))) + cbrt(((-0.5 / a) * t_1));
} else if (t_2 <= 5e+99) {
tmp = t_4;
} else {
tmp = cbrt(((0.5 / a) * (g - g))) + ((cbrt(-0.5) * cbrt(2.0)) * (1.0 / cbrt((a / g))));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((g * g) - (h * h)));
double t_1 = g + t_0;
double t_2 = Math.cbrt(((1.0 / (a * 2.0)) * (t_0 - g))) + Math.cbrt((t_1 * (-1.0 / (a * 2.0))));
double t_3 = -0.5 * (Math.pow(h, 2.0) / g);
double t_4 = Math.cbrt(((0.5 / a) * t_3)) + Math.cbrt(((t_3 + (g * 2.0)) * (-0.5 / a)));
double tmp;
if (t_2 <= -4e-89) {
tmp = t_4;
} else if (t_2 <= 0.0) {
tmp = (Math.cbrt((0.5 / a)) * Math.cbrt((-g - g))) + Math.cbrt(((-0.5 / a) * t_1));
} else if (t_2 <= 5e+99) {
tmp = t_4;
} else {
tmp = Math.cbrt(((0.5 / a) * (g - g))) + ((Math.cbrt(-0.5) * Math.cbrt(2.0)) * (1.0 / Math.cbrt((a / g))));
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h))) t_1 = Float64(g + t_0) t_2 = Float64(cbrt(Float64(Float64(1.0 / Float64(a * 2.0)) * Float64(t_0 - g))) + cbrt(Float64(t_1 * Float64(-1.0 / Float64(a * 2.0))))) t_3 = Float64(-0.5 * Float64((h ^ 2.0) / g)) t_4 = Float64(cbrt(Float64(Float64(0.5 / a) * t_3)) + cbrt(Float64(Float64(t_3 + Float64(g * 2.0)) * Float64(-0.5 / a)))) tmp = 0.0 if (t_2 <= -4e-89) tmp = t_4; elseif (t_2 <= 0.0) tmp = Float64(Float64(cbrt(Float64(0.5 / a)) * cbrt(Float64(Float64(-g) - g))) + cbrt(Float64(Float64(-0.5 / a) * t_1))); elseif (t_2 <= 5e+99) tmp = t_4; else tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(Float64(cbrt(-0.5) * cbrt(2.0)) * Float64(1.0 / cbrt(Float64(a / g))))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(g + t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(N[(1.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$1 * N[(-1.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(-0.5 * N[(N[Power[h, 2.0], $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * t$95$3), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(t$95$3 + N[(g * 2.0), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-89], t$95$4, If[LessEqual[t$95$2, 0.0], N[(N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[((-g) - g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * t$95$1), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+99], t$95$4, N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Power[N[(a / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := g + t\_0\\
t_2 := \sqrt[3]{\frac{1}{a \cdot 2} \cdot \left(t\_0 - g\right)} + \sqrt[3]{t\_1 \cdot \frac{-1}{a \cdot 2}}\\
t_3 := -0.5 \cdot \frac{{h}^{2}}{g}\\
t_4 := \sqrt[3]{\frac{0.5}{a} \cdot t\_3} + \sqrt[3]{\left(t\_3 + g \cdot 2\right) \cdot \frac{-0.5}{a}}\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{-89}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\left(-g\right) - g} + \sqrt[3]{\frac{-0.5}{a} \cdot t\_1}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+99}:\\
\;\;\;\;t\_4\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \cdot \frac{1}{\sqrt[3]{\frac{a}{g}}}\\
\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))))))) < -4.00000000000000015e-89 or 0.0 < (+.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.00000000000000008e99Initial program 88.4%
Simplified88.4%
add-sqr-sqrt79.4%
pow279.4%
pow1/279.4%
sqrt-pow179.4%
pow279.4%
pow279.4%
metadata-eval79.4%
Applied egg-rr79.4%
Taylor expanded in h around 0 42.8%
Taylor expanded in g around inf 92.7%
if -4.00000000000000015e-89 < (+.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))))))) < 0.0Initial program 4.6%
Simplified4.6%
cbrt-prod29.7%
pow229.7%
pow229.7%
Applied egg-rr29.7%
Taylor expanded in g around -inf 98.6%
neg-mul-198.6%
Simplified98.6%
if 5.00000000000000008e99 < (+.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 0.1%
Simplified0.1%
Taylor expanded in g around inf 1.8%
clear-num1.8%
cbrt-div1.8%
metadata-eval1.8%
Applied egg-rr1.8%
Taylor expanded in g around inf 56.1%
Final simplification76.0%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (* (* (cbrt g) (/ 1.0 (cbrt a))) (* (cbrt -0.5) (cbrt 2.0)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + ((cbrt(g) * (1.0 / cbrt(a))) * (cbrt(-0.5) * cbrt(2.0)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + ((Math.cbrt(g) * (1.0 / Math.cbrt(a))) * (Math.cbrt(-0.5) * Math.cbrt(2.0)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(Float64(cbrt(g) * Float64(1.0 / cbrt(a))) * Float64(cbrt(-0.5) * cbrt(2.0)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[(1.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around inf 27.0%
cbrt-div31.3%
div-inv31.4%
Applied egg-rr31.4%
Taylor expanded in g around inf 94.6%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (* (* (cbrt -0.5) (cbrt 2.0)) (/ (cbrt g) (cbrt a)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + ((cbrt(-0.5) * cbrt(2.0)) * (cbrt(g) / cbrt(a)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + ((Math.cbrt(-0.5) * Math.cbrt(2.0)) * (Math.cbrt(g) / Math.cbrt(a)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(Float64(cbrt(-0.5) * cbrt(2.0)) * Float64(cbrt(g) / 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[(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]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \cdot \frac{\sqrt[3]{g}}{\sqrt[3]{a}}
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around inf 27.0%
cbrt-div31.3%
div-inv31.4%
Applied egg-rr31.4%
Taylor expanded in g around inf 94.6%
un-div-inv94.5%
Applied egg-rr94.5%
Final simplification94.5%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ 0.5 a) (- g g)))))
(if (<= g -1.35e+154)
(+ t_0 (* (* (cbrt -0.5) (cbrt 2.0)) (/ 1.0 (cbrt (/ a g)))))
(if (<= g 9e-201)
(+
(* (cbrt (/ 0.5 a)) (cbrt (- (- g) g)))
(cbrt (* (/ -0.5 a) (+ g (sqrt (- (* g g) (* h h)))))))
(+ t_0 (cbrt (* (/ -0.5 a) (+ g g))))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((0.5 / a) * (g - g)));
double tmp;
if (g <= -1.35e+154) {
tmp = t_0 + ((cbrt(-0.5) * cbrt(2.0)) * (1.0 / cbrt((a / g))));
} else if (g <= 9e-201) {
tmp = (cbrt((0.5 / a)) * cbrt((-g - g))) + cbrt(((-0.5 / a) * (g + sqrt(((g * g) - (h * h))))));
} else {
tmp = t_0 + cbrt(((-0.5 / a) * (g + g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((0.5 / a) * (g - g)));
double tmp;
if (g <= -1.35e+154) {
tmp = t_0 + ((Math.cbrt(-0.5) * Math.cbrt(2.0)) * (1.0 / Math.cbrt((a / g))));
} else if (g <= 9e-201) {
tmp = (Math.cbrt((0.5 / a)) * Math.cbrt((-g - g))) + Math.cbrt(((-0.5 / a) * (g + Math.sqrt(((g * g) - (h * h))))));
} else {
tmp = t_0 + Math.cbrt(((-0.5 / a) * (g + g)));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) tmp = 0.0 if (g <= -1.35e+154) tmp = Float64(t_0 + Float64(Float64(cbrt(-0.5) * cbrt(2.0)) * Float64(1.0 / cbrt(Float64(a / g))))); elseif (g <= 9e-201) tmp = Float64(Float64(cbrt(Float64(0.5 / a)) * cbrt(Float64(Float64(-g) - g))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + sqrt(Float64(Float64(g * g) - Float64(h * h))))))); else tmp = Float64(t_0 + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, -1.35e+154], N[(t$95$0 + N[(N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Power[N[(a / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 9e-201], N[(N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[((-g) - g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)}\\
\mathbf{if}\;g \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t\_0 + \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \cdot \frac{1}{\sqrt[3]{\frac{a}{g}}}\\
\mathbf{elif}\;g \leq 9 \cdot 10^{-201}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\left(-g\right) - g} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + \sqrt{g \cdot g - h \cdot h}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\
\end{array}
\end{array}
if g < -1.35000000000000003e154Initial program 0.0%
Simplified0.0%
Taylor expanded in g around inf 3.0%
clear-num3.0%
cbrt-div3.0%
metadata-eval3.0%
Applied egg-rr3.0%
Taylor expanded in g around inf 56.6%
if -1.35000000000000003e154 < g < 9.0000000000000004e-201Initial program 80.7%
Simplified80.7%
cbrt-prod88.0%
pow288.0%
pow288.0%
Applied egg-rr88.0%
Taylor expanded in g around -inf 92.5%
neg-mul-192.5%
Simplified92.5%
if 9.0000000000000004e-201 < g Initial program 46.8%
Simplified46.8%
Taylor expanded in g around inf 46.9%
Taylor expanded in g around inf 72.2%
Final simplification74.2%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (* (* (cbrt -0.5) (cbrt 2.0)) (/ 1.0 (cbrt (/ a g))))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + ((cbrt(-0.5) * cbrt(2.0)) * (1.0 / cbrt((a / g))));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + ((Math.cbrt(-0.5) * Math.cbrt(2.0)) * (1.0 / Math.cbrt((a / g))));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(Float64(cbrt(-0.5) * cbrt(2.0)) * Float64(1.0 / cbrt(Float64(a / g))))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[2.0, 1/3], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Power[N[(a / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \cdot \frac{1}{\sqrt[3]{\frac{a}{g}}}
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around inf 27.0%
clear-num26.6%
cbrt-div26.6%
metadata-eval26.6%
Applied egg-rr26.6%
Taylor expanded in g around inf 71.0%
Final simplification71.0%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (* (/ -0.5 a) (+ g g)))))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + cbrt(((-0.5 / a) * (g + g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt(((-0.5 / a) * (g + g)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))) 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[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around inf 23.1%
Taylor expanded in g around inf 70.4%
Final simplification70.4%
(FPCore (g h a) :precision binary64 (let* ((t_0 (cbrt (* (/ 0.5 a) (- g g))))) (if (<= a -4e-309) (+ t_0 (cbrt g)) (- t_0 (cbrt g)))))
double code(double g, double h, double a) {
double t_0 = cbrt(((0.5 / a) * (g - g)));
double tmp;
if (a <= -4e-309) {
tmp = t_0 + cbrt(g);
} else {
tmp = t_0 - cbrt(g);
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((0.5 / a) * (g - g)));
double tmp;
if (a <= -4e-309) {
tmp = t_0 + Math.cbrt(g);
} else {
tmp = t_0 - Math.cbrt(g);
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) tmp = 0.0 if (a <= -4e-309) tmp = Float64(t_0 + cbrt(g)); else tmp = Float64(t_0 - cbrt(g)); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[a, -4e-309], N[(t$95$0 + N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)}\\
\mathbf{if}\;a \leq -4 \cdot 10^{-309}:\\
\;\;\;\;t\_0 + \sqrt[3]{g}\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \sqrt[3]{g}\\
\end{array}
\end{array}
if a < -3.9999999999999977e-309Initial program 45.7%
Simplified45.7%
Taylor expanded in g around inf 25.4%
Taylor expanded in g around inf 73.8%
Taylor expanded in g around 0 73.8%
Simplified8.1%
if -3.9999999999999977e-309 < a Initial program 44.3%
Simplified44.3%
Taylor expanded in g around inf 20.5%
Taylor expanded in g around inf 66.5%
Taylor expanded in g around 0 66.5%
Simplified7.7%
Final simplification7.9%
(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.1%
Simplified45.1%
Taylor expanded in g around inf 23.1%
Taylor expanded in g around inf 70.4%
Taylor expanded in g around -inf 70.4%
Final simplification70.4%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt g)))
double code(double g, double h, double a) {
return cbrt(((0.5 / a) * (g - g))) + cbrt(g);
}
public static double code(double g, double h, double a) {
return Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt(g);
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(g)) end
code[g_, h_, a_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{g}
\end{array}
Initial program 45.1%
Simplified45.1%
Taylor expanded in g around inf 23.1%
Taylor expanded in g around inf 70.4%
Taylor expanded in g around 0 70.4%
Simplified4.9%
(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.1%
Simplified45.1%
Taylor expanded in g around inf 23.1%
Taylor expanded in g around inf 70.4%
cbrt-prod95.2%
flip-+0.0%
cbrt-div0.0%
unpow20.0%
unpow20.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
add-cbrt-cube0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
add-cbrt-cube0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified4.6%
herbie shell --seed 2024083
(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))))))))