\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 -3.334085620187398 \cdot 10^{+39}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\mathbf{elif}\;b \leq 2.111603012388429 \cdot 10^{-140}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}{a \cdot 2} - \frac{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 -3.334085620187398e+39)
(/ (* b -2.0) (* a 2.0))
(if (<= b 2.111603012388429e-140)
(- (/ (sqrt (- (* b b) (* (* a 4.0) c))) (* a 2.0)) (/ 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 <= -3.334085620187398e+39) {
tmp = (b * -2.0) / (a * 2.0);
} else if (b <= 2.111603012388429e-140) {
tmp = (sqrt((b * b) - ((a * 4.0) * c)) / (a * 2.0)) - (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 < -3.3340856201873979e39Initial program 36.4
Simplified36.4
Taylor expanded around -inf 6.2
if -3.3340856201873979e39 < b < 2.11160301238842913e-140Initial program 12.1
Simplified12.1
rmApplied div-sub_binary64_42412.1
if 2.11160301238842913e-140 < b Initial program 50.1
Simplified50.1
Taylor expanded around inf 12.8
Simplified12.8
Final simplification11.2
herbie shell --seed 2021022
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))