Average Error: 35.9 → 32.2
Time: 9.5s
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} \mathbf{if}\;g \leq 1.5431160917667745 \cdot 10^{-162}:\\ \;\;\;\;\frac{\sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}}{\sqrt[3]{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{\sqrt{g \cdot g - h \cdot h} - g}{2 \cdot a}} + \frac{\sqrt[3]{-0.5 \cdot \left(g + \sqrt{g \cdot g - h \cdot h}\right)}}{\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}
\mathbf{if}\;g \leq 1.5431160917667745 \cdot 10^{-162}:\\
\;\;\;\;\frac{\sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}}{\sqrt[3]{2 \cdot a}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{\sqrt{g \cdot g - h \cdot h} - g}{2 \cdot a}} + \frac{\sqrt[3]{-0.5 \cdot \left(g + \sqrt{g \cdot g - h \cdot h}\right)}}{\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
 (if (<= g 1.5431160917667745e-162)
   (/ (cbrt (- (sqrt (- (* g g) (* h h))) g)) (cbrt (* 2.0 a)))
   (+
    (cbrt (/ (- (sqrt (- (* g g) (* h h))) g) (* 2.0 a)))
    (/ (cbrt (* -0.5 (+ g (sqrt (- (* g g) (* h h)))))) (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 tmp;
	if (g <= 1.5431160917667745e-162) {
		tmp = cbrt(sqrt((g * g) - (h * h)) - g) / cbrt(2.0 * a);
	} else {
		tmp = cbrt((sqrt((g * g) - (h * h)) - g) / (2.0 * a)) + (cbrt(-0.5 * (g + sqrt((g * g) - (h * h)))) / 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 < 1.54311609176677453e-162

    1. Initial program 36.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. Simplified36.3

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\sqrt{g \cdot g - h \cdot h} - g}{2 \cdot a}} + \sqrt[3]{-0.5 \cdot \frac{g + \sqrt{g \cdot g - h \cdot h}}{a}}}\]
    3. Using strategy rm
    4. Applied cbrt-div_binary6432.3

      \[\leadsto \color{blue}{\frac{\sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}}{\sqrt[3]{2 \cdot a}}} + \sqrt[3]{-0.5 \cdot \frac{g + \sqrt{g \cdot g - h \cdot h}}{a}}\]
    5. Taylor expanded around 0 32.5

      \[\leadsto \frac{\sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}}{\sqrt[3]{2 \cdot a}} + \color{blue}{0}\]

    if 1.54311609176677453e-162 < g

    1. Initial program 35.5

      \[\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. Simplified35.5

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\sqrt{g \cdot g - h \cdot h} - g}{2 \cdot a}} + \sqrt[3]{-0.5 \cdot \frac{g + \sqrt{g \cdot g - h \cdot h}}{a}}}\]
    3. Using strategy rm
    4. Applied associate-*r/_binary6435.5

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

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

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

Reproduce

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