\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 -8.00336887744975224 \cdot 10^{118}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le -3.72191682831812008 \cdot 10^{-246}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\mathbf{elif}\;b \le 5.54044500863652378 \cdot 10^{145}:\\
\;\;\;\;\frac{\frac{1}{0.5} \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\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 <= -8.003368877449752e+118)) {
temp = (1.0 * ((c / b) - (b / a)));
} else {
double temp_1;
if ((b <= -3.72191682831812e-246)) {
temp_1 = ((-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a));
} else {
double temp_2;
if ((b <= 5.540445008636524e+145)) {
temp_2 = (((1.0 / 0.5) * c) / (-b - sqrt(((b * b) - ((4.0 * a) * c)))));
} else {
temp_2 = (-1.0 * (c / b));
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.3 |
|---|---|
| Target | 21.1 |
| Herbie | 6.2 |
if b < -8.003368877449752e+118Initial program 52.1
Taylor expanded around -inf 2.9
Simplified2.9
if -8.003368877449752e+118 < b < -3.72191682831812e-246Initial program 7.5
if -3.72191682831812e-246 < b < 5.540445008636524e+145Initial program 32.4
rmApplied flip-+32.5
Simplified15.8
rmApplied *-un-lft-identity15.8
Applied *-un-lft-identity15.8
Applied times-frac15.8
Applied associate-/l*16.0
Simplified14.7
Taylor expanded around 0 9.1
rmApplied associate-/r*8.6
Simplified8.6
if 5.540445008636524e+145 < b Initial program 63.2
Taylor expanded around inf 1.8
Final simplification6.2
herbie shell --seed 2020049 +o rules:numerics
(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)))