Average Error: 36.3 → 32.8
Time: 16.3s
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 := \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\\ \frac{\sqrt[3]{t_0 - g}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\left(-g\right) - t_0} \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 := \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\\
\frac{\sqrt[3]{t_0 - g}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\left(-g\right) - t_0}
\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 (sqrt (* (+ h g) (- g h)))))
   (+
    (/ (cbrt (- t_0 g)) (cbrt (* 2.0 a)))
    (* (cbrt (/ 0.5 a)) (cbrt (- (- g) t_0))))))
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 = sqrt((h + g) * (g - h));
	return (cbrt(t_0 - g) / cbrt(2.0 * a)) + (cbrt(0.5 / a) * cbrt(-g - t_0));
}

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. 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. Applied associate-*l/_binary6436.3

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

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

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

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

    \[\leadsto \frac{\sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}}{\sqrt[3]{2 \cdot a}} + \color{blue}{\sqrt[3]{\frac{0.5}{a}}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}} \]
  7. Applied difference-of-squares_binary6432.8

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

    \[\leadsto \frac{\sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{\color{blue}{\left(h + g\right)} \cdot \left(g - h\right)}} \]
  9. Applied difference-of-squares_binary6432.8

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

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

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

Reproduce

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