\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.9524641876928 \cdot 10^{+117}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.737946272785067 \cdot 10^{-273}:\\
\;\;\;\;\left(\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{elif}\;b \leq 1.2752640965720171 \cdot 10^{+42}:\\
\;\;\;\;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 -3.9524641876928e+117)
(- (/ c b) (/ b a))
(if (<= b 5.737946272785067e-273)
(* (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (/ 0.5 a))
(if (<= b 1.2752640965720171e+42)
(* 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 <= -3.9524641876928e+117) {
tmp = (c / b) - (b / a);
} else if (b <= 5.737946272785067e-273) {
tmp = (sqrt((b * b) - (c * (a * 4.0))) - b) * (0.5 / a);
} else if (b <= 1.2752640965720171e+42) {
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 < -3.9524641876928001e117Initial program 51.5
Simplified51.5
Taylor expanded around -inf 3.0
if -3.9524641876928001e117 < b < 5.73794627278506673e-273Initial program 9.0
Simplified9.0
rmApplied div-inv_binary649.1
Simplified9.1
if 5.73794627278506673e-273 < b < 1.2752640965720171e42Initial program 29.2
Simplified29.2
rmApplied flip--_binary6429.2
Simplified16.9
Simplified16.9
rmApplied *-un-lft-identity_binary6416.9
Applied times-frac_binary6417.0
Applied times-frac_binary6416.8
Simplified9.4
Simplified9.4
if 1.2752640965720171e42 < b Initial program 56.9
Simplified56.9
Taylor expanded around inf 4.3
Simplified4.3
Final simplification6.9
herbie shell --seed 2020260
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))