2-ancestry mixing, positive discriminant

Percentage Accurate: 43.4% → 95.8%
Time: 15.1s
Alternatives: 6
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 6 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.4% 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.8% 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 41.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. 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. lower-neg.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}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
    3. lower-/.f6425.3

      \[\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}}} \]
  5. Applied rewrites25.3%

    \[\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. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{a \cdot 2} \leq 5 \cdot 10^{+50}:\\ \;\;\;\;-\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)) 5e+50)
   (- (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)) <= 5e+50) {
		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)) <= 5e+50) {
		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)) <= 5e+50)
		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], 5e+50], (-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 5 \cdot 10^{+50}:\\
\;\;\;\;-\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)) < 5e50

    1. Initial program 42.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. 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. lower-neg.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}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
      3. lower-/.f6425.7

        \[\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}}} \]
    5. Applied rewrites25.7%

      \[\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 \sqrt[3]{\frac{1}{2 \cdot a} \cdot \color{blue}{\left(\frac{-1}{2} \cdot \frac{{h}^{2}}{g}\right)}} + \sqrt[3]{\mathsf{neg}\left(\frac{g}{a}\right)} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

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

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

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

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

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

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

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

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

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

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

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

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

    if 5e50 < (/.f64 #s(literal 1 binary64) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 36.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. 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. lower-neg.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}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
      3. lower-/.f6423.2

        \[\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}}} \]
    5. Applied rewrites23.2%

      \[\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. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt[3]{-g} \cdot {a}^{\color{blue}{-0.3333333333333333}} \]
    10. Applied rewrites87.2%

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

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

Alternative 3: 72.7% 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 41.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. 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. lower-neg.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}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
    3. lower-/.f6425.3

      \[\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}}} \]
  5. Applied rewrites25.3%

    \[\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 \sqrt[3]{\frac{1}{2 \cdot a} \cdot \color{blue}{\left(\frac{-1}{2} \cdot \frac{{h}^{2}}{g}\right)}} + \sqrt[3]{\mathsf{neg}\left(\frac{g}{a}\right)} \]
  7. Step-by-step derivation
    1. associate-*r/N/A

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 1.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ {\left(\frac{g}{a}\right)}^{0.3333333333333333} \end{array} \]
(FPCore (g h a) :precision binary64 (pow (/ g a) 0.3333333333333333))
double code(double g, double h, double a) {
	return pow((g / a), 0.3333333333333333);
}
real(8) function code(g, h, a)
    real(8), intent (in) :: g
    real(8), intent (in) :: h
    real(8), intent (in) :: a
    code = (g / a) ** 0.3333333333333333d0
end function
public static double code(double g, double h, double a) {
	return Math.pow((g / a), 0.3333333333333333);
}
def code(g, h, a):
	return math.pow((g / a), 0.3333333333333333)
function code(g, h, a)
	return Float64(g / a) ^ 0.3333333333333333
end
function tmp = code(g, h, a)
	tmp = (g / a) ^ 0.3333333333333333;
end
code[g_, h_, a_] := N[Power[N[(g / a), $MachinePrecision], 0.3333333333333333], $MachinePrecision]
\begin{array}{l}

\\
{\left(\frac{g}{a}\right)}^{0.3333333333333333}
\end{array}
Derivation
  1. Initial program 41.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. 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. lower-neg.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}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
    3. lower-/.f6425.3

      \[\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}}} \]
  5. Applied rewrites25.3%

    \[\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. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{\frac{1 \cdot -1}{\frac{a}{g}}}} \]
    6. metadata-evalN/A

      \[\leadsto \sqrt[3]{\frac{\color{blue}{-1}}{\frac{a}{g}}} \]
    7. cbrt-divN/A

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

      \[\leadsto \frac{\color{blue}{{-1}^{\frac{1}{3}}}}{\sqrt[3]{\frac{a}{g}}} \]
    9. sqr-powN/A

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

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

      \[\leadsto \frac{{\color{blue}{1}}^{\left(\frac{\frac{1}{3}}{2}\right)}}{\sqrt[3]{\frac{a}{g}}} \]
    12. pow-base-1N/A

      \[\leadsto \frac{\color{blue}{1}}{\sqrt[3]{\frac{a}{g}}} \]
    13. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\sqrt[3]{1}}}{\sqrt[3]{\frac{a}{g}}} \]
    14. cbrt-divN/A

      \[\leadsto \color{blue}{\sqrt[3]{\frac{1}{\frac{a}{g}}}} \]
    15. clear-numN/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    16. lift-/.f64N/A

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

      \[\leadsto \color{blue}{{\left(\frac{g}{a}\right)}^{\frac{1}{3}}} \]
    18. lower-pow.f641.4

      \[\leadsto \color{blue}{{\left(\frac{g}{a}\right)}^{0.3333333333333333}} \]
  10. Applied rewrites1.4%

    \[\leadsto \color{blue}{{\left(\frac{g}{a}\right)}^{0.3333333333333333}} \]
  11. Add Preprocessing

