\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 -1.44435856646914502 \cdot 10^{87}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le -8.94672295773202446 \cdot 10^{-284}:\\
\;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\
\mathbf{elif}\;b \le 1.74631986093255956 \cdot 10^{58}:\\
\;\;\;\;\frac{1 \cdot \frac{4 \cdot a}{\frac{-\left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}{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 VAR;
if ((b <= -1.444358566469145e+87)) {
VAR = (1.0 * ((c / b) - (b / a)));
} else {
double VAR_1;
if ((b <= -8.946722957732024e-284)) {
VAR_1 = ((-b + sqrt(((b * b) - ((4.0 * a) * c)))) * (1.0 / (2.0 * a)));
} else {
double VAR_2;
if ((b <= 1.7463198609325596e+58)) {
VAR_2 = ((1.0 * ((4.0 * a) / (-(b + sqrt(((b * b) - ((4.0 * a) * c)))) / c))) / (2.0 * a));
} else {
VAR_2 = (-1.0 * (c / b));
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.3 |
|---|---|
| Target | 21.2 |
| Herbie | 8.3 |
if b < -1.444358566469145e+87Initial program 43.8
Taylor expanded around -inf 3.4
Simplified3.4
if -1.444358566469145e+87 < b < -8.946722957732024e-284Initial program 9.6
rmApplied div-inv9.8
if -8.946722957732024e-284 < b < 1.7463198609325596e+58Initial program 29.5
rmApplied add-sqr-sqrt29.5
Applied sqrt-prod30.1
rmApplied flip-+30.2
Simplified17.5
Simplified17.3
rmApplied *-un-lft-identity17.3
Applied *-un-lft-identity17.3
Applied times-frac17.3
Simplified17.3
Simplified14.5
if 1.7463198609325596e+58 < b Initial program 57.5
Taylor expanded around inf 3.7
Final simplification8.3
herbie shell --seed 2020075
(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)))