2-ancestry mixing, positive discriminant

Percentage Accurate: 44.5% → 95.6%
Time: 11.0s
Alternatives: 4
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 4 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.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: 95.6% 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 45.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. Add Preprocessing
  3. Step-by-step derivation
    1. lift-cbrt.f64N/A

      \[\leadsto \color{blue}{\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. lift-*.f64N/A

      \[\leadsto \sqrt[3]{\color{blue}{\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)} \]
    3. *-commutativeN/A

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

      \[\leadsto \sqrt[3]{\left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right) \cdot \color{blue}{\frac{1}{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    5. un-div-invN/A

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

      \[\leadsto \sqrt[3]{\frac{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}}{\color{blue}{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    7. associate-/r*N/A

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}}{2}}{a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
    8. cbrt-divN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt[3]{\frac{g}{a}} \cdot \color{blue}{\sqrt[3]{\frac{-1}{2}}}\right) \cdot \sqrt[3]{2} \]
    7. lower-cbrt.f6476.1

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

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

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

    Alternative 2: 74.6% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ {\left(\sqrt[3]{\frac{-a}{g}}\right)}^{-1} \end{array} \]
    (FPCore (g h a) :precision binary64 (pow (cbrt (/ (- a) g)) -1.0))
    double code(double g, double h, double a) {
    	return pow(cbrt((-a / g)), -1.0);
    }
    
    public static double code(double g, double h, double a) {
    	return Math.pow(Math.cbrt((-a / g)), -1.0);
    }
    
    function code(g, h, a)
    	return cbrt(Float64(Float64(-a) / g)) ^ -1.0
    end
    
    code[g_, h_, a_] := N[Power[N[Power[N[((-a) / g), $MachinePrecision], 1/3], $MachinePrecision], -1.0], $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    {\left(\sqrt[3]{\frac{-a}{g}}\right)}^{-1}
    \end{array}
    
    Derivation
    1. Initial program 45.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. Add Preprocessing
    3. Step-by-step derivation
      1. lift-cbrt.f64N/A

        \[\leadsto \color{blue}{\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. lift-*.f64N/A

        \[\leadsto \sqrt[3]{\color{blue}{\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)} \]
      3. *-commutativeN/A

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

        \[\leadsto \sqrt[3]{\left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right) \cdot \color{blue}{\frac{1}{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
      5. un-div-invN/A

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

        \[\leadsto \sqrt[3]{\frac{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}}{\color{blue}{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
      7. associate-/r*N/A

        \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}}{2}}{a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
      8. cbrt-divN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt[3]{\frac{g}{a}} \cdot \color{blue}{\sqrt[3]{\frac{-1}{2}}}\right) \cdot \sqrt[3]{2} \]
      7. lower-cbrt.f6476.1

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

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

        \[\leadsto \frac{\sqrt[3]{-g}}{\color{blue}{\sqrt[3]{a}}} \]
      2. Step-by-step derivation
        1. Applied rewrites78.7%

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

          \[\leadsto {\left(\sqrt[3]{\frac{-a}{g}}\right)}^{-1} \]
        3. Add Preprocessing

        Alternative 3: 73.9% 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 cbrt(Float64(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 45.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. Add Preprocessing
        3. Step-by-step derivation
          1. lift-cbrt.f64N/A

            \[\leadsto \color{blue}{\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. lift-*.f64N/A

            \[\leadsto \sqrt[3]{\color{blue}{\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)} \]
          3. *-commutativeN/A

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

            \[\leadsto \sqrt[3]{\left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right) \cdot \color{blue}{\frac{1}{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
          5. un-div-invN/A

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

            \[\leadsto \sqrt[3]{\frac{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}}{\color{blue}{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
          7. associate-/r*N/A

            \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}}{2}}{a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
          8. cbrt-divN/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(\sqrt[3]{\frac{g}{a}} \cdot \color{blue}{\sqrt[3]{\frac{-1}{2}}}\right) \cdot \sqrt[3]{2} \]
          7. lower-cbrt.f6476.1

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

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

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

          Alternative 4: 3.0% accurate, 302.0× speedup?

          \[\begin{array}{l} \\ 0 \end{array} \]
          (FPCore (g h a) :precision binary64 0.0)
          double code(double g, double h, double a) {
          	return 0.0;
          }
          
          real(8) function code(g, h, a)
              real(8), intent (in) :: g
              real(8), intent (in) :: h
              real(8), intent (in) :: a
              code = 0.0d0
          end function
          
          public static double code(double g, double h, double a) {
          	return 0.0;
          }
          
          def code(g, h, a):
          	return 0.0
          
          function code(g, h, a)
          	return 0.0
          end
          
          function tmp = code(g, h, a)
          	tmp = 0.0;
          end
          
          code[g_, h_, a_] := 0.0
          
          \begin{array}{l}
          
          \\
          0
          \end{array}
          
          Derivation
          1. Initial program 45.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. Add Preprocessing
          3. Step-by-step derivation
            1. lift-cbrt.f64N/A

              \[\leadsto \color{blue}{\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. lift-*.f64N/A

              \[\leadsto \sqrt[3]{\color{blue}{\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)} \]
            3. *-commutativeN/A

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

              \[\leadsto \sqrt[3]{\left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right) \cdot \color{blue}{\frac{1}{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
            5. un-div-invN/A

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

              \[\leadsto \sqrt[3]{\frac{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}}{\color{blue}{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
            7. associate-/r*N/A

              \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}}{2}}{a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
            8. cbrt-divN/A

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(-\color{blue}{\sqrt[3]{\frac{1}{2}}}\right) \cdot \sqrt[3]{\frac{g \cdot \left(1 + {\left(\sqrt{-1}\right)}^{2}\right)}{a}} \]
            7. distribute-rgt-inN/A

              \[\leadsto \left(-\sqrt[3]{\frac{1}{2}}\right) \cdot \sqrt[3]{\frac{\color{blue}{1 \cdot g + {\left(\sqrt{-1}\right)}^{2} \cdot g}}{a}} \]
            8. *-lft-identityN/A

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

              \[\leadsto \left(-\sqrt[3]{\frac{1}{2}}\right) \cdot \sqrt[3]{\frac{g + \color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot g}{a}} \]
            10. rem-square-sqrtN/A

              \[\leadsto \left(-\sqrt[3]{\frac{1}{2}}\right) \cdot \sqrt[3]{\frac{g + \color{blue}{-1} \cdot g}{a}} \]
            11. distribute-rgt1-inN/A

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

              \[\leadsto \left(-\sqrt[3]{\frac{1}{2}}\right) \cdot \sqrt[3]{\frac{\color{blue}{0} \cdot g}{a}} \]
            13. mul0-lftN/A

              \[\leadsto \left(-\sqrt[3]{\frac{1}{2}}\right) \cdot \sqrt[3]{\frac{\color{blue}{0}}{a}} \]
            14. mul0-lftN/A

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

              \[\leadsto \left(-\sqrt[3]{\frac{1}{2}}\right) \cdot \sqrt[3]{\frac{\color{blue}{\left(-1 + 1\right)} \cdot h}{a}} \]
            16. distribute-rgt1-inN/A

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

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

            \[\leadsto \color{blue}{\left(-\sqrt[3]{0.5}\right) \cdot \sqrt[3]{\frac{0}{a}}} \]
          8. Step-by-step derivation
            1. Applied rewrites3.0%

              \[\leadsto \color{blue}{0} \]
            2. Add Preprocessing

            Reproduce

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