Alternative 5: 1.2% accurate, 2.7× speedup?

\[\begin{array}{l} \\ {\left(\frac{a}{g}\right)}^{-0.3333333333333333} \end{array} \]
(FPCore (g h a) :precision binary64 (pow (/ a g) -0.3333333333333333))
double code(double g, double h, double a) {
	return pow((a / g), -0.3333333333333333);
}
real(8) function code(g, h, a)
    real(8), intent (in) :: g
    real(8), intent (in) :: h
    real(8), intent (in) :: a
    code = (a / g) ** (-0.3333333333333333d0)
end function
public static double code(double g, double h, double a) {
	return Math.pow((a / g), -0.3333333333333333);
}
def code(g, h, a):
	return math.pow((a / g), -0.3333333333333333)
function code(g, h, a)
	return Float64(a / g) ^ -0.3333333333333333
end
function tmp = code(g, h, a)
	tmp = (a / g) ^ -0.3333333333333333;
end
code[g_, h_, a_] := N[Power[N[(a / g), $MachinePrecision], -0.3333333333333333], $MachinePrecision]
\begin{array}{l}

\\
{\left(\frac{a}{g}\right)}^{-0.3333333333333333}
\end{array}
Derivation
  1. Initial program 41.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. 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. lower-neg.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}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
    3. lower-/.f6425.3

      \[\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}}} \]
  5. Applied rewrites25.3%

    \[\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. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{\frac{1 \cdot -1}{\frac{a}{g}}}} \]
    6. metadata-evalN/A

      \[\leadsto \sqrt[3]{\frac{\color{blue}{-1}}{\frac{a}{g}}} \]
    7. cbrt-divN/A

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

      \[\leadsto \frac{\color{blue}{{-1}^{\frac{1}{3}}}}{\sqrt[3]{\frac{a}{g}}} \]
    9. sqr-powN/A

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

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

      \[\leadsto \frac{{\color{blue}{1}}^{\left(\frac{\frac{1}{3}}{2}\right)}}{\sqrt[3]{\frac{a}{g}}} \]
    12. pow-base-1N/A

      \[\leadsto \frac{\color{blue}{1}}{\sqrt[3]{\frac{a}{g}}} \]
    13. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\sqrt[3]{1}}}{\sqrt[3]{\frac{a}{g}}} \]
    14. cbrt-divN/A

      \[\leadsto \color{blue}{\sqrt[3]{\frac{1}{\frac{a}{g}}}} \]
    15. clear-numN/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    16. lift-/.f64N/A

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

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

      \[\leadsto {\color{blue}{\left(\frac{g}{a}\right)}}^{\frac{1}{3}} \]
    19. clear-numN/A

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

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

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

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

      \[\leadsto {\color{blue}{\left(\frac{a}{g}\right)}}^{\left(-1 \cdot \frac{1}{3}\right)} \]
    24. metadata-eval1.3

      \[\leadsto {\left(\frac{a}{g}\right)}^{\color{blue}{-0.3333333333333333}} \]
  10. Applied rewrites1.3%

    \[\leadsto \color{blue}{{\left(\frac{a}{g}\right)}^{-0.3333333333333333}} \]
  11. Add Preprocessing

Alternative 6: 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 41.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. 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. lower-neg.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}{\mathsf{neg}\left(\frac{g}{a}\right)}} \]
    3. lower-/.f6425.3

      \[\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}}} \]
  5. Applied rewrites25.3%

    \[\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. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{\frac{1 \cdot -1}{\frac{a}{g}}}} \]
    6. metadata-evalN/A

      \[\leadsto \sqrt[3]{\frac{\color{blue}{-1}}{\frac{a}{g}}} \]
    7. cbrt-divN/A

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

      \[\leadsto \frac{\color{blue}{{-1}^{\frac{1}{3}}}}{\sqrt[3]{\frac{a}{g}}} \]
    9. sqr-powN/A

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

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

      \[\leadsto \frac{{\color{blue}{1}}^{\left(\frac{\frac{1}{3}}{2}\right)}}{\sqrt[3]{\frac{a}{g}}} \]
    12. pow-base-1N/A

      \[\leadsto \frac{\color{blue}{1}}{\sqrt[3]{\frac{a}{g}}} \]
    13. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\sqrt[3]{1}}}{\sqrt[3]{\frac{a}{g}}} \]
    14. cbrt-divN/A

      \[\leadsto \color{blue}{\sqrt[3]{\frac{1}{\frac{a}{g}}}} \]
    15. clear-numN/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    16. lift-/.f64N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{g}{a}}} \]
    17. 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 2024219 
(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))))))))