\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 -2.744341717572267 \cdot 10^{+94}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq -3.965802121632277 \cdot 10^{-209}:\\
\;\;\;\;\left(\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{elif}\;b \leq 2.020343938322325 \cdot 10^{+102}:\\
\;\;\;\;c \cdot \frac{-2}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\
\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 -2.744341717572267e+94)
(- (/ c b) (/ b a))
(if (<= b -3.965802121632277e-209)
(* (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (/ 0.5 a))
(if (<= b 2.020343938322325e+102)
(* c (/ -2.0 (+ b (sqrt (- (* b b) (* c (* a 4.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 <= -2.744341717572267e+94) {
tmp = (c / b) - (b / a);
} else if (b <= -3.965802121632277e-209) {
tmp = (sqrt((b * b) - (c * (a * 4.0))) - b) * (0.5 / a);
} else if (b <= 2.020343938322325e+102) {
tmp = c * (-2.0 / (b + sqrt((b * b) - (c * (a * 4.0)))));
} else {
tmp = -(c / b);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -2.74434171757226696e94Initial program 44.9
Simplified44.9
Taylor expanded around -inf 4.4
if -2.74434171757226696e94 < b < -3.9658021216322772e-209Initial program 7.9
Simplified7.9
rmApplied div-inv_binary648.1
Simplified8.1
if -3.9658021216322772e-209 < b < 2.0203439383223249e102Initial program 30.5
Simplified30.5
rmApplied flip--_binary6430.6
Simplified16.9
Simplified16.9
rmApplied *-un-lft-identity_binary6416.9
Applied times-frac_binary6416.9
Applied times-frac_binary6416.2
Simplified10.3
Simplified10.3
if 2.0203439383223249e102 < b Initial program 59.6
Simplified59.6
Taylor expanded around inf 2.4
Simplified2.4
Final simplification7.0
herbie shell --seed 2020232
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))