\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 -2.6472597296593428 \cdot 10^{81}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 1.0105231099196228 \cdot 10^{-270}:\\
\;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\
\mathbf{elif}\;b \le 14169621.248013001:\\
\;\;\;\;\frac{\frac{\frac{4 \cdot \left(a \cdot c\right)}{2}}{a}}{\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 <= -2.647259729659343e+81)) {
temp = (1.0 * ((c / b) - (b / a)));
} else {
double temp_1;
if ((b <= 1.0105231099196228e-270)) {
temp_1 = (1.0 / ((2.0 * a) / (-b + sqrt(((b * b) - ((4.0 * a) * c))))));
} else {
double temp_2;
if ((b <= 14169621.248013001)) {
temp_2 = ((((4.0 * (a * c)) / 2.0) / a) / (-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 | 21.2 |
| Herbie | 9.3 |
if b < -2.647259729659343e+81Initial program 42.0
Taylor expanded around -inf 4.7
Simplified4.7
if -2.647259729659343e+81 < b < 1.0105231099196228e-270Initial program 10.1
rmApplied clear-num10.2
if 1.0105231099196228e-270 < b < 14169621.248013001Initial program 27.3
rmApplied flip-+27.3
Simplified17.4
rmApplied div-inv17.5
Applied associate-/l*23.3
Simplified23.2
rmApplied associate-/r*17.4
Simplified17.4
if 14169621.248013001 < b Initial program 55.9
Taylor expanded around inf 6.0
Final simplification9.3
herbie shell --seed 2020065 +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)))