\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 -6.90131991727783 \cdot 10^{-39}:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{elif}\;b \le 4.012768074517757 \cdot 10^{+87}:\\
\;\;\;\;\left(\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}\right) \cdot \frac{\frac{1}{2}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}double f(double a, double b, double c) {
double r2985514 = b;
double r2985515 = -r2985514;
double r2985516 = r2985514 * r2985514;
double r2985517 = 4.0;
double r2985518 = a;
double r2985519 = c;
double r2985520 = r2985518 * r2985519;
double r2985521 = r2985517 * r2985520;
double r2985522 = r2985516 - r2985521;
double r2985523 = sqrt(r2985522);
double r2985524 = r2985515 - r2985523;
double r2985525 = 2.0;
double r2985526 = r2985525 * r2985518;
double r2985527 = r2985524 / r2985526;
return r2985527;
}
double f(double a, double b, double c) {
double r2985528 = b;
double r2985529 = -6.90131991727783e-39;
bool r2985530 = r2985528 <= r2985529;
double r2985531 = c;
double r2985532 = r2985531 / r2985528;
double r2985533 = -r2985532;
double r2985534 = 4.012768074517757e+87;
bool r2985535 = r2985528 <= r2985534;
double r2985536 = -r2985528;
double r2985537 = r2985528 * r2985528;
double r2985538 = a;
double r2985539 = r2985531 * r2985538;
double r2985540 = 4.0;
double r2985541 = r2985539 * r2985540;
double r2985542 = r2985537 - r2985541;
double r2985543 = sqrt(r2985542);
double r2985544 = r2985536 - r2985543;
double r2985545 = 0.5;
double r2985546 = r2985545 / r2985538;
double r2985547 = r2985544 * r2985546;
double r2985548 = r2985536 / r2985538;
double r2985549 = r2985535 ? r2985547 : r2985548;
double r2985550 = r2985530 ? r2985533 : r2985549;
return r2985550;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 32.6 |
|---|---|
| Target | 20.0 |
| Herbie | 9.7 |
if b < -6.90131991727783e-39Initial program 53.0
rmApplied div-inv53.1
Simplified53.1
Taylor expanded around -inf 7.9
Simplified7.9
if -6.90131991727783e-39 < b < 4.012768074517757e+87Initial program 13.2
rmApplied div-inv13.3
Simplified13.3
if 4.012768074517757e+87 < b Initial program 41.3
rmApplied *-un-lft-identity41.3
Applied *-un-lft-identity41.3
Applied distribute-rgt-neg-in41.3
Applied distribute-lft-out--41.3
Applied associate-/l*41.3
Simplified41.3
Taylor expanded around 0 3.3
Simplified3.3
Final simplification9.7
herbie shell --seed 2019132 +o rules:numerics
(FPCore (a b c)
:name "The quadratic formula (r2)"
:herbie-target
(if (< b 0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))