\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 -3.575938583654324 \cdot 10^{+94}:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{a}{b} \cdot c - b\right)}\\
\mathbf{elif}\;b \le 4.0232110844075136 \cdot 10^{-262}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\
\mathbf{elif}\;b \le 2.6656023684116586 \cdot 10^{+55}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}double f(double a, double b, double c) {
double r4610425 = b;
double r4610426 = -r4610425;
double r4610427 = r4610425 * r4610425;
double r4610428 = 4.0;
double r4610429 = a;
double r4610430 = c;
double r4610431 = r4610429 * r4610430;
double r4610432 = r4610428 * r4610431;
double r4610433 = r4610427 - r4610432;
double r4610434 = sqrt(r4610433);
double r4610435 = r4610426 - r4610434;
double r4610436 = 2.0;
double r4610437 = r4610436 * r4610429;
double r4610438 = r4610435 / r4610437;
return r4610438;
}
double f(double a, double b, double c) {
double r4610439 = b;
double r4610440 = -3.575938583654324e+94;
bool r4610441 = r4610439 <= r4610440;
double r4610442 = 2.0;
double r4610443 = c;
double r4610444 = r4610442 * r4610443;
double r4610445 = a;
double r4610446 = r4610445 / r4610439;
double r4610447 = r4610446 * r4610443;
double r4610448 = r4610447 - r4610439;
double r4610449 = r4610442 * r4610448;
double r4610450 = r4610444 / r4610449;
double r4610451 = 4.0232110844075136e-262;
bool r4610452 = r4610439 <= r4610451;
double r4610453 = -r4610439;
double r4610454 = r4610439 * r4610439;
double r4610455 = 4.0;
double r4610456 = r4610445 * r4610443;
double r4610457 = r4610455 * r4610456;
double r4610458 = r4610454 - r4610457;
double r4610459 = sqrt(r4610458);
double r4610460 = r4610453 + r4610459;
double r4610461 = r4610444 / r4610460;
double r4610462 = 2.6656023684116586e+55;
bool r4610463 = r4610439 <= r4610462;
double r4610464 = 0.5;
double r4610465 = r4610453 - r4610459;
double r4610466 = r4610465 / r4610445;
double r4610467 = r4610464 * r4610466;
double r4610468 = r4610453 / r4610445;
double r4610469 = r4610463 ? r4610467 : r4610468;
double r4610470 = r4610452 ? r4610461 : r4610469;
double r4610471 = r4610441 ? r4610450 : r4610470;
return r4610471;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.0 |
|---|---|
| Target | 21.3 |
| Herbie | 7.2 |
if b < -3.575938583654324e+94Initial program 58.9
rmApplied *-un-lft-identity58.9
Applied *-un-lft-identity58.9
Applied distribute-rgt-neg-in58.9
Applied distribute-lft-out--58.9
Applied associate-/l*58.9
rmApplied flip--59.0
Applied associate-/r/59.0
Applied associate-/r*59.0
Simplified30.3
Taylor expanded around inf 29.6
Taylor expanded around -inf 6.4
Simplified2.5
if -3.575938583654324e+94 < b < 4.0232110844075136e-262Initial program 30.8
rmApplied *-un-lft-identity30.8
Applied *-un-lft-identity30.8
Applied distribute-rgt-neg-in30.8
Applied distribute-lft-out--30.8
Applied associate-/l*30.8
rmApplied flip--31.0
Applied associate-/r/31.0
Applied associate-/r*31.0
Simplified16.1
Taylor expanded around inf 9.8
if 4.0232110844075136e-262 < b < 2.6656023684116586e+55Initial program 9.0
rmApplied *-un-lft-identity9.0
Applied *-un-lft-identity9.0
Applied distribute-rgt-neg-in9.0
Applied distribute-lft-out--9.0
Applied associate-/l*9.2
rmApplied *-un-lft-identity9.2
Applied times-frac9.2
Applied add-sqr-sqrt9.2
Applied times-frac9.2
Simplified9.2
Simplified9.0
if 2.6656023684116586e+55 < b Initial program 37.1
rmApplied *-un-lft-identity37.1
Applied *-un-lft-identity37.1
Applied distribute-rgt-neg-in37.1
Applied distribute-lft-out--37.1
Applied associate-/l*37.2
rmApplied flip--60.2
Applied associate-/r/60.2
Applied associate-/r*60.2
Simplified60.3
Taylor expanded around inf 60.3
Taylor expanded around 0 6.5
Simplified6.5
Final simplification7.2
herbie shell --seed 2019141
(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)))