2-ancestry mixing, positive discriminant

Percentage Accurate: 44.3% → 95.7%
Time: 36.1s
Alternatives: 11
Speedup: 2.1×

Specification

?
\[\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
 (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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 44.3% accurate, 1.0× speedup?

\[\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
 (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}

Alternative 1: 95.7% accurate, 0.8× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 45.1%

    \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
  2. Simplified45.1%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
  3. Add Preprocessing
  4. Taylor expanded in g around inf 27.0%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)} \]
  5. Step-by-step derivation
    1. cbrt-div31.3%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
    2. div-inv31.4%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\left(\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{a}}\right)} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  6. Applied egg-rr31.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\left(\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{a}}\right)} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  7. Taylor expanded in g around inf 94.6%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{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) \]
  8. Step-by-step derivation
    1. pow1/395.1%

      \[\leadsto \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 \color{blue}{{2}^{0.3333333333333333}}\right) \]
  9. Applied egg-rr95.1%

    \[\leadsto \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 \color{blue}{{2}^{0.3333333333333333}}\right) \]
  10. Add Preprocessing

Alternative 2: 78.0% accurate, 0.3× speedup?

\[\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} \]
(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}
Derivation
  1. Split input into 3 regimes
  2. 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.00000000000000008e99

    1. Initial program 88.4%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Simplified88.4%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt79.4%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{\sqrt{\sqrt{g \cdot g - h \cdot h}} \cdot \sqrt{\sqrt{g \cdot g - h \cdot h}}} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      2. pow279.4%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{{\left(\sqrt{\sqrt{g \cdot g - h \cdot h}}\right)}^{2}} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      3. pow1/279.4%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left({\left(\sqrt{\color{blue}{{\left(g \cdot g - h \cdot h\right)}^{0.5}}}\right)}^{2} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      4. sqrt-pow179.4%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left({\color{blue}{\left({\left(g \cdot g - h \cdot h\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      5. pow279.4%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left({\left({\left(\color{blue}{{g}^{2}} - h \cdot h\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      6. pow279.4%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left({\left({\left({g}^{2} - \color{blue}{{h}^{2}}\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      7. metadata-eval79.4%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left({\left({\left({g}^{2} - {h}^{2}\right)}^{\color{blue}{0.25}}\right)}^{2} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    5. Applied egg-rr79.4%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{{\left({\left({g}^{2} - {h}^{2}\right)}^{0.25}\right)}^{2}} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    6. Taylor expanded in h around 0 42.8%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left({\left({\left({g}^{2} - {h}^{2}\right)}^{0.25}\right)}^{2} - g\right)} + \sqrt[3]{\color{blue}{\left(-0.5 \cdot \frac{{h}^{2}}{g} + 2 \cdot g\right)} \cdot \frac{-0.5}{a}} \]
    7. Taylor expanded in g around inf 92.7%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \color{blue}{\left(-0.5 \cdot \frac{{h}^{2}}{g}\right)}} + \sqrt[3]{\left(-0.5 \cdot \frac{{h}^{2}}{g} + 2 \cdot g\right) \cdot \frac{-0.5}{a}} \]

    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.0

    1. Initial program 4.6%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Simplified4.6%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. cbrt-prod29.7%

        \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      2. pow229.7%

        \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\sqrt{\color{blue}{{g}^{2}} - h \cdot h} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      3. pow229.7%

        \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\sqrt{{g}^{2} - \color{blue}{{h}^{2}}} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    5. Applied egg-rr29.7%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\sqrt{{g}^{2} - {h}^{2}} - g}} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    6. Taylor expanded in g around -inf 98.6%

      \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\color{blue}{-1 \cdot g} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    7. Step-by-step derivation
      1. neg-mul-198.6%

        \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\color{blue}{\left(-g\right)} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    8. Simplified98.6%

      \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\color{blue}{\left(-g\right)} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]

    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)))))))

    1. Initial program 0.1%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Simplified0.1%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
    3. Add Preprocessing
    4. Taylor expanded in g around inf 1.8%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)} \]
    5. Step-by-step derivation
      1. clear-num1.8%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\color{blue}{\frac{1}{\frac{a}{g}}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
      2. cbrt-div1.8%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{a}{g}}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
      3. metadata-eval1.8%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \frac{\color{blue}{1}}{\sqrt[3]{\frac{a}{g}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
    6. Applied egg-rr1.8%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\frac{1}{\sqrt[3]{\frac{a}{g}}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
    7. Taylor expanded in g around inf 56.1%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \frac{1}{\sqrt[3]{\frac{a}{g}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt[3]{\frac{1}{a \cdot 2} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-1}{a \cdot 2}} \leq -4 \cdot 10^{-89}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(-0.5 \cdot \frac{{h}^{2}}{g}\right)} + \sqrt[3]{\left(-0.5 \cdot \frac{{h}^{2}}{g} + g \cdot 2\right) \cdot \frac{-0.5}{a}}\\ \mathbf{elif}\;\sqrt[3]{\frac{1}{a \cdot 2} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-1}{a \cdot 2}} \leq 0:\\ \;\;\;\;\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{elif}\;\sqrt[3]{\frac{1}{a \cdot 2} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-1}{a \cdot 2}} \leq 5 \cdot 10^{+99}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(-0.5 \cdot \frac{{h}^{2}}{g}\right)} + \sqrt[3]{\left(-0.5 \cdot \frac{{h}^{2}}{g} + g \cdot 2\right) \cdot \frac{-0.5}{a}}\\ \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} \]
  5. Add Preprocessing

