Average Error: 35.8 → 31.0
Time: 15.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 := \sqrt{g \cdot g - h \cdot h}\\ t_1 := \sqrt[3]{2 \cdot a}\\ \mathbf{if}\;g \leq 2.190077304331994 \cdot 10^{-161}:\\ \;\;\;\;\frac{\sqrt[3]{g \cdot -2}}{t_1} + \sqrt[3]{\left(g + t_0\right) \cdot \frac{-1}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{-0.5 \cdot \frac{{h}^{2}}{g}}}{t_1} + \frac{\sqrt[3]{\left(-g\right) - t_0}}{t_1}\\ \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)))) (t_1 (cbrt (* 2.0 a))))
   (if (<= g 2.190077304331994e-161)
     (+ (/ (cbrt (* g -2.0)) t_1) (cbrt (* (+ g t_0) (/ -1.0 (* 2.0 a)))))
     (+
      (/ (cbrt (* -0.5 (/ (pow h 2.0) g))) t_1)
      (/ (cbrt (- (- g) t_0)) t_1)))))
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)));
	double t_1 = cbrt((2.0 * a));
	double tmp;
	if (g <= 2.190077304331994e-161) {
		tmp = (cbrt((g * -2.0)) / t_1) + cbrt(((g + t_0) * (-1.0 / (2.0 * a))));
	} else {
		tmp = (cbrt((-0.5 * (pow(h, 2.0) / g))) / t_1) + (cbrt((-g - t_0)) / t_1);
	}
	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)));
	double t_1 = Math.cbrt((2.0 * a));
	double tmp;
	if (g <= 2.190077304331994e-161) {
		tmp = (Math.cbrt((g * -2.0)) / t_1) + Math.cbrt(((g + t_0) * (-1.0 / (2.0 * a))));
	} else {
		tmp = (Math.cbrt((-0.5 * (Math.pow(h, 2.0) / g))) / t_1) + (Math.cbrt((-g - t_0)) / t_1);
	}
	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 = sqrt(Float64(Float64(g * g) - Float64(h * h)))
	t_1 = cbrt(Float64(2.0 * a))
	tmp = 0.0
	if (g <= 2.190077304331994e-161)
		tmp = Float64(Float64(cbrt(Float64(g * -2.0)) / t_1) + cbrt(Float64(Float64(g + t_0) * Float64(-1.0 / Float64(2.0 * a)))));
	else
		tmp = Float64(Float64(cbrt(Float64(-0.5 * Float64((h ^ 2.0) / g))) / t_1) + Float64(cbrt(Float64(Float64(-g) - t_0)) / t_1));
	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[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(2.0 * a), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[g, 2.190077304331994e-161], N[(N[(N[Power[N[(g * -2.0), $MachinePrecision], 1/3], $MachinePrecision] / t$95$1), $MachinePrecision] + N[Power[N[(N[(g + t$95$0), $MachinePrecision] * N[(-1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(-0.5 * N[(N[Power[h, 2.0], $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[Power[N[((-g) - t$95$0), $MachinePrecision], 1/3], $MachinePrecision] / t$95$1), $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}\\
t_1 := \sqrt[3]{2 \cdot a}\\
\mathbf{if}\;g \leq 2.190077304331994 \cdot 10^{-161}:\\
\;\;\;\;\frac{\sqrt[3]{g \cdot -2}}{t_1} + \sqrt[3]{\left(g + t_0\right) \cdot \frac{-1}{2 \cdot a}}\\

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


\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 < 2.1900773043319939e-161

    1. Initial program 36.0

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

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

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

      \[\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. Taylor expanded in g around -inf 31.2

      \[\leadsto \frac{\sqrt[3]{\color{blue}{-2 \cdot 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)} \]

    if 2.1900773043319939e-161 < g

    1. Initial program 35.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. Applied associate-*l/_binary6435.6

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

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

      \[\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 associate-*l/_binary6435.5

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

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

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

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

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

Reproduce

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