\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.1144981103869975 \cdot 10^{+131}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \le 4.5810084990875205 \cdot 10^{-68}:\\
\;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2}}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r3011519 = b;
double r3011520 = -r3011519;
double r3011521 = r3011519 * r3011519;
double r3011522 = 4.0;
double r3011523 = a;
double r3011524 = r3011522 * r3011523;
double r3011525 = c;
double r3011526 = r3011524 * r3011525;
double r3011527 = r3011521 - r3011526;
double r3011528 = sqrt(r3011527);
double r3011529 = r3011520 + r3011528;
double r3011530 = 2.0;
double r3011531 = r3011530 * r3011523;
double r3011532 = r3011529 / r3011531;
return r3011532;
}
double f(double a, double b, double c) {
double r3011533 = b;
double r3011534 = -2.1144981103869975e+131;
bool r3011535 = r3011533 <= r3011534;
double r3011536 = c;
double r3011537 = r3011536 / r3011533;
double r3011538 = a;
double r3011539 = r3011533 / r3011538;
double r3011540 = r3011537 - r3011539;
double r3011541 = 4.5810084990875205e-68;
bool r3011542 = r3011533 <= r3011541;
double r3011543 = 1.0;
double r3011544 = r3011533 * r3011533;
double r3011545 = r3011536 * r3011538;
double r3011546 = 4.0;
double r3011547 = r3011545 * r3011546;
double r3011548 = r3011544 - r3011547;
double r3011549 = sqrt(r3011548);
double r3011550 = r3011549 - r3011533;
double r3011551 = 2.0;
double r3011552 = r3011550 / r3011551;
double r3011553 = r3011538 / r3011552;
double r3011554 = r3011543 / r3011553;
double r3011555 = -r3011537;
double r3011556 = r3011542 ? r3011554 : r3011555;
double r3011557 = r3011535 ? r3011540 : r3011556;
return r3011557;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.6 |
|---|---|
| Target | 21.0 |
| Herbie | 10.4 |
if b < -2.1144981103869975e+131Initial program 53.8
Taylor expanded around -inf 2.6
if -2.1144981103869975e+131 < b < 4.5810084990875205e-68Initial program 13.3
rmApplied div-inv13.5
Simplified13.5
rmApplied associate-*r/13.3
Simplified13.3
Taylor expanded around 0 13.3
Simplified13.3
rmApplied clear-num13.4
if 4.5810084990875205e-68 < b Initial program 52.0
rmApplied div-inv52.0
Simplified52.0
rmApplied associate-*r/52.0
Simplified52.0
Taylor expanded around 0 51.9
Simplified51.9
Taylor expanded around inf 9.3
Simplified9.3
Final simplification10.4
herbie shell --seed 2019163
(FPCore (a b c)
:name "The quadratic formula (r1)"
:herbie-target
(if (< b 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)))