Average Error: 36.2 → 2.4
Time: 13.9s
Precision: binary64
Cost: 33152
\[\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)} \]
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot {4}^{0.16666666666666666}\right) \]
(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
 (+
  (cbrt (* (/ 0.5 a) (- g g)))
  (*
   (* (cbrt g) (cbrt (/ 1.0 a)))
   (* (cbrt -0.5) (pow 4.0 0.16666666666666666)))))
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) {
	return cbrt(((0.5 / a) * (g - g))) + ((cbrt(g) * cbrt((1.0 / a))) * (cbrt(-0.5) * pow(4.0, 0.16666666666666666)));
}
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) {
	return Math.cbrt(((0.5 / a) * (g - g))) + ((Math.cbrt(g) * Math.cbrt((1.0 / a))) * (Math.cbrt(-0.5) * Math.pow(4.0, 0.16666666666666666)));
}
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)
	return Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g - g))) + Float64(Float64(cbrt(g) * cbrt(Float64(1.0 / a))) * Float64(cbrt(-0.5) * (4.0 ^ 0.16666666666666666))))
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_] := N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[(N[Power[-0.5, 1/3], $MachinePrecision] * N[Power[4.0, 0.16666666666666666], $MachinePrecision]), $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)}
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot {4}^{0.16666666666666666}\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 36.2

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

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

    [Start]36.2

    \[ \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)} \]

    +-commutative [=>]36.2

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

    associate-/r* [=>]36.2

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

    metadata-eval [=>]36.2

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

    unsub-neg [=>]36.2

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

    sub-neg [=>]36.2

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

    distribute-neg-out [=>]36.2

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

    neg-mul-1 [=>]36.2

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

    associate-*r* [=>]36.2

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

    *-commutative [<=]36.2

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

    associate-*l/ [=>]36.2

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

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{g} - g\right)} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-0.5}{a}} \]
  4. Taylor expanded in h around 0 41.9

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \color{blue}{{\left(\frac{1 \cdot g}{a}\right)}^{0.3333333333333333} \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right)} \]
  5. Applied egg-rr2.7

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

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot \color{blue}{{4}^{0.16666666666666666}}\right) \]
  7. Final simplification2.4

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot {4}^{0.16666666666666666}\right) \]

Alternatives

Alternative 1
Error2.7
Cost33088
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{g} \cdot \sqrt[3]{\frac{1}{a}}\right) \cdot \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \]
Alternative 2
Error2.9
Cost32960
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{-0.5} \cdot \sqrt[3]{2}\right) \cdot \frac{\sqrt[3]{g}}{\sqrt[3]{a}} \]
Alternative 3
Error13.4
Cost27473
\[\begin{array}{l} t_0 := g + \sqrt{g \cdot g - h \cdot h}\\ t_1 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)}\\ t_2 := t_1 + \left(\sqrt[3]{-0.5} \cdot {4}^{0.16666666666666666}\right) \cdot \frac{1}{\sqrt[3]{\frac{a}{g}}}\\ \mathbf{if}\;g \leq -8.2 \cdot 10^{+152}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;g \leq -1.46 \cdot 10^{-155}:\\ \;\;\;\;\frac{\sqrt[3]{0.5 \cdot \left(g \cdot -2\right)}}{\sqrt[3]{a}} + \sqrt[3]{t_0 \cdot \frac{-0.5}{a}}\\ \mathbf{elif}\;g \leq 2.35 \cdot 10^{-157} \lor \neg \left(g \leq 1.35 \cdot 10^{+154}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\sqrt[3]{-0.5 \cdot t_0}}{\sqrt[3]{a}}\\ \end{array} \]
Alternative 4
Error15.1
Cost27209
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)}\\ \mathbf{if}\;g \leq 3.2 \cdot 10^{-158} \lor \neg \left(g \leq 1.35 \cdot 10^{+154}\right):\\ \;\;\;\;t_0 + \left(\sqrt[3]{-0.5} \cdot {4}^{0.16666666666666666}\right) \cdot \frac{1}{\sqrt[3]{\frac{a}{g}}}\\ \mathbf{else}:\\ \;\;\;\;t_0 + \sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + \sqrt{g \cdot g - h \cdot h}}\\ \end{array} \]
Alternative 5
Error15.1
Cost27209
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)}\\ \mathbf{if}\;g \leq 2.6 \cdot 10^{-159} \lor \neg \left(g \leq 1.35 \cdot 10^{+154}\right):\\ \;\;\;\;t_0 + \left(\sqrt[3]{-0.5} \cdot {4}^{0.16666666666666666}\right) \cdot \frac{1}{\sqrt[3]{\frac{a}{g}}}\\ \mathbf{else}:\\ \;\;\;\;t_0 + \frac{\sqrt[3]{-0.5 \cdot \left(g + \sqrt{g \cdot g - h \cdot h}\right)}}{\sqrt[3]{a}}\\ \end{array} \]
Alternative 6
Error16.8
Cost26752
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \left(\sqrt[3]{-0.5} \cdot {4}^{0.16666666666666666}\right) \cdot \frac{1}{\sqrt[3]{\frac{a}{g}}} \]
Alternative 7
Error17.3
Cost13568
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}} \]
Alternative 8
Error62.1
Cost6848
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} \]

Error

Reproduce

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