\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \leq -7.102439644234899 \cdot 10^{-32}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\mathbf{elif}\;b \leq 9.908180707161701 \cdot 10^{-62}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
:precision binary64
(if (<= b -7.102439644234899e-32)
(/ (* b -2.0) (* a 2.0))
(if (<= b 9.908180707161701e-62)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(- (/ c b)))))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 tmp;
if (b <= -7.102439644234899e-32) {
tmp = (b * -2.0) / (a * 2.0);
} else if (b <= 9.908180707161701e-62) {
tmp = (sqrt((b * b) - ((a * 4.0) * c)) - b) / (a * 2.0);
} else {
tmp = -(c / b);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -7.1024396442348992e-32Initial program 30.2
Simplified30.2
Taylor expanded around -inf 8.8
if -7.1024396442348992e-32 < b < 9.9081807071617013e-62Initial program 15.4
if 9.9081807071617013e-62 < b Initial program 54.2
Simplified54.2
Taylor expanded around inf 8.3
Simplified8.3
Final simplification10.9
herbie shell --seed 2021044
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))