2-ancestry mixing, positive discriminant

Percentage Accurate: 43.9% → 95.4%
Time: 22.9s
Alternatives: 8
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 8 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: 43.9% 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.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} \end{array} \]
(FPCore (g h a)
 :precision binary64
 (+ (* (cbrt (/ 0.5 a)) (cbrt (* g -2.0))) (cbrt (* (- g g) (/ -0.5 a)))))
double code(double g, double h, double a) {
	return (cbrt((0.5 / a)) * cbrt((g * -2.0))) + cbrt(((g - g) * (-0.5 / a)));
}
public static double code(double g, double h, double a) {
	return (Math.cbrt((0.5 / a)) * Math.cbrt((g * -2.0))) + Math.cbrt(((g - g) * (-0.5 / a)));
}
function code(g, h, a)
	return Float64(Float64(cbrt(Float64(0.5 / a)) * cbrt(Float64(g * -2.0))) + cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))))
end
code[g_, h_, a_] := N[(N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}
\end{array}
Derivation
  1. Initial program 44.5%

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

    \[\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. Taylor expanded in g around -inf 25.5%

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

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

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

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

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

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

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

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

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

Alternative 2: 95.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \frac{\sqrt[3]{-g}}{\sqrt[3]{a}} \end{array} \]
(FPCore (g h a)
 :precision binary64
 (+ (cbrt (* (- g g) (/ -0.5 a))) (/ (cbrt (- g)) (cbrt a))))
double code(double g, double h, double a) {
	return cbrt(((g - g) * (-0.5 / a))) + (cbrt(-g) / cbrt(a));
}
public static double code(double g, double h, double a) {
	return Math.cbrt(((g - g) * (-0.5 / a))) + (Math.cbrt(-g) / Math.cbrt(a));
}
function code(g, h, a)
	return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + Float64(cbrt(Float64(-g)) / cbrt(a)))
end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \frac{\sqrt[3]{-g}}{\sqrt[3]{a}}
\end{array}
Derivation
  1. Initial program 44.5%

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

    \[\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. Taylor expanded in g around -inf 25.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 88.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -3.5 \cdot 10^{-19} \lor \neg \left(a \leq 1.4 \cdot 10^{-44}\right):\\ \;\;\;\;\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{-\frac{g}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{-2}\\ \end{array} \end{array} \]
(FPCore (g h a)
 :precision binary64
 (if (or (<= a -3.5e-19) (not (<= a 1.4e-44)))
   (+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (- (/ g a))))
   (+ (/ (cbrt (- g)) (cbrt a)) (cbrt -2.0))))
double code(double g, double h, double a) {
	double tmp;
	if ((a <= -3.5e-19) || !(a <= 1.4e-44)) {
		tmp = cbrt(((g - g) * (-0.5 / a))) + cbrt(-(g / a));
	} else {
		tmp = (cbrt(-g) / cbrt(a)) + cbrt(-2.0);
	}
	return tmp;
}
public static double code(double g, double h, double a) {
	double tmp;
	if ((a <= -3.5e-19) || !(a <= 1.4e-44)) {
		tmp = Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt(-(g / a));
	} else {
		tmp = (Math.cbrt(-g) / Math.cbrt(a)) + Math.cbrt(-2.0);
	}
	return tmp;
}
function code(g, h, a)
	tmp = 0.0
	if ((a <= -3.5e-19) || !(a <= 1.4e-44))
		tmp = Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(-Float64(g / a))));
	else
		tmp = Float64(Float64(cbrt(Float64(-g)) / cbrt(a)) + cbrt(-2.0));
	end
	return tmp
