Average Error: 36.0 → 31.3
Time: 12.9s
Precision: binary64
\[\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)} \]
\[\begin{array}{l} t_0 := g + \sqrt{g \cdot g - h \cdot h}\\ \mathbf{if}\;g \leq 4.6235888593323855 \cdot 10^{-161}:\\ \;\;\;\;\frac{\sqrt[3]{\left(-g\right) - g}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{t_0}{a} \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{-0.5 \cdot \frac{{h}^{2}}{g}}{2 \cdot a}} + \frac{\sqrt[3]{t_0 \cdot -0.5}}{\sqrt[3]{a}}\\ \end{array} \]
\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)}
\begin{array}{l}
t_0 := g + \sqrt{g \cdot g - h \cdot h}\\
\mathbf{if}\;g \leq 4.6235888593323855 \cdot 10^{-161}:\\
\;\;\;\;\frac{\sqrt[3]{\left(-g\right) - g}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{t_0}{a} \cdot -0.5}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{-0.5 \cdot \frac{{h}^{2}}{g}}{2 \cdot a}} + \frac{\sqrt[3]{t_0 \cdot -0.5}}{\sqrt[3]{a}}\\


\end{array}
(FPCore (g h a)
 :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))))))))
(FPCore (g h a)
 :precision binary64
 (let* ((t_0 (+ g (sqrt (- (* g g) (* h h))))))
   (if (<= g 4.6235888593323855e-161)
     (+ (/ (cbrt (- (- g) g)) (cbrt (* 2.0 a))) (cbrt (* (/ t_0 a) -0.5)))
     (+
      (cbrt (/ (* -0.5 (/ (pow h 2.0) g)) (* 2.0 a)))
      (/ (cbrt (* t_0 -0.5)) (cbrt a))))))
double code(double g, double h, double a) {
	return cbrt((1.0 / (2.0 * a)) * (-g + sqrt((g * g) - (h * h)))) + cbrt((1.0 / (2.0 * a)) * (-g - sqrt((g * g) - (h * h))));
}
double code(double g, double h, double a) {
	double t_0 = g + sqrt((g * g) - (h * h));
	double tmp;
	if (g <= 4.6235888593323855e-161) {
		tmp = (cbrt(-g - g) / cbrt(2.0 * a)) + cbrt((t_0 / a) * -0.5);
	} else {
		tmp = cbrt((-0.5 * (pow(h, 2.0) / g)) / (2.0 * a)) + (cbrt(t_0 * -0.5) / cbrt(a));
	}
	return tmp;
}

Error

Bits error versus g

Bits error versus h

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if g < 4.6235888593323855e-161

    1. Initial program 37.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. Simplified37.3

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\sqrt{g \cdot g - h \cdot h} - g}{2 \cdot a}} + \sqrt[3]{\frac{g + \sqrt{g \cdot g - h \cdot h}}{a} \cdot -0.5}} \]
    3. Applied cbrt-div_binary6433.5

      \[\leadsto \color{blue}{\frac{\sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}}{\sqrt[3]{2 \cdot a}}} + \sqrt[3]{\frac{g + \sqrt{g \cdot g - h \cdot h}}{a} \cdot -0.5} \]
    4. Taylor expanded in g around -inf 32.0

      \[\leadsto \frac{\sqrt[3]{\color{blue}{-1 \cdot g} - g}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{g + \sqrt{g \cdot g - h \cdot h}}{a} \cdot -0.5} \]
    5. Simplified32.0

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

    if 4.6235888593323855e-161 < g

    1. Initial program 34.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. Simplified34.5

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\sqrt{g \cdot g - h \cdot h} - g}{2 \cdot a}} + \sqrt[3]{\frac{g + \sqrt{g \cdot g - h \cdot h}}{a} \cdot -0.5}} \]
    3. Applied associate-*l/_binary6434.5

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

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

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

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

Reproduce

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