2-ancestry mixing, positive discriminant

Percentage Accurate: 43.5% → 96.0%
Time: 14.1s
Alternatives: 5
Speedup: 2.6×

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: 43.5% 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.0% accurate, 1.4× 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 42.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. Add Preprocessing
  3. Taylor expanded in g around inf

    \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
    2. distribute-neg-frac2N/A

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
    3. lower-/.f64N/A

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
    4. lower-neg.f6429.0

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

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

    \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}} \]
  7. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    2. lower-*.f64N/A

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    3. lower-cbrt.f64N/A

      \[\leadsto \color{blue}{\sqrt[3]{-1}} \cdot \sqrt[3]{\frac{g}{a}} \]
    4. lower-cbrt.f64N/A

      \[\leadsto \sqrt[3]{-1} \cdot \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
    5. lower-/.f6471.7

      \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
  8. Applied rewrites71.7%

    \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
  9. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    2. cbrt-unprodN/A

      \[\leadsto \color{blue}{\sqrt[3]{-1 \cdot \frac{g}{a}}} \]
    3. neg-mul-1N/A

      \[\leadsto \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
    4. lift-/.f64N/A

      \[\leadsto \sqrt[3]{\mathsf{neg}\left(\color{blue}{\frac{g}{a}}\right)} \]
    5. distribute-frac-negN/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\mathsf{neg}\left(g\right)}{a}}} \]
    6. cbrt-divN/A

      \[\leadsto \color{blue}{\frac{\sqrt[3]{\mathsf{neg}\left(g\right)}}{\sqrt[3]{a}}} \]
    7. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\sqrt[3]{\mathsf{neg}\left(g\right)}}{\sqrt[3]{a}}} \]
    8. lower-cbrt.f64N/A

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\mathsf{neg}\left(g\right)}}}{\sqrt[3]{a}} \]
    9. lower-neg.f64N/A

      \[\leadsto \frac{\sqrt[3]{\color{blue}{\mathsf{neg}\left(g\right)}}}{\sqrt[3]{a}} \]
    10. lower-cbrt.f6496.9

      \[\leadsto \frac{\sqrt[3]{-g}}{\color{blue}{\sqrt[3]{a}}} \]
  10. Applied rewrites96.9%

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

