Average Error: 28.4 → 5.9
Time: 6.2s
Precision: binary64
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[-0.5 \cdot \frac{c}{b} - \frac{\mathsf{fma}\left(1.125, \frac{{\left(c \cdot a\right)}^{2}}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}}\right)\right)}{a \cdot 3} \]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
-0.5 \cdot \frac{c}{b} - \frac{\mathsf{fma}\left(1.125, \frac{{\left(c \cdot a\right)}^{2}}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}}\right)\right)}{a \cdot 3}
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (-
  (* -0.5 (/ c b))
  (/
   (fma
    1.125
    (/ (pow (* c a) 2.0) (pow b 3.0))
    (fma
     1.6875
     (/ (pow (* c a) 3.0) (pow b 5.0))
     (* 3.1640625 (/ (pow (* c a) 4.0) (pow b 7.0)))))
   (* a 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 (-0.5 * (c / b)) - (fma(1.125, (pow((c * a), 2.0) / pow(b, 3.0)), fma(1.6875, (pow((c * a), 3.0) / pow(b, 5.0)), (3.1640625 * (pow((c * a), 4.0) / pow(b, 7.0))))) / (a * 3.0));
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.4

    \[\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 6.2

    \[\leadsto \frac{\color{blue}{-\left(1.5 \cdot \frac{c \cdot a}{b} + \left(1.125 \cdot \frac{{c}^{2} \cdot {a}^{2}}{{b}^{3}} + \left(3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}} + 1.6875 \cdot \frac{{c}^{3} \cdot {a}^{3}}{{b}^{5}}\right)\right)\right)}}{3 \cdot a} \]
  3. Simplified6.2

    \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{c \cdot a}{b} - \mathsf{fma}\left(1.125, \frac{\left(c \cdot a\right) \cdot \left(c \cdot a\right)}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{c}^{3} \cdot {a}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}}\right)\right)}}{3 \cdot a} \]
  4. Applied egg-rr6.2

    \[\leadsto \color{blue}{\frac{-1.5 \cdot \frac{c \cdot a}{b}}{a \cdot 3} - \frac{\mathsf{fma}\left(1.125, \frac{{\left(c \cdot a\right)}^{2}}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}}\right)\right)}{a \cdot 3}} \]
  5. Taylor expanded in c around 0 5.9

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} - \frac{\mathsf{fma}\left(1.125, \frac{{\left(c \cdot a\right)}^{2}}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}}\right)\right)}{a \cdot 3} \]
  6. Final simplification5.9

    \[\leadsto -0.5 \cdot \frac{c}{b} - \frac{\mathsf{fma}\left(1.125, \frac{{\left(c \cdot a\right)}^{2}}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}}\right)\right)}{a \cdot 3} \]

Reproduce

herbie shell --seed 2022125 
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))