\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 -7.45076962416815215 \cdot 10^{-7}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3}}{a}\\
\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)) <= -7.450769624168152e-07)) {
temp = ((fma(b, b, -((b * b) - ((3.0 * a) * c))) / (-b - sqrt(((b * b) - ((3.0 * a) * c))))) / (3.0 * a));
} else {
temp = (((-1.5 * ((a * c) / b)) / 3.0) / a);
}
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)) < -7.450769624168152e-07Initial program 17.9
rmApplied flip-+18.0
Simplified17.2
if -7.450769624168152e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) Initial program 42.7
Taylor expanded around inf 11.5
rmApplied associate-/r*11.4
Final simplification14.7
herbie shell --seed 2020057 +o rules:numerics
(FPCore (a b c)
:name "Cubic critical, narrow range"
:precision binary64
:pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))