\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));
}



Bits error versus a



Bits error versus b



Bits error versus c
Initial program 28.4
Taylor expanded in b around inf 6.2
Simplified6.2
Applied egg-rr6.2
Taylor expanded in c around 0 5.9
Final simplification5.9
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)))