Alternative 2: 89.8% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{a \cdot 2} \leq -5 \cdot 10^{-309}:\\
\;\;\;\;{\left(-a\right)}^{-0.3333333333333333} \cdot \sqrt[3]{g}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-g} \cdot {a}^{-0.3333333333333333}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < -4.9999999999999995e-309

    1. Initial program 43.7%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in g around inf

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
      3. lower-/.f64N/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
      4. lower-neg.f6427.5

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

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

      \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
      3. lower-cbrt.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{-1}} \cdot \sqrt[3]{\frac{g}{a}} \]
      4. lower-cbrt.f64N/A

        \[\leadsto \sqrt[3]{-1} \cdot \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
      5. lower-/.f6472.5

        \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    8. Applied rewrites72.5%

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
      2. cbrt-unprodN/A

        \[\leadsto \color{blue}{\sqrt[3]{-1 \cdot \frac{g}{a}}} \]
      3. neg-mul-1N/A

        \[\leadsto \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
      4. lift-/.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(\color{blue}{\frac{g}{a}}\right)} \]
      5. distribute-frac-neg2N/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
      6. lift-neg.f64N/A

        \[\leadsto \sqrt[3]{\frac{g}{\color{blue}{\mathsf{neg}\left(a\right)}}} \]
      7. clear-numN/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{1}{\frac{\mathsf{neg}\left(a\right)}{g}}}} \]
      8. associate-/r/N/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{1}{\mathsf{neg}\left(a\right)} \cdot g}} \]
      9. cbrt-prodN/A

        \[\leadsto \color{blue}{\sqrt[3]{\frac{1}{\mathsf{neg}\left(a\right)}} \cdot \sqrt[3]{g}} \]
      10. pow1/3N/A

        \[\leadsto \color{blue}{{\left(\frac{1}{\mathsf{neg}\left(a\right)}\right)}^{\frac{1}{3}}} \cdot \sqrt[3]{g} \]
      11. inv-powN/A

        \[\leadsto {\color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{-1}\right)}}^{\frac{1}{3}} \cdot \sqrt[3]{g} \]
      12. pow-powN/A

        \[\leadsto \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\left(-1 \cdot \frac{1}{3}\right)}} \cdot \sqrt[3]{g} \]
      13. metadata-evalN/A

        \[\leadsto {\left(\mathsf{neg}\left(a\right)\right)}^{\color{blue}{\frac{-1}{3}}} \cdot \sqrt[3]{g} \]
      14. sqr-powN/A

        \[\leadsto \color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}\right)} \cdot \sqrt[3]{g} \]
      15. lift-cbrt.f64N/A

        \[\leadsto \left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}\right) \cdot \color{blue}{\sqrt[3]{g}} \]
      16. associate-*l*N/A

        \[\leadsto \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot \left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot \sqrt[3]{g}\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot \left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot \sqrt[3]{g}\right)} \]
      18. lower-pow.f64N/A

        \[\leadsto \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}} \cdot \left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot \sqrt[3]{g}\right) \]
      19. metadata-evalN/A

        \[\leadsto {\left(\mathsf{neg}\left(a\right)\right)}^{\color{blue}{\frac{-1}{6}}} \cdot \left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot \sqrt[3]{g}\right) \]
      20. lower-*.f64N/A

        \[\leadsto {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot \color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot \sqrt[3]{g}\right)} \]
      21. lower-pow.f64N/A

        \[\leadsto {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot \left(\color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}} \cdot \sqrt[3]{g}\right) \]
      22. metadata-eval90.6

        \[\leadsto {\left(-a\right)}^{-0.16666666666666666} \cdot \left({\left(-a\right)}^{\color{blue}{-0.16666666666666666}} \cdot \sqrt[3]{g}\right) \]
    10. Applied rewrites90.6%

      \[\leadsto \color{blue}{{\left(-a\right)}^{-0.16666666666666666} \cdot \left({\left(-a\right)}^{-0.16666666666666666} \cdot \sqrt[3]{g}\right)} \]
    11. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto {\color{blue}{\left(\mathsf{neg}\left(a\right)\right)}}^{\frac{-1}{6}} \cdot \left({\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot \sqrt[3]{g}\right) \]
      2. lift-pow.f64N/A

        \[\leadsto \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}}} \cdot \left({\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot \sqrt[3]{g}\right) \]
      3. lift-neg.f64N/A

        \[\leadsto {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot \left({\color{blue}{\left(\mathsf{neg}\left(a\right)\right)}}^{\frac{-1}{6}} \cdot \sqrt[3]{g}\right) \]
      4. lift-pow.f64N/A

        \[\leadsto {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot \left(\color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}}} \cdot \sqrt[3]{g}\right) \]
      5. lift-cbrt.f64N/A

        \[\leadsto {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot \left({\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot \color{blue}{\sqrt[3]{g}}\right) \]
      6. associate-*r*N/A

        \[\leadsto \color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}}\right) \cdot \sqrt[3]{g}} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}}\right) \cdot \sqrt[3]{g}} \]
      8. lift-pow.f64N/A

        \[\leadsto \left(\color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}}} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}}\right) \cdot \sqrt[3]{g} \]
      9. lift-pow.f64N/A

        \[\leadsto \left({\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}} \cdot \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{6}}}\right) \cdot \sqrt[3]{g} \]
      10. pow-prod-upN/A

        \[\leadsto \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{-1}{6} + \frac{-1}{6}\right)}} \cdot \sqrt[3]{g} \]
      11. metadata-evalN/A

        \[\leadsto {\left(\mathsf{neg}\left(a\right)\right)}^{\color{blue}{\frac{-1}{3}}} \cdot \sqrt[3]{g} \]
      12. lower-pow.f6490.6

        \[\leadsto \color{blue}{{\left(-a\right)}^{-0.3333333333333333}} \cdot \sqrt[3]{g} \]
    12. Applied rewrites90.6%

      \[\leadsto \color{blue}{{\left(-a\right)}^{-0.3333333333333333} \cdot \sqrt[3]{g}} \]

    if -4.9999999999999995e-309 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 40.6%

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in g around inf

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
      3. lower-/.f64N/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
      4. lower-neg.f6430.8

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

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

      \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
      3. lower-cbrt.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{-1}} \cdot \sqrt[3]{\frac{g}{a}} \]
      4. lower-cbrt.f64N/A

        \[\leadsto \sqrt[3]{-1} \cdot \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
      5. lower-/.f6470.6

        \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    8. Applied rewrites70.6%

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
      2. cbrt-unprodN/A

        \[\leadsto \color{blue}{\sqrt[3]{-1 \cdot \frac{g}{a}}} \]
      3. neg-mul-1N/A

        \[\leadsto \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
      4. lift-/.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(\color{blue}{\frac{g}{a}}\right)} \]
      5. div-invN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(\color{blue}{g \cdot \frac{1}{a}}\right)} \]
      6. distribute-lft-neg-inN/A

        \[\leadsto \sqrt[3]{\color{blue}{\left(\mathsf{neg}\left(g\right)\right) \cdot \frac{1}{a}}} \]
      7. cbrt-prodN/A

        \[\leadsto \color{blue}{\sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \sqrt[3]{\frac{1}{a}}} \]
      8. pow1/3N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\frac{1}{a}\right)}^{\frac{1}{3}}} \]
      9. inv-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\color{blue}{\left({a}^{-1}\right)}}^{\frac{1}{3}} \]
      10. pow-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{a}^{\left(-1 \cdot \frac{1}{3}\right)}} \]
      11. metadata-evalN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {a}^{\color{blue}{\frac{-1}{3}}} \]
      12. sqr-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{\left({a}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot {a}^{\left(\frac{\frac{-1}{3}}{2}\right)}\right)} \]
      13. pow-prod-downN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(a \cdot a\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}} \]
      14. sqr-negN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\color{blue}{\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right)\right)}}^{\left(\frac{\frac{-1}{3}}{2}\right)} \]
      15. lift-neg.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(a\right)\right)} \cdot \left(\mathsf{neg}\left(a\right)\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \]
      16. lift-neg.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(a\right)\right)}\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \]
      17. pow-prod-downN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}\right)} \]
      18. sqr-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}}} \]
      19. lift-pow.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}}} \]
      20. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}}} \]
      21. lower-cbrt.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{\mathsf{neg}\left(g\right)}} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}} \]
      22. lower-neg.f640.0

        \[\leadsto \sqrt[3]{\color{blue}{-g}} \cdot {\left(-a\right)}^{-0.3333333333333333} \]
      23. lift-pow.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}}} \]
      24. sqr-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}\right)} \]
      25. pow-prod-downN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}} \]
    10. Applied rewrites90.5%

      \[\leadsto \color{blue}{\sqrt[3]{-g} \cdot {a}^{-0.3333333333333333}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.5%

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

Alternative 3: 82.2% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{a \cdot 2} \leq 2 \cdot 10^{+63}:\\
\;\;\;\;-\sqrt[3]{\frac{g}{a}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{-g} \cdot {a}^{-0.3333333333333333}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a)) < 2.00000000000000012e63

    1. Initial program 47.9%

      \[\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. Add Preprocessing
    3. Taylor expanded in g around inf

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
      3. lower-/.f64N/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
      4. lower-neg.f6431.6

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

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

      \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
      3. lower-cbrt.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{-1}} \cdot \sqrt[3]{\frac{g}{a}} \]
      4. lower-cbrt.f64N/A

        \[\leadsto \sqrt[3]{-1} \cdot \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
      5. lower-/.f6480.1

        \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    8. Applied rewrites80.1%

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    9. Taylor expanded in a around -inf

      \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot {\left(\sqrt[3]{-1}\right)}^{3}} \]
    10. Step-by-step derivation
      1. rem-cube-cbrtN/A

        \[\leadsto \sqrt[3]{\frac{g}{a}} \cdot \color{blue}{-1} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{-1 \cdot \sqrt[3]{\frac{g}{a}}} \]
      3. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\sqrt[3]{\frac{g}{a}}\right)} \]
      4. lower-neg.f64N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\sqrt[3]{\frac{g}{a}}\right)} \]
      5. lower-cbrt.f64N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\sqrt[3]{\frac{g}{a}}}\right) \]
      6. lower-/.f6480.1

        \[\leadsto -\sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    11. Applied rewrites80.1%

      \[\leadsto \color{blue}{-\sqrt[3]{\frac{g}{a}}} \]

    if 2.00000000000000012e63 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 19.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. Add Preprocessing
    3. Taylor expanded in g around inf

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
      3. lower-/.f64N/A

        \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
      4. lower-neg.f6418.4

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

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

      \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
      3. lower-cbrt.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{-1}} \cdot \sqrt[3]{\frac{g}{a}} \]
      4. lower-cbrt.f64N/A

        \[\leadsto \sqrt[3]{-1} \cdot \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
      5. lower-/.f6436.8

        \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    8. Applied rewrites36.8%

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
      2. cbrt-unprodN/A

        \[\leadsto \color{blue}{\sqrt[3]{-1 \cdot \frac{g}{a}}} \]
      3. neg-mul-1N/A

        \[\leadsto \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
      4. lift-/.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(\color{blue}{\frac{g}{a}}\right)} \]
      5. div-invN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(\color{blue}{g \cdot \frac{1}{a}}\right)} \]
      6. distribute-lft-neg-inN/A

        \[\leadsto \sqrt[3]{\color{blue}{\left(\mathsf{neg}\left(g\right)\right) \cdot \frac{1}{a}}} \]
      7. cbrt-prodN/A

        \[\leadsto \color{blue}{\sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \sqrt[3]{\frac{1}{a}}} \]
      8. pow1/3N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\frac{1}{a}\right)}^{\frac{1}{3}}} \]
      9. inv-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\color{blue}{\left({a}^{-1}\right)}}^{\frac{1}{3}} \]
      10. pow-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{a}^{\left(-1 \cdot \frac{1}{3}\right)}} \]
      11. metadata-evalN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {a}^{\color{blue}{\frac{-1}{3}}} \]
      12. sqr-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{\left({a}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot {a}^{\left(\frac{\frac{-1}{3}}{2}\right)}\right)} \]
      13. pow-prod-downN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(a \cdot a\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}} \]
      14. sqr-negN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\color{blue}{\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right)\right)}}^{\left(\frac{\frac{-1}{3}}{2}\right)} \]
      15. lift-neg.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(a\right)\right)} \cdot \left(\mathsf{neg}\left(a\right)\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \]
      16. lift-neg.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(a\right)\right)}\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \]
      17. pow-prod-downN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}\right)} \]
      18. sqr-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}}} \]
      19. lift-pow.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}}} \]
      20. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{\mathsf{neg}\left(g\right)} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}}} \]
      21. lower-cbrt.f64N/A

        \[\leadsto \color{blue}{\sqrt[3]{\mathsf{neg}\left(g\right)}} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}} \]
      22. lower-neg.f640.0

        \[\leadsto \sqrt[3]{\color{blue}{-g}} \cdot {\left(-a\right)}^{-0.3333333333333333} \]
      23. lift-pow.f64N/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\mathsf{neg}\left(a\right)\right)}^{\frac{-1}{3}}} \]
      24. sqr-powN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{\left({\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)} \cdot {\left(\mathsf{neg}\left(a\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}\right)} \]
      25. pow-prod-downN/A

        \[\leadsto \sqrt[3]{\mathsf{neg}\left(g\right)} \cdot \color{blue}{{\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right)\right)}^{\left(\frac{\frac{-1}{3}}{2}\right)}} \]
    10. Applied rewrites88.2%

      \[\leadsto \color{blue}{\sqrt[3]{-g} \cdot {a}^{-0.3333333333333333}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification81.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{a \cdot 2} \leq 2 \cdot 10^{+63}:\\ \;\;\;\;-\sqrt[3]{\frac{g}{a}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{-g} \cdot {a}^{-0.3333333333333333}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 74.4% accurate, 2.6× 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 Float64(-cbrt(Float64(g / 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 42.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. Add Preprocessing
  3. Taylor expanded in g around inf

    \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
    2. distribute-neg-frac2N/A

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
    3. lower-/.f64N/A

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
    4. lower-neg.f6429.0

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

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

    \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}} \]
  7. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    2. lower-*.f64N/A

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    3. lower-cbrt.f64N/A

      \[\leadsto \color{blue}{\sqrt[3]{-1}} \cdot \sqrt[3]{\frac{g}{a}} \]
    4. lower-cbrt.f64N/A

      \[\leadsto \sqrt[3]{-1} \cdot \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
    5. lower-/.f6471.7

      \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
  8. Applied rewrites71.7%

    \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
  9. Taylor expanded in a around -inf

    \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot {\left(\sqrt[3]{-1}\right)}^{3}} \]
  10. Step-by-step derivation
    1. rem-cube-cbrtN/A

      \[\leadsto \sqrt[3]{\frac{g}{a}} \cdot \color{blue}{-1} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{-1 \cdot \sqrt[3]{\frac{g}{a}}} \]
    3. mul-1-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\sqrt[3]{\frac{g}{a}}\right)} \]
    4. lower-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\sqrt[3]{\frac{g}{a}}\right)} \]
    5. lower-cbrt.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\sqrt[3]{\frac{g}{a}}}\right) \]
    6. lower-/.f6471.7

      \[\leadsto -\sqrt[3]{\color{blue}{\frac{g}{a}}} \]
  11. Applied rewrites71.7%

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

