2-ancestry mixing, positive discriminant

Percentage Accurate: 44.6% → 76.3%
Time: 18.5s
Alternatives: 5
Speedup: 2.0×

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 5 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.6% 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: 76.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{{g}^{2} - {h}^{2}}\\ t_1 := \sqrt{g \cdot g - h \cdot h}\\ \mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t_1 - g\right)} + \sqrt[3]{\left(g + t_1\right) \cdot \frac{-1}{2 \cdot a}} \leq 4 \cdot 10^{-100}:\\ \;\;\;\;\frac{\sqrt[3]{0.5 \cdot \left(t_0 - g\right)}}{\sqrt[3]{a}} + \sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + t_0}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}}\\ \end{array} \end{array} \]
(FPCore (g h a)
 :precision binary64
 (let* ((t_0 (sqrt (- (pow g 2.0) (pow h 2.0))))
        (t_1 (sqrt (- (* g g) (* h h)))))
   (if (<=
        (+
         (cbrt (* (/ 1.0 (* 2.0 a)) (- t_1 g)))
         (cbrt (* (+ g t_1) (/ -1.0 (* 2.0 a)))))
        4e-100)
     (+
      (/ (cbrt (* 0.5 (- t_0 g))) (cbrt a))
      (* (cbrt (/ -0.5 a)) (cbrt (+ g t_0))))
     (+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ (- g) a))))))
double code(double g, double h, double a) {
	double t_0 = sqrt((pow(g, 2.0) - pow(h, 2.0)));
	double t_1 = sqrt(((g * g) - (h * h)));
	double tmp;
	if ((cbrt(((1.0 / (2.0 * a)) * (t_1 - g))) + cbrt(((g + t_1) * (-1.0 / (2.0 * a))))) <= 4e-100) {
		tmp = (cbrt((0.5 * (t_0 - g))) / cbrt(a)) + (cbrt((-0.5 / a)) * cbrt((g + t_0)));
	} else {
		tmp = cbrt(((0.5 / a) * (g - g))) + cbrt((-g / a));
	}
	return tmp;
}
public static double code(double g, double h, double a) {
	double t_0 = Math.sqrt((Math.pow(g, 2.0) - Math.pow(h, 2.0)));
	double t_1 = Math.sqrt(((g * g) - (h * h)));
	double tmp;
	if ((Math.cbrt(((1.0 / (2.0 * a)) * (t_1 - g))) + Math.cbrt(((g + t_1) * (-1.0 / (2.0 * a))))) <= 4e-100) {
		tmp = (Math.cbrt((0.5 * (t_0 - g))) / Math.cbrt(a)) + (Math.cbrt((-0.5 / a)) * Math.cbrt((g + t_0)));
	} else {
		tmp = Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt((-g / a));
	}
	return tmp;
}
function code(g, h, a)
	t_0 = sqrt(Float64((g ^ 2.0) - (h ^ 2.0)))
	t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h)))
	tmp = 0.0
	if (Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(t_1 - g))) + cbrt(Float64(Float64(g + t_1) * Float64(-1.0 / Float64(2.0 * a))))) <= 4e-100)
		tmp = Float64(Float64(cbrt(Float64(0.5 * Float64(t_0 - g))) / cbrt(a)) + Float64(cbrt(Float64(-0.5 / a)) * cbrt(Float64(g + t_0))));
	else
		tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(Float64(-g) / a)));
	end
	return tmp
end
code[g_, h_, a_] := Block[{t$95$0 = N[Sqrt[N[(N[Power[g, 2.0], $MachinePrecision] - N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(g + t$95$1), $MachinePrecision] * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 4e-100], N[(N[(N[Power[N[(0.5 * N[(t$95$0 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[(-0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g + t$95$0), $MachinePrecision], 1/3], $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}
t_0 := \sqrt{{g}^{2} - {h}^{2}}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t_1 - g\right)} + \sqrt[3]{\left(g + t_1\right) \cdot \frac{-1}{2 \cdot a}} \leq 4 \cdot 10^{-100}:\\
\;\;\;\;\frac{\sqrt[3]{0.5 \cdot \left(t_0 - g\right)}}{\sqrt[3]{a}} + \sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + t_0}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 4.0000000000000001e-100

    1. Initial program 74.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. Simplified74.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. Step-by-step derivation
      1. *-commutative74.3%

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

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

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

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

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + \sqrt{{g}^{2} - {h}^{2}}}} \]
    6. Step-by-step derivation
      1. associate-*l/80.5%

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

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

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

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

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

    if 4.0000000000000001e-100 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))))

    1. Initial program 28.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. Simplified28.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 13.3%

      \[\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 75.3%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
    6. Step-by-step derivation
      1. associate-*r/75.3%

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

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

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

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

Alternative 2: 74.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{g \cdot g - h \cdot h}\\ t_1 := g + t_0\\ \mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t_0 - g\right)} + \sqrt[3]{t_1 \cdot \frac{-1}{2 \cdot a}} \leq 4 \cdot 10^{-100}:\\ \;\;\;\;\frac{\sqrt[3]{0.5 \cdot \left(\sqrt{{g}^{2} - {h}^{2}} - g\right)}}{\sqrt[3]{a}} + \sqrt[3]{\frac{-0.5}{a} \cdot t_1}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}}\\ \end{array} \end{array} \]
(FPCore (g h a)
 :precision binary64
 (let* ((t_0 (sqrt (- (* g g) (* h h)))) (t_1 (+ g t_0)))
   (if (<=
        (+
         (cbrt (* (/ 1.0 (* 2.0 a)) (- t_0 g)))
         (cbrt (* t_1 (/ -1.0 (* 2.0 a)))))
        4e-100)
     (+
      (/ (cbrt (* 0.5 (- (sqrt (- (pow g 2.0) (pow h 2.0))) g))) (cbrt a))
      (cbrt (* (/ -0.5 a) t_1)))
     (+ (cbrt (* (/ 0.5 a) (- g g))) (cbrt (/ (- g) a))))))
