\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.88909646695332609 \cdot 10^{-61}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 1.61619933633238581 \cdot 10^{68}:\\
\;\;\;\;\frac{1}{\left(-b\right) \cdot \frac{\frac{2}{4}}{c} + \left(-\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{\frac{2}{4}}{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 <= -1.889096466953326e-61)) {
temp = (1.0 * ((c / b) - (b / a)));
} else {
double temp_1;
if ((b <= 1.6161993363323858e+68)) {
temp_1 = (1.0 / ((-b * ((2.0 / 4.0) / c)) + (-sqrt(((b * b) - ((4.0 * a) * c))) * ((2.0 / 4.0) / c))));
} 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.3 |
|---|---|
| Target | 20.8 |
| Herbie | 9.8 |
if b < -1.889096466953326e-61Initial program 28.1
Taylor expanded around -inf 10.9
Simplified10.9
if -1.889096466953326e-61 < b < 1.6161993363323858e+68Initial program 23.5
rmApplied flip-+27.0
Simplified18.0
rmApplied *-un-lft-identity18.0
Applied *-un-lft-identity18.0
Applied times-frac18.0
Applied associate-/l*18.1
Simplified17.9
rmApplied times-frac17.9
Simplified13.3
rmApplied sub-neg13.3
Applied distribute-lft-in13.3
Simplified13.3
Simplified13.3
if 1.6161993363323858e+68 < b Initial program 58.0
Taylor expanded around inf 3.0
Final simplification9.8
herbie shell --seed 2020058
(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)))