\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -4.73423627781717686 \cdot 10^{122}:\\
\;\;\;\;1 \cdot \left(1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\right)\\
\mathbf{elif}\;b \le 4.300666801536262 \cdot 10^{-42}:\\
\;\;\;\;1 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}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 temp;
if ((b <= -4.734236277817177e+122)) {
temp = (1.0 * (1.0 * ((c / b) - (b / a))));
} else {
double temp_1;
if ((b <= 4.300666801536262e-42)) {
temp_1 = (1.0 * ((-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)));
} else {
temp_1 = (-1.0 * (c / b));
}
temp = temp_1;
}
return temp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.2 |
|---|---|
| Target | 20.8 |
| Herbie | 9.6 |
if b < -4.734236277817177e+122Initial program 52.5
rmApplied div-inv52.6
rmApplied *-un-lft-identity52.6
Applied associate-*l*52.6
Simplified52.5
Taylor expanded around -inf 3.4
Simplified3.4
if -4.734236277817177e+122 < b < 4.300666801536262e-42Initial program 13.6
rmApplied div-inv13.7
rmApplied *-un-lft-identity13.7
Applied associate-*l*13.7
Simplified13.6
if 4.300666801536262e-42 < b Initial program 55.0
Taylor expanded around inf 6.5
Final simplification9.6
herbie shell --seed 2020053
(FPCore (a b c)
:name "The quadratic formula (r1)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))