Average Error: 36.1 → 31.4
Time: 12.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} t_0 := \sqrt{g \cdot g - h \cdot h} - g\\ \mathbf{if}\;g \leq -5.469826934247915 \cdot 10^{-160}:\\ \;\;\;\;\frac{\sqrt[3]{t_0}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{0.5 \cdot \frac{{h}^{2}}{g}}{a} \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{t_0}{2 \cdot a}} + \frac{\sqrt[3]{-0.5 \cdot \left(g + g\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
 (let* ((t_0 (- (sqrt (- (* g g) (* h h))) g)))
   (if (<= g -5.469826934247915e-160)
     (+
      (/ (cbrt t_0) (cbrt (* 2.0 a)))
      (cbrt (* (/ (* 0.5 (/ (pow h 2.0) g)) a) -0.5)))
     (+ (cbrt (/ t_0 (* 2.0 a))) (/ (cbrt (* -0.5 (+ g g))) (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 = sqrt(((g * g) - (h * h))) - g;
	double tmp;
	if (g <= -5.469826934247915e-160) {
		tmp = (cbrt(t_0) / cbrt((2.0 * a))) + cbrt((((0.5 * (pow(h, 2.0) / g)) / a) * -0.5));
	} else {
		tmp = cbrt((t_0 / (2.0 * a))) + (cbrt((-0.5 * (g + g))) / cbrt(a));
	}
	return tmp;
}
public static double code(double g, double h, double a) {
	return Math.cbrt(((1.0 / (2.0 * a)) * (-g + Math.sqrt(((g * g) - (h * h)))))) + Math.cbrt(((1.0 / (2.0 * a)) * (-g - Math.sqrt(((g * g) - (h * h))))));
}
public static double code(double g, double h, double a) {
	double t_0 = Math.sqrt(((g * g) - (h * h))) - g;
	double tmp;
	if (g <= -5.469826934247915e-160) {
		tmp = (Math.cbrt(t_0) / Math.cbrt((2.0 * a))) + Math.cbrt((((0.5 * (Math.pow(h, 2.0) / g)) / a) * -0.5));
	} else {
		tmp = Math.cbrt((t_0 / (2.0 * a))) + (Math.cbrt((-0.5 * (g + g))) / Math.cbrt(a));
	}
	return tmp;
}
function code(g, h, a)
	return Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(Float64(-g) + sqrt(Float64(Float64(g * g) - Float64(h * h)))))) + cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(Float64(-g) - sqrt(Float64(Float64(g * g) - Float64(h * h)))))))
end
function code(g, h, a)
	t_0 = Float64(sqrt(Float64(Float64(g * g) - Float64(h * h))) - g)
	tmp = 0.0
	if (g <= -5.469826934247915e-160)
		tmp = Float64(Float64(cbrt(t_0) / cbrt(Float64(2.0 * a))) + cbrt(Float64(Float64(Float64(0.5 * Float64((h ^ 2.0) / g)) / a) * -0.5)));
	else
		tmp = Float64(cbrt(Float64(t_0 / Float64(2.0 * a))) + Float64(cbrt(Float64(-0.5 * Float64(g + g))) / cbrt(a)));
	end
	return tmp
end
code[g_, h_, a_] := N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[((-g) + N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[((-g) - N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
code[g_, h_, a_] := Block[{t$95$0 = N[(N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision]}, If[LessEqual[g, -5.469826934247915e-160], N[(N[(N[Power[t$95$0, 1/3], $MachinePrecision] / N[Power[N[(2.0 * a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[(0.5 * N[(N[Power[h, 2.0], $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(t$95$0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[N[(-0.5 * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\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{g \cdot g - h \cdot h} - g\\
\mathbf{if}\;g \leq -5.469826934247915 \cdot 10^{-160}:\\
\;\;\;\;\frac{\sqrt[3]{t_0}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{0.5 \cdot \frac{{h}^{2}}{g}}{a} \cdot -0.5}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{t_0}{2 \cdot a}} + \frac{\sqrt[3]{-0.5 \cdot \left(g + g\right)}}{\sqrt[3]{a}}\\


\end{array}

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 < -5.46982693424791488e-160

    1. Initial program 35.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. Simplified35.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_binary6431.2

      \[\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 30.8

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

    if -5.46982693424791488e-160 < g

    1. Initial program 36.9

      \[\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.9

      \[\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/_binary6436.9

      \[\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_binary6433.0

      \[\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 32.0

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

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

Reproduce

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