2-ancestry mixing, positive discriminant

Percentage Accurate: 44.1% → 96.6%
Time: 17.3s
Alternatives: 5
Speedup: 4.2×

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.1% 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: 96.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;h \cdot h \leq 10^{+187}:\\
\;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{\left(0.5 \cdot \frac{{h}^{2}}{g}\right) \cdot \frac{-0.5}{a}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 h h) < 9.99999999999999907e186

    1. Initial program 43.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. Simplified43.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.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{-g}}{\sqrt[3]{-\left(-a\right)}}} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    9. Step-by-step derivation
      1. remove-double-neg32.1%

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

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

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

    if 9.99999999999999907e186 < (*.f64 h h)

    1. Initial program 2.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. Simplified2.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. Taylor expanded in h around 0 11.9%

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

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

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

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

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

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

        \[\leadsto h \cdot \left({\left(\color{blue}{\left(\left(\sqrt[3]{\frac{1}{a \cdot \left(g \cdot h\right)}} \cdot \sqrt[3]{\frac{1}{a \cdot \left(g \cdot h\right)}}\right) \cdot \sqrt[3]{\frac{1}{a \cdot \left(g \cdot h\right)}}\right)} \cdot {\left(\sqrt[3]{-0.5} \cdot \sqrt[3]{0.5}\right)}^{3}\right)}^{0.3333333333333333} + \sqrt[3]{\frac{g}{a}} \cdot \frac{\sqrt[3]{-0.5} \cdot \sqrt[3]{2}}{h}\right) \]
      6. add-cube-cbrt32.5%

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

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

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

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

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

      \[\leadsto h \cdot \left(\color{blue}{{\left(\frac{1}{\left(g \cdot a\right) \cdot h} \cdot {\left(\sqrt[3]{-0.25}\right)}^{3}\right)}^{0.3333333333333333}} + \sqrt[3]{\frac{g}{a}} \cdot \frac{\sqrt[3]{-0.5} \cdot \sqrt[3]{2}}{h}\right) \]
    8. Step-by-step derivation
      1. unpow1/335.5%

        \[\leadsto h \cdot \left(\color{blue}{\sqrt[3]{\frac{1}{\left(g \cdot a\right) \cdot h} \cdot {\left(\sqrt[3]{-0.25}\right)}^{3}}} + \sqrt[3]{\frac{g}{a}} \cdot \frac{\sqrt[3]{-0.5} \cdot \sqrt[3]{2}}{h}\right) \]
      2. associate-*l/35.5%

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

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

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

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

      \[\leadsto h \cdot \left(\color{blue}{\sqrt[3]{\frac{-0.25}{g \cdot \left(a \cdot h\right)}}} + \sqrt[3]{\frac{g}{a}} \cdot \frac{\sqrt[3]{-0.5} \cdot \sqrt[3]{2}}{h}\right) \]
    10. Step-by-step derivation
      1. pow1/316.3%

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

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

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

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

      \[\leadsto h \cdot \left(\sqrt[3]{\frac{-0.25}{g \cdot \left(a \cdot h\right)}} + \color{blue}{\left(\sqrt[3]{g} \cdot {\left(\frac{1}{a}\right)}^{0.3333333333333333}\right)} \cdot \frac{\sqrt[3]{-0.5} \cdot \sqrt[3]{2}}{h}\right) \]
    12. Step-by-step derivation
      1. unpow1/394.5%

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

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

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

Alternative 2: 93.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;h \leq 3.8 \cdot 10^{+117}:\\
\;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{\left(0.5 \cdot \frac{{h}^{2}}{g}\right) \cdot \frac{-0.5}{a}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < 3.8000000000000002e117

    1. Initial program 40.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. Simplified40.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 25.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{-g}}{\sqrt[3]{-\left(-a\right)}}} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
    9. Step-by-step derivation
      1. remove-double-neg29.9%

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

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

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

    if 3.8000000000000002e117 < h

    1. Initial program 0.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. Simplified0.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 h around 0 8.9%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto h \cdot \left(\color{blue}{{\left(\frac{1}{\left(g \cdot a\right) \cdot h} \cdot {\left(\sqrt[3]{-0.25}\right)}^{3}\right)}^{0.3333333333333333}} + \sqrt[3]{\frac{g}{a}} \cdot \frac{\sqrt[3]{-0.5} \cdot \sqrt[3]{2}}{h}\right) \]
    8. Step-by-step derivation
      1. unpow1/347.7%

        \[\leadsto h \cdot \left(\color{blue}{\sqrt[3]{\frac{1}{\left(g \cdot a\right) \cdot h} \cdot {\left(\sqrt[3]{-0.25}\right)}^{3}}} + \sqrt[3]{\frac{g}{a}} \cdot \frac{\sqrt[3]{-0.5} \cdot \sqrt[3]{2}}{h}\right) \]
      2. associate-*l/47.7%

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

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

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

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

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

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

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

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

Alternative 3: 95.8% accurate, 2.1× speedup?

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

\\
\frac{\sqrt[3]{-g}}{\sqrt[3]{a}}
\end{array}
Derivation
  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. Add Preprocessing
  4. Taylor expanded in g around -inf 24.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \color{blue}{0} \]
  15. Final simplification96.0%

    \[\leadsto \frac{\sqrt[3]{-g}}{\sqrt[3]{a}} \]
  16. Add Preprocessing

Alternative 4: 15.2% accurate, 4.1× speedup?

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

\\
\sqrt[3]{\frac{g}{a}} \cdot -2
\end{array}
Derivation
  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. Add Preprocessing
  4. Taylor expanded in g around -inf 24.0%

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

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

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

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

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

    \[\leadsto \color{blue}{-2 \cdot \sqrt[3]{\frac{g}{a}}} \]
  9. Step-by-step derivation
    1. *-commutative14.6%

      \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot -2} \]
  10. Simplified14.6%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot -2} \]
  11. Add Preprocessing

Alternative 5: 73.2% accurate, 4.2× speedup?

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

\\
\sqrt[3]{\frac{g}{-a}}
\end{array}
Derivation
  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. Add Preprocessing
  4. Taylor expanded in g around -inf 24.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + \sqrt[3]{\left(g + \color{blue}{\left(-g\right)}\right) \cdot \frac{-0.5}{a}} \]
  14. Step-by-step derivation
    1. *-un-lft-identity96.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{\frac{g}{-a}} + \sqrt[3]{\color{blue}{0} \cdot \frac{-0.5}{a}} \]
    6. mul0-lft69.8%

      \[\leadsto \sqrt[3]{\frac{g}{-a}} + \sqrt[3]{\color{blue}{0}} \]
    7. metadata-eval69.8%

      \[\leadsto \sqrt[3]{\frac{g}{-a}} + \sqrt[3]{\color{blue}{{0}^{3}}} \]
    8. +-inverses69.8%

      \[\leadsto \sqrt[3]{\frac{g}{-a}} + \sqrt[3]{{\color{blue}{\left(g - g\right)}}^{3}} \]
    9. rem-cbrt-cube69.8%

      \[\leadsto \sqrt[3]{\frac{g}{-a}} + \color{blue}{\left(g - g\right)} \]
    10. +-inverses69.8%

      \[\leadsto \sqrt[3]{\frac{g}{-a}} + \color{blue}{0} \]
  17. Simplified69.8%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{-a}} + 0} \]
  18. Final simplification69.8%

    \[\leadsto \sqrt[3]{\frac{g}{-a}} \]
  19. Add Preprocessing

Reproduce

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