\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 -6.87536045284350627 \cdot 10^{92}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le -8.27767730821019174 \cdot 10^{-175}:\\
\;\;\;\;\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 3.8636444360254825 \cdot 10^{121}:\\
\;\;\;\;\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 <= -6.875360452843506e+92)) {
temp = (1.0 * ((c / b) - (b / a)));
} else {
double temp_1;
if ((b <= -8.277677308210192e-175)) {
temp_1 = ((-b + sqrt(((b * b) - ((4.0 * a) * c)))) * (1.0 / (2.0 * a)));
} else {
double temp_2;
if ((b <= 3.8636444360254825e+121)) {
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 | 33.8 |
|---|---|
| Target | 20.5 |
| Herbie | 6.4 |
if b < -6.875360452843506e+92Initial program 45.0
Taylor expanded around -inf 3.5
Simplified3.5
if -6.875360452843506e+92 < b < -8.277677308210192e-175Initial program 7.0
rmApplied div-inv7.1
if -8.277677308210192e-175 < b < 3.8636444360254825e+121Initial program 29.7
rmApplied flip-+29.8
Simplified16.1
rmApplied *-un-lft-identity16.1
Applied *-un-lft-identity16.1
Applied times-frac16.1
Applied associate-/l*16.2
Simplified15.2
Taylor expanded around 0 10.0
rmApplied associate-/r*9.6
Simplified9.5
if 3.8636444360254825e+121 < b Initial program 60.9
Taylor expanded around inf 1.5
Final simplification6.4
herbie shell --seed 2020066 +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)))