\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -1.4363725490879053 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}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) {
double temp;
if ((((-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)) <= -1.4363725490879053e-06)) {
temp = ((fma(b, b, -((b * b) - ((3.0 * a) * c))) / (-b - sqrt(((b * b) - ((3.0 * a) * c))))) / (3.0 * a));
} else {
temp = (-0.5 * (c / b));
}
return temp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) < -1.4363725490879053e-06Initial program 21.6
rmApplied flip-+21.6
Simplified20.9
if -1.4363725490879053e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) Initial program 52.5
Taylor expanded around inf 5.8
Final simplification10.0
herbie shell --seed 2020060 +o rules:numerics
(FPCore (a b c)
:name "Cubic critical, medium range"
:precision binary64
:pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))