\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 -110883243782.23416:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq -4.61052798615193 \cdot 10^{-299}:\\
\;\;\;\;\left(\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{elif}\;b \leq 1.0321611733451932 \cdot 10^{+121}:\\
\;\;\;\;\left(c \cdot -4\right) \cdot \frac{0.5}{b + \sqrt{b \cdot b + a \cdot \left(c \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 -110883243782.23416)
(- (/ c b) (/ b a))
(if (<= b -4.61052798615193e-299)
(* (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (/ 0.5 a))
(if (<= b 1.0321611733451932e+121)
(* (* c -4.0) (/ 0.5 (+ b (sqrt (+ (* b b) (* a (* c -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 <= -110883243782.23416) {
tmp = (c / b) - (b / a);
} else if (b <= -4.61052798615193e-299) {
tmp = (sqrt((b * b) - (c * (a * 4.0))) - b) * (0.5 / a);
} else if (b <= 1.0321611733451932e+121) {
tmp = (c * -4.0) * (0.5 / (b + sqrt((b * b) + (a * (c * -4.0)))));
} else {
tmp = -(c / b);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -110883243782.23416Initial program 32.1
Simplified32.1
Taylor expanded around -inf 7.2
if -110883243782.23416 < b < -4.61052798615192997e-299Initial program 10.6
Simplified10.6
rmApplied div-inv_binary6410.7
Simplified10.7
if -4.61052798615192997e-299 < b < 1.03216117334519319e121Initial program 32.5
Simplified32.5
rmApplied flip--_binary6432.5
Simplified16.2
Simplified16.2
rmApplied div-inv_binary6416.2
Applied times-frac_binary6415.2
Simplified8.8
Simplified8.8
rmApplied sub-neg_binary648.8
Simplified8.8
if 1.03216117334519319e121 < b Initial program 60.7
Simplified60.7
Taylor expanded around inf 1.9
Simplified1.9
Final simplification7.3
herbie shell --seed 2020220
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))