end
code[g_, h_, a_] := If[Or[LessEqual[a, -3.5e-19], N[Not[LessEqual[a, 1.4e-44]], $MachinePrecision]], N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[(-N[(g / a), $MachinePrecision]), 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.5 \cdot 10^{-19} \lor \neg \left(a \leq 1.4 \cdot 10^{-44}\right):\\
\;\;\;\;\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{-\frac{g}{a}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -3.50000000000000015e-19 or 1.4e-44 < a

    1. Initial program 47.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. Simplified47.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. Taylor expanded in g around -inf 28.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.50000000000000015e-19 < a < 1.4e-44

    1. Initial program 40.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. Simplified40.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. Taylor expanded in g around -inf 21.8%

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{0}{0}}{a}\right)} - 1}} + \sqrt[3]{\left(g + g\right) \cdot \frac{-0.5}{a}} \]
    8. Simplified47.3%

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

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

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

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

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

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

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

        \[\leadsto \sqrt[3]{-2} + \sqrt[3]{\sqrt{\frac{\color{blue}{0.25}}{a \cdot a} \cdot \left(\left(g + g\right) \cdot \left(g + g\right)\right)}} \]
      8. metadata-eval6.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{-2} + \color{blue}{\frac{\sqrt[3]{-g}}{\sqrt[3]{a}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -3.5 \cdot 10^{-19} \lor \neg \left(a \leq 1.4 \cdot 10^{-44}\right):\\ \;\;\;\;\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{-\frac{g}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{-2}\\ \end{array} \]

Alternative 4: 47.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;g \leq -2.7 \lor \neg \left(g \leq 0.37\right):\\ \;\;\;\;\sqrt[3]{-\frac{g}{a}} + \sqrt[3]{-2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{-g} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\ \end{array} \end{array} \]
(FPCore (g h a)
 :precision binary64
 (if (or (<= g -2.7) (not (<= g 0.37)))
   (+ (cbrt (- (/ g a))) (cbrt -2.0))
   (+ (cbrt (- g)) (cbrt (* (/ -0.5 a) (+ g g))))))
double code(double g, double h, double a) {
	double tmp;
	if ((g <= -2.7) || !(g <= 0.37)) {
		tmp = cbrt(-(g / a)) + cbrt(-2.0);
	} else {
		tmp = cbrt(-g) + cbrt(((-0.5 / a) * (g + g)));
	}
	return tmp;
}
public static double code(double g, double h, double a) {
	double tmp;
	if ((g <= -2.7) || !(g <= 0.37)) {
		tmp = Math.cbrt(-(g / a)) + Math.cbrt(-2.0);
	} else {
		tmp = Math.cbrt(-g) + Math.cbrt(((-0.5 / a) * (g + g)));
	}
	return tmp;
}
function code(g, h, a)
	tmp = 0.0
	if ((g <= -2.7) || !(g <= 0.37))
		tmp = Float64(cbrt(Float64(-Float64(g / a))) + cbrt(-2.0));
	else
		tmp = Float64(cbrt(Float64(-g)) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))));
	end
	return tmp
end
code[g_, h_, a_] := If[Or[LessEqual[g, -2.7], N[Not[LessEqual[g, 0.37]], $MachinePrecision]], N[(N[Power[(-N[(g / a), $MachinePrecision]), 1/3], $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[(-g), 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;g \leq -2.7 \lor \neg \left(g \leq 0.37\right):\\
\;\;\;\;\sqrt[3]{-\frac{g}{a}} + \sqrt[3]{-2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if g < -2.7000000000000002 or 0.37 < g

    1. Initial program 37.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. Simplified37.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. Taylor expanded in g around -inf 20.7%

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{0}{0}}{a}\right)} - 1}} + \sqrt[3]{\left(g + g\right) \cdot \frac{-0.5}{a}} \]
    8. Simplified49.9%

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

      \[\leadsto \sqrt[3]{-2} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]

    if -2.7000000000000002 < g < 0.37

    1. Initial program 63.5%

      \[\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. Simplified63.5%

      \[\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. Taylor expanded in g around -inf 39.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;g \leq -2.7 \lor \neg \left(g \leq 0.37\right):\\ \;\;\;\;\sqrt[3]{-\frac{g}{a}} + \sqrt[3]{-2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{-g} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}\\ \end{array} \]

Alternative 5: 47.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;g \leq -1.75 \lor \neg \left(g \leq 4.3 \cdot 10^{+17}\right):\\ \;\;\;\;\sqrt[3]{-\frac{g}{a}} + \sqrt[3]{-2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)} + \sqrt[3]{g}\\ \end{array} \end{array} \]
(FPCore (g h a)
 :precision binary64
 (if (or (<= g -1.75) (not (<= g 4.3e+17)))
   (+ (cbrt (- (/ g a))) (cbrt -2.0))
   (+ (cbrt (* (/ -0.5 a) (+ g g))) (cbrt g))))
double code(double g, double h, double a) {
	double tmp;
	if ((g <= -1.75) || !(g <= 4.3e+17)) {
		tmp = cbrt(-(g / a)) + cbrt(-2.0);
	} else {
		tmp = cbrt(((-0.5 / a) * (g + g))) + cbrt(g);
	}
	return tmp;
}
public static double code(double g, double h, double a) {
	double tmp;
	if ((g <= -1.75) || !(g <= 4.3e+17)) {
		tmp = Math.cbrt(-(g / a)) + Math.cbrt(-2.0);
	} else {
		tmp = Math.cbrt(((-0.5 / a) * (g + g))) + Math.cbrt(g);
	}
	return tmp;
}
function code(g, h, a)
	tmp = 0.0
	if ((g <= -1.75) || !(g <= 4.3e+17))
		tmp = Float64(cbrt(Float64(-Float64(g / a))) + cbrt(-2.0));
	else
		tmp = Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + g))) + cbrt(g));
	end
	return tmp