Alternative 3: 95.0% accurate, 0.8× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 45.1%

    \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
  2. Simplified45.1%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
  3. Add Preprocessing
  4. Taylor expanded in g around inf 27.0%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)} \]
  5. Step-by-step derivation
    1. cbrt-div31.3%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
    2. div-inv31.4%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\left(\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{a}}\right)} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  6. Applied egg-rr31.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\left(\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{a}}\right)} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  7. Taylor expanded in g around inf 94.6%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{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) \]
  8. Add Preprocessing

Alternative 4: 95.0% accurate, 0.8× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 45.1%

    \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
  2. Simplified45.1%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
  3. Add Preprocessing
  4. Taylor expanded in g around inf 27.0%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)} \]
  5. Step-by-step derivation
    1. cbrt-div31.3%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
    2. div-inv31.4%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\left(\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{a}}\right)} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  6. Applied egg-rr31.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\left(\sqrt[3]{g} \cdot \frac{1}{\sqrt[3]{a}}\right)} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  7. Taylor expanded in g around inf 94.6%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{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) \]
  8. Step-by-step derivation
    1. un-div-inv94.5%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  9. Applied egg-rr94.5%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{\frac{\sqrt[3]{g}}{\sqrt[3]{a}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  10. Final simplification94.5%

    \[\leadsto \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}} \]
  11. Add Preprocessing

Alternative 5: 76.5% accurate, 1.0× speedup?

\[\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} \]
(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}
Derivation
  1. Split input into 3 regimes
  2. if g < -1.35000000000000003e154

    1. Initial program 0.0%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Simplified0.0%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
    3. Add Preprocessing
    4. Taylor expanded in g around inf 3.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)} \]
    5. Step-by-step derivation
      1. clear-num3.0%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\color{blue}{\frac{1}{\frac{a}{g}}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
      2. cbrt-div3.0%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{a}{g}}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
      3. metadata-eval3.0%

        \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \frac{\color{blue}{1}}{\sqrt[3]{\frac{a}{g}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
    6. Applied egg-rr3.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\frac{1}{\sqrt[3]{\frac{a}{g}}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
    7. Taylor expanded in g around inf 56.6%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \frac{1}{\sqrt[3]{\frac{a}{g}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]

    if -1.35000000000000003e154 < g < 9.0000000000000004e-201

    1. Initial program 80.7%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Simplified80.7%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. cbrt-prod88.0%

        \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      2. pow288.0%

        \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\sqrt{\color{blue}{{g}^{2}} - h \cdot h} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
      3. pow288.0%

        \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\sqrt{{g}^{2} - \color{blue}{{h}^{2}}} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    5. Applied egg-rr88.0%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\sqrt{{g}^{2} - {h}^{2}} - g}} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    6. Taylor expanded in g around -inf 92.5%

      \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\color{blue}{-1 \cdot g} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    7. Step-by-step derivation
      1. neg-mul-192.5%

        \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\color{blue}{\left(-g\right)} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    8. Simplified92.5%

      \[\leadsto \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\color{blue}{\left(-g\right)} - g} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]

    if 9.0000000000000004e-201 < g

    1. Initial program 46.8%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Simplified46.8%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
    3. Add Preprocessing
    4. Taylor expanded in g around inf 46.9%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    5. Taylor expanded in g around inf 72.2%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\left(g + \color{blue}{g}\right) \cdot \frac{-0.5}{a}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;g \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\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}}}\\ \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}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 73.8% accurate, 1.0× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 45.1%

    \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
  2. Simplified45.1%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
  3. Add Preprocessing
  4. Taylor expanded in g around inf 27.0%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)} \]
  5. Step-by-step derivation
    1. clear-num26.6%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\color{blue}{\frac{1}{\frac{a}{g}}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
    2. cbrt-div26.6%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{a}{g}}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
    3. metadata-eval26.6%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \frac{\color{blue}{1}}{\sqrt[3]{\frac{a}{g}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  6. Applied egg-rr26.6%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\frac{1}{\sqrt[3]{\frac{a}{g}}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  7. Taylor expanded in g around inf 71.0%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \frac{1}{\sqrt[3]{\frac{a}{g}}} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
  8. Final simplification71.0%

    \[\leadsto \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}}} \]
  9. Add Preprocessing

Alternative 7: 73.6% accurate, 2.0× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 45.1%

    \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
  2. Simplified45.1%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
  3. Add Preprocessing
  4. Taylor expanded in g around inf 23.1%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
  5. Taylor expanded in g around inf 70.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\left(g + \color{blue}{g}\right) \cdot \frac{-0.5}{a}} \]
  6. Final simplification70.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)} \]
  7. Add Preprocessing

