\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 -9.5975400610846271 \cdot 10^{115}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le -1.06237398994986779 \cdot 10^{-305}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\mathbf{elif}\;b \le 3.29571176074688 \cdot 10^{130}:\\
\;\;\;\;\frac{1}{\frac{0.5}{c} \cdot \left(-b\right) + \frac{0.5}{c} \cdot \left(-\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\\
\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 <= -9.597540061084627e+115)) {
VAR = (1.0 * ((c / b) - (b / a)));
} else {
double VAR_1;
if ((b <= -1.0623739899498678e-305)) {
VAR_1 = ((-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a));
} else {
double VAR_2;
if ((b <= 3.29571176074688e+130)) {
VAR_2 = (1.0 / (((0.5 / c) * -b) + ((0.5 / c) * -sqrt(((b * b) - ((4.0 * a) * c))))));
} 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 | 33.7 |
|---|---|
| Target | 20.9 |
| Herbie | 6.9 |
if b < -9.597540061084627e+115Initial program 48.7
Taylor expanded around -inf 3.3
Simplified3.3
if -9.597540061084627e+115 < b < -1.0623739899498678e-305Initial program 8.7
if -1.0623739899498678e-305 < b < 3.29571176074688e+130Initial program 34.4
rmApplied flip-+34.4
Simplified16.9
rmApplied clear-num17.1
Simplified16.0
Taylor expanded around 0 9.6
rmApplied sub-neg9.6
Applied distribute-lft-in9.6
if 3.29571176074688e+130 < b Initial program 61.2
Taylor expanded around inf 2.1
Final simplification6.9
herbie shell --seed 2020100
(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)))