Alternative 5: 1.4% accurate, 2.7× 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 / 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 42.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. Add Preprocessing
  3. Taylor expanded in g around inf

    \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{-1 \cdot \frac{g}{a}}} \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
    2. distribute-neg-frac2N/A

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
    3. lower-/.f64N/A

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(\mathsf{neg}\left(g\right)\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}} \]
    4. lower-neg.f6429.0

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

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

    \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}} \cdot \sqrt[3]{-1}} \]
  7. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    2. lower-*.f64N/A

      \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
    3. lower-cbrt.f64N/A

      \[\leadsto \color{blue}{\sqrt[3]{-1}} \cdot \sqrt[3]{\frac{g}{a}} \]
    4. lower-cbrt.f64N/A

      \[\leadsto \sqrt[3]{-1} \cdot \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
    5. lower-/.f6471.7

      \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
  8. Applied rewrites71.7%

    \[\leadsto \color{blue}{\sqrt[3]{-1} \cdot \sqrt[3]{\frac{g}{a}}} \]
  9. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \sqrt[3]{-1} \cdot \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    2. cbrt-unprodN/A

      \[\leadsto \color{blue}{\sqrt[3]{-1 \cdot \frac{g}{a}}} \]
    3. pow1/3N/A

      \[\leadsto \color{blue}{{\left(-1 \cdot \frac{g}{a}\right)}^{\frac{1}{3}}} \]
    4. neg-mul-1N/A

      \[\leadsto {\color{blue}{\left(\mathsf{neg}\left(\frac{g}{a}\right)\right)}}^{\frac{1}{3}} \]
    5. lift-/.f64N/A

      \[\leadsto {\left(\mathsf{neg}\left(\color{blue}{\frac{g}{a}}\right)\right)}^{\frac{1}{3}} \]
    6. distribute-frac-neg2N/A

      \[\leadsto {\color{blue}{\left(\frac{g}{\mathsf{neg}\left(a\right)}\right)}}^{\frac{1}{3}} \]
    7. lift-neg.f64N/A

      \[\leadsto {\left(\frac{g}{\color{blue}{\mathsf{neg}\left(a\right)}}\right)}^{\frac{1}{3}} \]
    8. lift-/.f64N/A

      \[\leadsto {\color{blue}{\left(\frac{g}{\mathsf{neg}\left(a\right)}\right)}}^{\frac{1}{3}} \]
    9. sqr-powN/A

      \[\leadsto \color{blue}{{\left(\frac{g}{\mathsf{neg}\left(a\right)}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \cdot {\left(\frac{g}{\mathsf{neg}\left(a\right)}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)}} \]
    10. pow-prod-downN/A

      \[\leadsto \color{blue}{{\left(\frac{g}{\mathsf{neg}\left(a\right)} \cdot \frac{g}{\mathsf{neg}\left(a\right)}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)}} \]
    11. lift-/.f64N/A

      \[\leadsto {\left(\color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}} \cdot \frac{g}{\mathsf{neg}\left(a\right)}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \]
    12. lift-neg.f64N/A

      \[\leadsto {\left(\frac{g}{\color{blue}{\mathsf{neg}\left(a\right)}} \cdot \frac{g}{\mathsf{neg}\left(a\right)}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \]
    13. distribute-frac-neg2N/A

      \[\leadsto {\left(\color{blue}{\left(\mathsf{neg}\left(\frac{g}{a}\right)\right)} \cdot \frac{g}{\mathsf{neg}\left(a\right)}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \]
    14. lift-/.f64N/A

      \[\leadsto {\left(\left(\mathsf{neg}\left(\color{blue}{\frac{g}{a}}\right)\right) \cdot \frac{g}{\mathsf{neg}\left(a\right)}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \]
    15. lift-/.f64N/A

      \[\leadsto {\left(\left(\mathsf{neg}\left(\frac{g}{a}\right)\right) \cdot \color{blue}{\frac{g}{\mathsf{neg}\left(a\right)}}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \]
    16. lift-neg.f64N/A

      \[\leadsto {\left(\left(\mathsf{neg}\left(\frac{g}{a}\right)\right) \cdot \frac{g}{\color{blue}{\mathsf{neg}\left(a\right)}}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \]
    17. distribute-frac-neg2N/A

      \[\leadsto {\left(\left(\mathsf{neg}\left(\frac{g}{a}\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{g}{a}\right)\right)}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \]
    18. lift-/.f64N/A

      \[\leadsto {\left(\left(\mathsf{neg}\left(\frac{g}{a}\right)\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{g}{a}}\right)\right)\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \]
    19. sqr-negN/A

      \[\leadsto {\color{blue}{\left(\frac{g}{a} \cdot \frac{g}{a}\right)}}^{\left(\frac{\frac{1}{3}}{2}\right)} \]
    20. pow-prod-downN/A

      \[\leadsto \color{blue}{{\left(\frac{g}{a}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \cdot {\left(\frac{g}{a}\right)}^{\left(\frac{\frac{1}{3}}{2}\right)}} \]
    21. sqr-powN/A

      \[\leadsto \color{blue}{{\left(\frac{g}{a}\right)}^{\frac{1}{3}}} \]
    22. pow1/3N/A

      \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
    23. lift-cbrt.f641.3

      \[\leadsto \color{blue}{\sqrt[3]{\frac{g}{a}}} \]
  10. Applied rewrites1.3%

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

Reproduce

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