\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -2.3044033969831823 \cdot 10^{153}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 3.2001964328628576 \cdot 10^{-306}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\
\mathbf{elif}\;b \le 3.3690530579691639 \cdot 10^{141}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \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 temp;
if ((b <= -2.3044033969831823e+153)) {
temp = (1.0 * ((c / b) - (b / a)));
} else {
double temp_1;
if ((b <= 3.2001964328628576e-306)) {
temp_1 = ((-b + sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a));
} else {
double temp_2;
if ((b <= 3.369053057969164e+141)) {
temp_2 = ((2.0 * 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.1 |
|---|---|
| Target | 20.6 |
| Herbie | 6.5 |
if b < -2.3044033969831823e+153Initial program 63.5
Taylor expanded around -inf 2.0
Simplified2.0
if -2.3044033969831823e+153 < b < 3.2001964328628576e-306Initial program 8.8
if 3.2001964328628576e-306 < b < 3.369053057969164e+141Initial program 34.4
rmApplied clear-num34.4
rmApplied flip-+34.4
Applied associate-/r/34.4
Applied associate-/r*34.5
Simplified14.9
Taylor expanded around 0 8.3
if 3.369053057969164e+141 < b Initial program 62.5
Taylor expanded around inf 1.5
Final simplification6.5
herbie shell --seed 2020060
(FPCore (a b c)
:name "quadp (p42, positive)"
: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)))