Average Error: 35.7 → 2.5
Time: 13.3s
Precision: binary64
Cost: 19968
\[\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)} + \frac{\sqrt[3]{-g}}{\sqrt[3]{a}} \]
(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 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) {
	return cbrt(((0.5 / a) * (g - g))) + (cbrt(-g) / cbrt(a));
}
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(a));
}
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(cbrt(Float64(-g)) / cbrt(a)))
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[Power[(-g), 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)}
\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{-g}}{\sqrt[3]{a}}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 35.7

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

    \[\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
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1/2 a) (-.f64 (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))) g))) (cbrt.f64 (*.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))) (/.f64 -1/2 a)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 (Rewrite<= metadata-eval (/.f64 1 2)) a) (-.f64 (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))) g))) (cbrt.f64 (*.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))) (/.f64 -1/2 a)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (Rewrite<= associate-/r*_binary64 (/.f64 1 (*.f64 2 a))) (-.f64 (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))) g))) (cbrt.f64 (*.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))) (/.f64 -1/2 a)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (Rewrite<= unsub-neg_binary64 (+.f64 (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))) (neg.f64 g))))) (cbrt.f64 (*.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))) (/.f64 -1/2 a)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) (cbrt.f64 (*.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))) (/.f64 -1/2 a)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))) (/.f64 (Rewrite<= metadata-eval (*.f64 1/2 -1)) a)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))) (/.f64 (*.f64 (Rewrite<= metadata-eval (/.f64 1 2)) -1) a)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))) (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 (/.f64 1 2) a) -1))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))) (*.f64 (Rewrite<= associate-/r*_binary64 (/.f64 1 (*.f64 2 a))) -1)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (Rewrite=> *-commutative_binary64 (*.f64 (*.f64 (/.f64 1 (*.f64 2 a)) -1) (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (Rewrite<= associate-*r*_binary64 (*.f64 (/.f64 1 (*.f64 2 a)) (*.f64 -1 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (Rewrite<= neg-mul-1_binary64 (neg.f64 (+.f64 g (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (Rewrite<= distribute-neg-out_binary64 (+.f64 (neg.f64 g) (neg.f64 (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (Rewrite<= sub-neg_binary64 (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))))): 0 points increase in error, 0 points decrease in error
  3. Taylor expanded in h around 0 55.8

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

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \color{blue}{\sqrt[3]{-0.5} \cdot \left(\sqrt[3]{2} \cdot \sqrt[3]{\frac{g}{a}}\right)} \]
    Proof
    (*.f64 (cbrt.f64 -1/2) (*.f64 (cbrt.f64 2) (cbrt.f64 (/.f64 g a)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (cbrt.f64 -1/2) (*.f64 (cbrt.f64 2) (cbrt.f64 (/.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 g)) a)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (cbrt.f64 -1/2) (*.f64 (cbrt.f64 2) (Rewrite<= unpow1/3_binary64 (pow.f64 (/.f64 (*.f64 1 g) a) 1/3)))): 191 points increase in error, 8 points decrease in error
    (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 (cbrt.f64 -1/2) (cbrt.f64 2)) (pow.f64 (/.f64 (*.f64 1 g) a) 1/3))): 22 points increase in error, 15 points decrease in error
    (Rewrite<= *-commutative_binary64 (*.f64 (pow.f64 (/.f64 (*.f64 1 g) a) 1/3) (*.f64 (cbrt.f64 -1/2) (cbrt.f64 2)))): 0 points increase in error, 0 points decrease in error
  5. Taylor expanded in g around inf 17.9

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

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

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

Alternatives

Alternative 1
Error17.2
Cost20040
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\ \mathbf{if}\;g \leq 0:\\ \;\;\;\;t_0 + \sqrt[3]{\left(\frac{0.5}{g} \cdot \left(h \cdot h\right)\right) \cdot \frac{-0.5}{a}}\\ \mathbf{elif}\;g \leq 4.5 \cdot 10^{-24}:\\ \;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} + {\left(g + g\right)}^{3.3333333333333335}\\ \mathbf{else}:\\ \;\;\;\;t_0 + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}\\ \end{array} \]
Alternative 2
Error17.2
Cost14148
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\ \mathbf{if}\;g \leq -7 \cdot 10^{-172}:\\ \;\;\;\;t_0 + \sqrt[3]{\left(\frac{0.5}{g} \cdot \left(h \cdot h\right)\right) \cdot \frac{-0.5}{a}}\\ \mathbf{elif}\;g \leq 1.6 \cdot 10^{-76}:\\ \;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} - g\\ \mathbf{else}:\\ \;\;\;\;t_0 + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}\\ \end{array} \]
Alternative 3
Error16.1
Cost14024
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)}\\ \mathbf{if}\;a \leq -4.7470246873734645 \cdot 10^{-240}:\\ \;\;\;\;t_0 - \sqrt[3]{\frac{g}{a}}\\ \mathbf{elif}\;a \leq 5.96471841423863 \cdot 10^{-181}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} - g\\ \mathbf{else}:\\ \;\;\;\;t_0 + \sqrt[3]{-0.5 \cdot \frac{2}{\frac{a}{g}}}\\ \end{array} \]
Alternative 4
Error16.5
Cost14024
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}\\ \mathbf{if}\;g \leq -5.2 \cdot 10^{-192}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;g \leq 1.6 \cdot 10^{-76}:\\ \;\;\;\;\frac{\sqrt[3]{-g}}{\sqrt[3]{a}} - g\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error15.9
Cost13768
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} - \sqrt[3]{\frac{g}{a}}\\ \mathbf{if}\;a \leq -4.7470246873734645 \cdot 10^{-240}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 5.96471841423863 \cdot 10^{-181}:\\ \;\;\;\;\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g \cdot -2} - g\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error38.5
Cost7496
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\ t_1 := t_0 + \frac{g + g}{a}\\ \mathbf{if}\;a \leq -8.503575272543727 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.465349214684264 \cdot 10^{-11}:\\ \;\;\;\;t_0 + \left(g + g\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error38.5
Cost7496
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\ t_1 := t_0 + \frac{g + g}{a}\\ \mathbf{if}\;a \leq -8.503575272543727 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.465349214684264 \cdot 10^{-11}:\\ \;\;\;\;t_0 + 0.5 \cdot \left(g + g\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error22.2
Cost7496
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\ t_1 := t_0 + \frac{1}{g + g}\\ \mathbf{if}\;g \leq -0.7:\\ \;\;\;\;t_1\\ \mathbf{elif}\;g \leq 9.5 \cdot 10^{-9}:\\ \;\;\;\;t_0 + 0.5 \cdot \left(g + g\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error21.3
Cost7496
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\ t_1 := t_0 + \frac{1}{g + g}\\ \mathbf{if}\;g \leq -0.23:\\ \;\;\;\;t_1\\ \mathbf{elif}\;g \leq 9.5 \cdot 10^{-9}:\\ \;\;\;\;t_0 + \left(g \cdot g\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error50.3
Cost7104
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + \left(g + g\right) \]
Alternative 11
Error50.3
Cost6976
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} - g \]
Alternative 12
Error50.3
Cost6784
\[\sqrt[3]{\frac{-g}{a}} - g \]
Alternative 13
Error61.7
Cost128
\[-g \]
Alternative 14
Error62.1
Cost64
\[0 \]

Error

Reproduce

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