\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 -8.273540851308956 \cdot 10^{+145}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq -3.561644019231982 \cdot 10^{-259}:\\
\;\;\;\;\left(\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{elif}\;b \leq 5.421378530068417 \cdot 10^{+117}:\\
\;\;\;\;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 -8.273540851308956e+145)
(- (/ c b) (/ b a))
(if (<= b -3.561644019231982e-259)
(* (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (/ 0.5 a))
(if (<= b 5.421378530068417e+117)
(* 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 <= -8.273540851308956e+145) {
tmp = (c / b) - (b / a);
} else if (b <= -3.561644019231982e-259) {
tmp = (sqrt((b * b) - (c * (a * 4.0))) - b) * (0.5 / a);
} else if (b <= 5.421378530068417e+117) {
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 < -8.27354085130895625e145Initial program 60.6
Simplified60.6
Taylor expanded around -inf 2.3
if -8.27354085130895625e145 < b < -3.56164401923198198e-259Initial program 8.5
Simplified8.5
rmApplied div-inv_binary648.6
Simplified8.6
if -3.56164401923198198e-259 < b < 5.42137853006841731e117Initial program 31.6
Simplified31.6
rmApplied flip--_binary6431.7
Simplified15.4
Simplified15.4
rmApplied *-un-lft-identity_binary6415.4
Applied times-frac_binary6415.5
Applied times-frac_binary6414.6
Simplified8.8
Simplified8.8
if 5.42137853006841731e117 < b Initial program 60.8
Simplified60.8
Taylor expanded around inf 2.8
Simplified2.8
Final simplification6.6
herbie shell --seed 2020233
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))