double code(double g, double h, double a) {
	double t_0 = sqrt(((g * g) - (h * h)));
	double t_1 = g + t_0;
	double tmp;
	if ((cbrt(((1.0 / (2.0 * a)) * (t_0 - g))) + cbrt((t_1 * (-1.0 / (2.0 * a))))) <= 4e-100) {
		tmp = (cbrt((0.5 * (sqrt((pow(g, 2.0) - pow(h, 2.0))) - g))) / cbrt(a)) + cbrt(((-0.5 / a) * t_1));
	} else {
		tmp = cbrt(((0.5 / a) * (g - g))) + cbrt((-g / a));
	}
	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 tmp;
	if ((Math.cbrt(((1.0 / (2.0 * a)) * (t_0 - g))) + Math.cbrt((t_1 * (-1.0 / (2.0 * a))))) <= 4e-100) {
		tmp = (Math.cbrt((0.5 * (Math.sqrt((Math.pow(g, 2.0) - Math.pow(h, 2.0))) - g))) / Math.cbrt(a)) + Math.cbrt(((-0.5 / a) * t_1));
	} else {
		tmp = Math.cbrt(((0.5 / a) * (g - g))) + Math.cbrt((-g / a));
	}
	return tmp;
}
function code(g, h, a)
	t_0 = sqrt(Float64(Float64(g * g) - Float64(h * h)))
	t_1 = Float64(g + t_0)
	tmp = 0.0
	if (Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(t_0 - g))) + cbrt(Float64(t_1 * Float64(-1.0 / Float64(2.0 * a))))) <= 4e-100)
		tmp = Float64(Float64(cbrt(Float64(0.5 * Float64(sqrt(Float64((g ^ 2.0) - (h ^ 2.0))) - g))) / cbrt(a)) + cbrt(Float64(Float64(-0.5 / a) * t_1)));
	else
		tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + cbrt(Float64(Float64(-g) / a)));
	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]}, If[LessEqual[N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$1 * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 4e-100], N[(N[(N[Power[N[(0.5 * N[(N[Sqrt[N[(N[Power[g, 2.0], $MachinePrecision] - N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * t$95$1), $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}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := g + t_0\\
\mathbf{if}\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(t_0 - g\right)} + \sqrt[3]{t_1 \cdot \frac{-1}{2 \cdot a}} \leq 4 \cdot 10^{-100}:\\
\;\;\;\;\frac{\sqrt[3]{0.5 \cdot \left(\sqrt{{g}^{2} - {h}^{2}} - g\right)}}{\sqrt[3]{a}} + \sqrt[3]{\frac{-0.5}{a} \cdot t_1}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 4.0000000000000001e-100

    1. Initial program 74.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. Simplified74.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. Step-by-step derivation
      1. associate-*l/80.5%

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

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

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

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

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

    if 4.0000000000000001e-100 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))))

    1. Initial program 28.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. Simplified28.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 13.3%

      \[\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 75.3%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
    6. Step-by-step derivation
      1. associate-*r/75.3%

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

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

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

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

Alternative 3: 76.8% accurate, 0.6× 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.9 \cdot 10^{-157}:\\ \;\;\;\;t_0 + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\ \mathbf{elif}\;g \leq 1.25 \cdot 10^{+153}:\\ \;\;\;\;\sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + \sqrt{{g}^{2} - {h}^{2}}} + \sqrt[3]{\left(\sqrt{g \cdot g - h \cdot h} - g\right) \cdot \frac{0.5}{a}}\\ \mathbf{else}:\\ \;\;\;\;t_0 + \sqrt[3]{\frac{-g}{a}}\\ \end{array} \end{array} \]
(FPCore (g h a)
 :precision binary64
 (let* ((t_0 (cbrt (* (/ 0.5 a) (- g g)))))
   (if (<= g 1.9e-157)
     (+ t_0 (cbrt (* (/ -0.5 a) (+ g g))))
     (if (<= g 1.25e+153)
       (+
        (* (cbrt (/ -0.5 a)) (cbrt (+ g (sqrt (- (pow g 2.0) (pow h 2.0))))))
        (cbrt (* (- (sqrt (- (* g g) (* h h))) g) (/ 0.5 a))))
       (+ t_0 (cbrt (/ (- g) a)))))))
double code(double g, double h, double a) {
	double t_0 = cbrt(((0.5 / a) * (g - g)));
	double tmp;
	if (g <= 1.9e-157) {
		tmp = t_0 + cbrt(((-0.5 / a) * (g + g)));
	} else if (g <= 1.25e+153) {
		tmp = (cbrt((-0.5 / a)) * cbrt((g + sqrt((pow(g, 2.0) - pow(h, 2.0)))))) + cbrt(((sqrt(((g * g) - (h * h))) - g) * (0.5 / a)));
	} else {
		tmp = t_0 + cbrt((-g / a));
	}
	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.9e-157) {
		tmp = t_0 + Math.cbrt(((-0.5 / a) * (g + g)));
	} else if (g <= 1.25e+153) {
		tmp = (Math.cbrt((-0.5 / a)) * Math.cbrt((g + Math.sqrt((Math.pow(g, 2.0) - Math.pow(h, 2.0)))))) + Math.cbrt(((Math.sqrt(((g * g) - (h * h))) - g) * (0.5 / a)));
	} else {
		tmp = t_0 + Math.cbrt((-g / a));
	}
	return tmp;
}
function code(g, h, a)
	t_0 = cbrt(Float64(Float64(0.5 / a) * Float64(g - g)))
	tmp = 0.0
	if (g <= 1.9e-157)
		tmp = Float64(t_0 + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))));
	elseif (g <= 1.25e+153)
		tmp = Float64(Float64(cbrt(Float64(-0.5 / a)) * cbrt(Float64(g + sqrt(Float64((g ^ 2.0) - (h ^ 2.0)))))) + cbrt(Float64(Float64(sqrt(Float64(Float64(g * g) - Float64(h * h))) - g) * Float64(0.5 / a))));
	else
		tmp = Float64(t_0 + cbrt(Float64(Float64(-g) / a)));
	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.9e-157], N[(t$95$0 + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[g, 1.25e+153], N[(N[(N[Power[N[(-0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g + N[Sqrt[N[(N[Power[g, 2.0], $MachinePrecision] - N[Power[h, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[Power[N[((-g) / a), $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.9 \cdot 10^{-157}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\

\mathbf{elif}\;g \leq 1.25 \cdot 10^{+153}:\\
\;\;\;\;\sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + \sqrt{{g}^{2} - {h}^{2}}} + \sqrt[3]{\left(\sqrt{g \cdot g - h \cdot h} - g\right) \cdot \frac{0.5}{a}}\\

\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{-g}{a}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if g < 1.9000000000000001e-157

    1. Initial program 46.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. Simplified46.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 4.0%

      \[\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 78.6%

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

    if 1.9000000000000001e-157 < g < 1.25000000000000005e153

    1. Initial program 83.2%

      \[\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. Simplified83.2%

      \[\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. *-commutative83.2%

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

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

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

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

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

    if 1.25000000000000005e153 < g

    1. Initial program 3.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. Simplified3.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 6.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 64.0%

      \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
    6. Step-by-step derivation
      1. associate-*r/64.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;g \leq 1.9 \cdot 10^{-157}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\ \mathbf{elif}\;g \leq 1.25 \cdot 10^{+153}:\\ \;\;\;\;\sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + \sqrt{{g}^{2} - {h}^{2}}} + \sqrt[3]{\left(\sqrt{g \cdot g - h \cdot h} - g\right) \cdot \frac{0.5}{a}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.4% 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 43.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. Simplified43.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. Taylor expanded in g around inf 21.8%

    \[\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 75.6%

    \[\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 simplification75.6%

    \[\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 5: 73.4% accurate, 2.0× 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(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 43.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. Simplified43.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. Taylor expanded in g around inf 21.8%

    \[\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 75.6%

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
  6. Step-by-step derivation
    1. associate-*r/75.6%

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

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

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

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

Reproduce

?
herbie shell --seed 2024011 
(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))))))))