\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \le -3.73397243102552555 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot c}{\left(2 \cdot a\right) \cdot \frac{b}{a}}\\
\end{array}double code(double a, double b, double c) {
return ((-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a));
}
double code(double a, double b, double c) {
double temp;
if ((((-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)) <= -3.7339724310255256e-06)) {
temp = ((fma(b, b, -((b * b) - ((4.0 * a) * c))) / (-b - sqrt(((b * b) - ((4.0 * a) * c))))) / (2.0 * a));
} else {
temp = ((-2.0 * c) / ((2.0 * a) * (b / a)));
}
return temp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) < -3.7339724310255256e-06Initial program 17.6
rmApplied flip-+17.6
Simplified16.8
if -3.7339724310255256e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) Initial program 41.1
Taylor expanded around inf 12.6
rmApplied *-commutative12.6
Applied associate-/l*12.7
Applied associate-*r/12.7
Applied associate-/l/12.6
Final simplification14.9
herbie shell --seed 2020066 +o rules:numerics
(FPCore (a b c)
:name "Quadratic roots, 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) (* (* 4 a) c)))) (* 2 a)))