end
code[g_, h_, a_] := If[Or[LessEqual[g, -1.75], N[Not[LessEqual[g, 4.3e+17]], $MachinePrecision]], N[(N[Power[(-N[(g / a), $MachinePrecision]), 1/3], $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision], 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}

\\
\begin{array}{l}
\mathbf{if}\;g \leq -1.75 \lor \neg \left(g \leq 4.3 \cdot 10^{+17}\right):\\
\;\;\;\;\sqrt[3]{-\frac{g}{a}} + \sqrt[3]{-2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if g < -1.75 or 4.3e17 < g

    1. Initial program 36.5%

      \[\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. Simplified36.5%

      \[\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. Taylor expanded in g around -inf 20.7%

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{0}{0}}{a}\right)} - 1}} + \sqrt[3]{\left(g + g\right) \cdot \frac{-0.5}{a}} \]
    8. Simplified50.0%

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

      \[\leadsto \sqrt[3]{-2} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]

    if -1.75 < g < 4.3e17

    1. Initial program 65.5%

      \[\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. Simplified65.5%

      \[\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. Taylor expanded in g around -inf 38.1%

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

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

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

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

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

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

        \[\leadsto \sqrt[3]{\frac{1}{\frac{a}{0.5 \cdot \color{blue}{\left(-2 \cdot g\right)}}}} + \sqrt[3]{\left(g + g\right) \cdot \frac{-0.5}{a}} \]
      4. associate-*r*17.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;g \leq -1.75 \lor \neg \left(g \leq 4.3 \cdot 10^{+17}\right):\\ \;\;\;\;\sqrt[3]{-\frac{g}{a}} + \sqrt[3]{-2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)} + \sqrt[3]{g}\\ \end{array} \]

Alternative 6: 73.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{-\frac{g}{a}} \end{array} \]
(FPCore (g h a)
 :precision binary64
 (+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (- (/ g a)))))
double code(double g, double h, double a) {
	return cbrt(((g - g) * (-0.5 / a))) + cbrt(-(g / a));
}
public static double code(double g, double h, double a) {
	return Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt(-(g / a));
}
function code(g, h, a)
	return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(-Float64(g / a))))
end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[(-N[(g / a), $MachinePrecision]), 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{-\frac{g}{a}}
\end{array}
Derivation
  1. Initial program 44.5%

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

    \[\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. Taylor expanded in g around -inf 25.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 43.3% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \sqrt[3]{-\frac{g}{a}} + \sqrt[3]{-2} \end{array} \]
(FPCore (g h a) :precision binary64 (+ (cbrt (- (/ g a))) (cbrt -2.0)))
double code(double g, double h, double a) {
	return cbrt(-(g / a)) + cbrt(-2.0);
}
public static double code(double g, double h, double a) {
	return Math.cbrt(-(g / a)) + Math.cbrt(-2.0);
}
function code(g, h, a)
	return Float64(cbrt(Float64(-Float64(g / a))) + cbrt(-2.0))
end
code[g_, h_, a_] := N[(N[Power[(-N[(g / a), $MachinePrecision]), 1/3], $MachinePrecision] + N[Power[-2.0, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sqrt[3]{-\frac{g}{a}} + \sqrt[3]{-2}
\end{array}
Derivation
  1. Initial program 44.5%

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

    \[\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. Taylor expanded in g around -inf 25.5%

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

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

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

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

    \[\leadsto \sqrt[3]{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{0}{0}}{a}\right)} - 1}} + \sqrt[3]{\left(g + g\right) \cdot \frac{-0.5}{a}} \]
  8. Simplified43.7%

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

    \[\leadsto \sqrt[3]{-2} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
  10. Final simplification43.7%

    \[\leadsto \sqrt[3]{-\frac{g}{a}} + \sqrt[3]{-2} \]

Alternative 8: 4.5% accurate, 433.0× speedup?

\[\begin{array}{l} \\ -8 \end{array} \]
(FPCore (g h a) :precision binary64 -8.0)
double code(double g, double h, double a) {
	return -8.0;
}
real(8) function code(g, h, a)
    real(8), intent (in) :: g
    real(8), intent (in) :: h
    real(8), intent (in) :: a
    code = -8.0d0
end function
public static double code(double g, double h, double a) {
	return -8.0;
}
def code(g, h, a):
	return -8.0
function code(g, h, a)
	return -8.0
end
function tmp = code(g, h, a)
	tmp = -8.0;
end
code[g_, h_, a_] := -8.0
\begin{array}{l}

\\
-8
\end{array}
Derivation
  1. Initial program 44.5%

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

    \[\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. Taylor expanded in g around -inf 25.5%

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

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

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

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

    \[\leadsto \sqrt[3]{\color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{0}{0}}{a}\right)} - 1}} + \sqrt[3]{\left(g + g\right) \cdot \frac{-0.5}{a}} \]
  8. Simplified43.7%

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

    \[\leadsto \color{blue}{\sqrt[3]{-2}} \]
  10. Simplified4.5%

    \[\leadsto \color{blue}{-8} \]
  11. Final simplification4.5%

    \[\leadsto -8 \]

Reproduce

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