\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 -5.148407540792454 \cdot 10^{+110}:\\
\;\;\;\;\frac{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 2}{2}\\
\mathbf{elif}\;b \le 2.326372645943808 \cdot 10^{-74}:\\
\;\;\;\;\frac{\frac{1}{a} \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \frac{b}{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c}{b} \cdot -2}{2}\\
\end{array}double f(double a, double b, double c) {
double r1763445 = b;
double r1763446 = -r1763445;
double r1763447 = r1763445 * r1763445;
double r1763448 = 4.0;
double r1763449 = a;
double r1763450 = r1763448 * r1763449;
double r1763451 = c;
double r1763452 = r1763450 * r1763451;
double r1763453 = r1763447 - r1763452;
double r1763454 = sqrt(r1763453);
double r1763455 = r1763446 + r1763454;
double r1763456 = 2.0;
double r1763457 = r1763456 * r1763449;
double r1763458 = r1763455 / r1763457;
return r1763458;
}
double f(double a, double b, double c) {
double r1763459 = b;
double r1763460 = -5.148407540792454e+110;
bool r1763461 = r1763459 <= r1763460;
double r1763462 = c;
double r1763463 = r1763462 / r1763459;
double r1763464 = a;
double r1763465 = r1763459 / r1763464;
double r1763466 = r1763463 - r1763465;
double r1763467 = 2.0;
double r1763468 = r1763466 * r1763467;
double r1763469 = r1763468 / r1763467;
double r1763470 = 2.326372645943808e-74;
bool r1763471 = r1763459 <= r1763470;
double r1763472 = 1.0;
double r1763473 = r1763472 / r1763464;
double r1763474 = r1763459 * r1763459;
double r1763475 = 4.0;
double r1763476 = r1763462 * r1763464;
double r1763477 = r1763475 * r1763476;
double r1763478 = r1763474 - r1763477;
double r1763479 = sqrt(r1763478);
double r1763480 = r1763473 * r1763479;
double r1763481 = r1763480 - r1763465;
double r1763482 = r1763481 / r1763467;
double r1763483 = -2.0;
double r1763484 = r1763463 * r1763483;
double r1763485 = r1763484 / r1763467;
double r1763486 = r1763471 ? r1763482 : r1763485;
double r1763487 = r1763461 ? r1763469 : r1763486;
return r1763487;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.4 |
|---|---|
| Target | 20.3 |
| Herbie | 9.9 |
if b < -5.148407540792454e+110Initial program 46.9
Simplified46.9
rmApplied div-sub46.9
rmApplied *-un-lft-identity46.9
Applied add-sqr-sqrt46.9
Applied sqrt-prod47.0
Applied times-frac47.0
Taylor expanded around -inf 3.6
Simplified3.6
if -5.148407540792454e+110 < b < 2.326372645943808e-74Initial program 12.8
Simplified12.7
rmApplied div-sub12.7
rmApplied div-inv12.8
if 2.326372645943808e-74 < b Initial program 52.5
Simplified52.5
rmApplied div-sub53.2
rmApplied *-un-lft-identity53.2
Applied add-sqr-sqrt53.2
Applied sqrt-prod54.6
Applied times-frac54.8
Taylor expanded around inf 8.8
Final simplification9.9
herbie shell --seed 2019151
(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)))