Alternative 8: 7.9% accurate, 2.0× speedup?

\[\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} \]
(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}
Derivation
  1. Split input into 2 regimes
  2. if a < -3.9999999999999977e-309

    1. Initial program 45.7%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Simplified45.7%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
    3. Add Preprocessing
    4. Taylor expanded in g around inf 25.4%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    5. Taylor expanded in g around inf 73.8%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\left(g + \color{blue}{g}\right) \cdot \frac{-0.5}{a}} \]
    6. Taylor expanded in g around 0 73.8%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
    7. Simplified8.1%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\color{blue}{g}} \]

    if -3.9999999999999977e-309 < a

    1. Initial program 44.3%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Simplified44.3%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
    3. Add Preprocessing
    4. Taylor expanded in g around inf 20.5%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    5. Taylor expanded in g around inf 66.5%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\left(g + \color{blue}{g}\right) \cdot \frac{-0.5}{a}} \]
    6. Taylor expanded in g around 0 66.5%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}} \]
    7. Simplified7.7%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{\left(-\sqrt[3]{g}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4 \cdot 10^{-309}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{g}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{g}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 73.6% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{\frac{g}{a}} \end{array} \]
(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}
Derivation
  1. Initial program 45.1%

    \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
  2. Simplified45.1%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
  3. Add Preprocessing
  4. Taylor expanded in g around inf 23.1%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
  5. Taylor expanded in g around inf 70.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\left(g + \color{blue}{g}\right) \cdot \frac{-0.5}{a}} \]
  6. Taylor expanded in g around -inf 70.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{-1 \cdot \sqrt[3]{\frac{g}{a}}} \]
  7. Final simplification70.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{\frac{g}{a}} \]
  8. Add Preprocessing

Alternative 10: 4.6% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{g} \end{array} \]
(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}
Derivation
  1. Initial program 45.1%

    \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
  2. Simplified45.1%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
  3. Add Preprocessing
  4. Taylor expanded in g around inf 23.1%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
  5. Taylor expanded in g around inf 70.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\left(g + \color{blue}{g}\right) \cdot \frac{-0.5}{a}} \]
  6. Taylor expanded in g around 0 70.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
  7. Simplified4.9%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\color{blue}{g}} \]
  8. Add Preprocessing

Alternative 11: 4.5% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + -1 \end{array} \]
(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}
Derivation
  1. Initial program 45.1%

    \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
  2. Simplified45.1%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}}} \]
  3. Add Preprocessing
  4. Taylor expanded in g around inf 23.1%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
  5. Taylor expanded in g around inf 70.4%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\left(g + \color{blue}{g}\right) \cdot \frac{-0.5}{a}} \]
  6. Step-by-step derivation
    1. cbrt-prod95.2%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{\sqrt[3]{g + g} \cdot \sqrt[3]{\frac{-0.5}{a}}} \]
    2. flip-+0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\color{blue}{\frac{g \cdot g - g \cdot g}{g - g}}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    3. cbrt-div0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{\frac{\sqrt[3]{g \cdot g - g \cdot g}}{\sqrt[3]{g - g}}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    4. unpow20.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{g \cdot g - \color{blue}{{g}^{2}}}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    5. unpow20.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{\color{blue}{{g}^{2}} - {g}^{2}}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    6. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{\color{blue}{0}}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    7. metadata-eval0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{\color{blue}{0 \cdot 0}}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    8. metadata-eval0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{\color{blue}{\left(0 \cdot 0\right)} \cdot 0}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    9. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{\left(\color{blue}{\left(g - g\right)} \cdot 0\right) \cdot 0}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    10. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{\left(\left(g - g\right) \cdot \color{blue}{\left(g - g\right)}\right) \cdot 0}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    11. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{\left(\left(g - g\right) \cdot \left(g - g\right)\right) \cdot \color{blue}{\left(g - g\right)}}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    12. add-cbrt-cube0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\color{blue}{g - g}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    13. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\color{blue}{0}}{\sqrt[3]{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    14. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{0}{\sqrt[3]{\color{blue}{0}}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    15. metadata-eval0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{0}{\sqrt[3]{\color{blue}{0 \cdot 0}}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    16. metadata-eval0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{0}{\sqrt[3]{\color{blue}{\left(0 \cdot 0\right)} \cdot 0}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    17. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{0}{\sqrt[3]{\left(\color{blue}{\left(g - g\right)} \cdot 0\right) \cdot 0}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    18. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{0}{\sqrt[3]{\left(\left(g - g\right) \cdot \color{blue}{\left(g - g\right)}\right) \cdot 0}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    19. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{0}{\sqrt[3]{\left(\left(g - g\right) \cdot \left(g - g\right)\right) \cdot \color{blue}{\left(g - g\right)}}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    20. add-cbrt-cube0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{0}{\color{blue}{g - g}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
    21. +-inverses0.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{0}{\color{blue}{0}} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
  7. Applied egg-rr0.0%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{\frac{0}{0} \cdot \sqrt[3]{\frac{-0.5}{a}}} \]
  8. Simplified4.6%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{-1} \]
  9. Add Preprocessing

Reproduce

?
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))))))))