\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 1.9238883452280037 \cdot 10^{-130}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} + \left(-b\right)}{2 \cdot a}\\
\mathbf{elif}\;b \le 4.01993084419163312 \cdot 10^{109}:\\
\;\;\;\;\frac{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\\
\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 <= 1.9238883452280037e-130)) {
temp_1 = ((sqrt(((b * b) - (4.0 * (a * c)))) + -b) / (2.0 * a));
} else {
double temp_2;
if ((b <= 4.019930844191633e+109)) {
temp_2 = (((0.0 + (4.0 * (a * c))) / (-b - sqrt(((b * b) - (4.0 * (a * c)))))) / (2.0 * a));
} 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 | 9.2 |
if b < -2.3044033969831823e+153Initial program 63.5
Taylor expanded around -inf 2.0
Simplified2.0
if -2.3044033969831823e+153 < b < 1.9238883452280037e-130Initial program 11.3
rmApplied +-commutative11.3
if 1.9238883452280037e-130 < b < 4.019930844191633e+109Initial program 40.3
rmApplied flip-+40.3
Simplified15.5
if 4.019930844191633e+109 < b Initial program 59.9
Taylor expanded around inf 2.4
Final simplification9.2
herbie shell --seed 2020060 +o rules:numerics
(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)))