Average Error: 43.8 → 2.9
Time: 14.8s
Precision: binary64
Cost: 47296
\[\left(\left(1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992\right) \land \left(1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992\right)\right) \land \left(1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\mathsf{fma}\left(-0.5625, \frac{\left(\left(a \cdot a\right) \cdot c\right) \cdot \left(c \cdot c\right)}{{b}^{5}}, \mathsf{fma}\left(-0.16666666666666666, \left({\left(c \cdot a\right)}^{4} \cdot 6.328125\right) \cdot \frac{{b}^{-7}}{a}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right)\right)\right) \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (fma
  -0.5625
  (/ (* (* (* a a) c) (* c c)) (pow b 5.0))
  (fma
   -0.16666666666666666
   (* (* (pow (* c a) 4.0) 6.328125) (/ (pow b -7.0) a))
   (fma -0.5 (/ c b) (/ (* -0.375 (* (* c c) a)) (pow b 3.0))))))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
double code(double a, double b, double c) {
	return fma(-0.5625, ((((a * a) * c) * (c * c)) / pow(b, 5.0)), fma(-0.16666666666666666, ((pow((c * a), 4.0) * 6.328125) * (pow(b, -7.0) / a)), fma(-0.5, (c / b), ((-0.375 * ((c * c) * a)) / pow(b, 3.0)))));
}
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function code(a, b, c)
	return fma(-0.5625, Float64(Float64(Float64(Float64(a * a) * c) * Float64(c * c)) / (b ^ 5.0)), fma(-0.16666666666666666, Float64(Float64((Float64(c * a) ^ 4.0) * 6.328125) * Float64((b ^ -7.0) / a)), fma(-0.5, Float64(c / b), Float64(Float64(-0.375 * Float64(Float64(c * c) * a)) / (b ^ 3.0)))))
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := N[(-0.5625 * N[(N[(N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-0.16666666666666666 * N[(N[(N[Power[N[(c * a), $MachinePrecision], 4.0], $MachinePrecision] * 6.328125), $MachinePrecision] * N[(N[Power[b, -7.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision] + N[(N[(-0.375 * N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\mathsf{fma}\left(-0.5625, \frac{\left(\left(a \cdot a\right) \cdot c\right) \cdot \left(c \cdot c\right)}{{b}^{5}}, \mathsf{fma}\left(-0.16666666666666666, \left({\left(c \cdot a\right)}^{4} \cdot 6.328125\right) \cdot \frac{{b}^{-7}}{a}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right)\right)\right)

Error

Derivation

  1. Initial program 43.8

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Taylor expanded in b around inf 2.9

    \[\leadsto \color{blue}{-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)} \]
  3. Simplified2.9

    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5625, \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}, \mathsf{fma}\left(-0.16666666666666666, \frac{\mathsf{fma}\left({\left(c \cdot a\right)}^{4}, 5.0625, \left(-1.125 \cdot -1.125\right) \cdot {\left(c \cdot a\right)}^{4}\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right)\right)\right)} \]
    Proof
  4. Applied egg-rr2.9

    \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}, \mathsf{fma}\left(-0.16666666666666666, \color{blue}{\left({\left(c \cdot a\right)}^{4} \cdot 6.328125\right) \cdot \frac{{b}^{-7}}{a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right)\right)\right) \]
  5. Applied egg-rr2.9

    \[\leadsto \mathsf{fma}\left(-0.5625, \frac{\color{blue}{\left(\left(a \cdot a\right) \cdot c\right) \cdot \left(c \cdot c\right)}}{{b}^{5}}, \mathsf{fma}\left(-0.16666666666666666, \left({\left(c \cdot a\right)}^{4} \cdot 6.328125\right) \cdot \frac{{b}^{-7}}{a}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right)\right)\right) \]

Alternatives

Alternative 1
Error3.9
Cost27328
\[\mathsf{fma}\left(-0.5625, \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{\frac{\left(c \cdot c\right) \cdot a}{b \cdot b} \cdot -0.375}{b}\right)\right) \]
Alternative 2
Error12.1
Cost14092
\[\begin{array}{l} \mathbf{if}\;b \leq 2.95 \cdot 10^{-7}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{elif}\;b \leq 0.055:\\ \;\;\;\;\frac{-0.5}{b} \cdot c\\ \mathbf{elif}\;b \leq 7.5:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \]
Alternative 3
Error5.9
Cost13696
\[\mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right) \]
Alternative 4
Error12.1
Cost7820
\[\begin{array}{l} t_0 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{if}\;b \leq 2.95 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 0.055:\\ \;\;\;\;\frac{-0.5}{b} \cdot c\\ \mathbf{elif}\;b \leq 7.5:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \]
Alternative 5
Error12.1
Cost7756
\[\begin{array}{l} t_0 := \left(b - \sqrt{b \cdot b + \left(-3 \cdot c\right) \cdot a}\right) \cdot \frac{-0.3333333333333333}{a}\\ \mathbf{if}\;b \leq 2.95 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 0.055:\\ \;\;\;\;\frac{-0.5}{b} \cdot c\\ \mathbf{elif}\;b \leq 7.5:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \]
Alternative 6
Error12.2
Cost320
\[\frac{-0.5}{b} \cdot c \]
Alternative 7
Error12.0
Cost320
\[\frac{-0.5 \cdot c}{b} \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))