Average Error: 35.8 → 2.4
Time: 11.5s
Precision: binary64
Cost: 40128
\[\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 := h \cdot \frac{h}{g}\\ \frac{\sqrt[3]{\left(\mathsf{fma}\left(-0.5, t_0, g\right) - g\right) \cdot 0.5}}{\sqrt[3]{a}} + \sqrt[3]{\mathsf{fma}\left(-0.5, t_0, g + g\right)} \cdot \sqrt[3]{\frac{-0.5}{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 (* h (/ h g))))
   (+
    (/ (cbrt (* (- (fma -0.5 t_0 g) g) 0.5)) (cbrt a))
    (* (cbrt (fma -0.5 t_0 (+ g g))) (cbrt (/ -0.5 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 = h * (h / g);
	return (cbrt(((fma(-0.5, t_0, g) - g) * 0.5)) / cbrt(a)) + (cbrt(fma(-0.5, t_0, (g + g))) * cbrt((-0.5 / 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)
	t_0 = Float64(h * Float64(h / g))
	return Float64(Float64(cbrt(Float64(Float64(fma(-0.5, t_0, g) - g) * 0.5)) / cbrt(a)) + Float64(cbrt(fma(-0.5, t_0, Float64(g + g))) * cbrt(Float64(-0.5 / 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_] := Block[{t$95$0 = N[(h * N[(h / g), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Power[N[(N[(N[(-0.5 * t$95$0 + g), $MachinePrecision] - g), $MachinePrecision] * 0.5), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[(-0.5 * t$95$0 + N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(-0.5 / a), $MachinePrecision], 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 := h \cdot \frac{h}{g}\\
\frac{\sqrt[3]{\left(\mathsf{fma}\left(-0.5, t_0, g\right) - g\right) \cdot 0.5}}{\sqrt[3]{a}} + \sqrt[3]{\mathsf{fma}\left(-0.5, t_0, g + g\right)} \cdot \sqrt[3]{\frac{-0.5}{a}}
\end{array}

Error

Derivation

  1. Initial program 35.8

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

    \[\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 g around inf 46.7

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

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\left(g + \color{blue}{\mathsf{fma}\left(-0.5, \frac{h}{\frac{g}{h}}, g\right)}\right) \cdot \frac{-0.5}{a}} \]
    Proof
    (fma.f64 -1/2 (/.f64 h (/.f64 g h)) g): 0 points increase in error, 0 points decrease in error
    (fma.f64 -1/2 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 h h) g)) g): 19 points increase in error, 0 points decrease in error
    (fma.f64 -1/2 (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 h 2)) g) g): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 -1/2 (/.f64 (pow.f64 h 2) g)) g)): 0 points increase in error, 0 points decrease in error
  5. Taylor expanded in g around inf 19.2

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{\left(-0.5 \cdot \frac{{h}^{2}}{g} + g\right)} - g\right)} + \sqrt[3]{\left(g + \mathsf{fma}\left(-0.5, \frac{h}{\frac{g}{h}}, g\right)\right) \cdot \frac{-0.5}{a}} \]
  6. Simplified17.0

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\color{blue}{\mathsf{fma}\left(-0.5, \frac{h}{\frac{g}{h}}, g\right)} - g\right)} + \sqrt[3]{\left(g + \mathsf{fma}\left(-0.5, \frac{h}{\frac{g}{h}}, g\right)\right) \cdot \frac{-0.5}{a}} \]
    Proof
    (fma.f64 -1/2 (/.f64 h (/.f64 g h)) g): 0 points increase in error, 0 points decrease in error
    (fma.f64 -1/2 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 h h) g)) g): 19 points increase in error, 0 points decrease in error
    (fma.f64 -1/2 (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 h 2)) g) g): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 -1/2 (/.f64 (pow.f64 h 2) g)) g)): 0 points increase in error, 0 points decrease in error
  7. Applied egg-rr2.6

    \[\leadsto \sqrt[3]{\frac{0.5}{a} \cdot \left(\mathsf{fma}\left(-0.5, \frac{h}{\frac{g}{h}}, g\right) - g\right)} + \color{blue}{\sqrt[3]{\mathsf{fma}\left(-0.5, h \cdot \frac{h}{g}, g + g\right)} \cdot \sqrt[3]{\frac{-0.5}{a}}} \]
  8. Applied egg-rr2.4

    \[\leadsto \color{blue}{\frac{\sqrt[3]{\left(\mathsf{fma}\left(-0.5, h \cdot \frac{h}{g}, g\right) - g\right) \cdot 0.5}}{\sqrt[3]{a}}} + \sqrt[3]{\mathsf{fma}\left(-0.5, h \cdot \frac{h}{g}, g + g\right)} \cdot \sqrt[3]{\frac{-0.5}{a}} \]
  9. Final simplification2.4

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

Alternatives

Alternative 1
Error2.6
Cost33728
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(\mathsf{fma}\left(-0.5, \frac{h}{\frac{g}{h}}, g\right) - g\right)} + \frac{\sqrt[3]{-0.5 \cdot \mathsf{fma}\left(-0.5, h \cdot \frac{h}{g}, g + g\right)}}{\sqrt[3]{a}} \]
Alternative 2
Error2.6
Cost33728
\[\sqrt[3]{\mathsf{fma}\left(-0.5, h \cdot \frac{h}{g}, g + g\right)} \cdot \sqrt[3]{\frac{-0.5}{a}} + \sqrt[3]{\frac{0.5}{a} \cdot \left(\mathsf{fma}\left(-0.5, \frac{h}{\frac{g}{h}}, g\right) - g\right)} \]
Alternative 3
Error2.9
Cost33344
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(\mathsf{fma}\left(-0.5, \frac{h}{\frac{g}{h}}, g\right) - g\right)} + \sqrt[3]{\frac{-0.5}{a}} \cdot \left(\sqrt[3]{g} \cdot \sqrt[3]{2}\right) \]
Alternative 4
Error2.8
Cost20288
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{\frac{-0.5}{a}}}{\sqrt[3]{0.5 \cdot \frac{1}{g}}} \]
Alternative 5
Error2.8
Cost19968
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{\sqrt[3]{-g}}{\sqrt[3]{a}} \]
Alternative 6
Error16.9
Cost14016
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \frac{1}{\sqrt[3]{\left(0.5 \cdot \frac{1}{g}\right) \cdot \left(a \cdot -2\right)}} \]
Alternative 7
Error17.3
Cost13760
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\left(g + g\right) \cdot \frac{-0.5}{a}} \]
Alternative 8
Error17.3
Cost13568
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{-g}{a}} \]
Alternative 9
Error63.2
Cost13504
\[\sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)} + \sqrt[3]{\frac{g}{a}} \]

Error

Reproduce

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