\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 -4.639043916588305 \cdot 10^{+143}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \le 5.046853365273247 \cdot 10^{-144}:\\
\;\;\;\;\frac{\frac{\frac{1}{2}}{a}}{\frac{1}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r3928657 = b;
double r3928658 = -r3928657;
double r3928659 = r3928657 * r3928657;
double r3928660 = 4.0;
double r3928661 = a;
double r3928662 = r3928660 * r3928661;
double r3928663 = c;
double r3928664 = r3928662 * r3928663;
double r3928665 = r3928659 - r3928664;
double r3928666 = sqrt(r3928665);
double r3928667 = r3928658 + r3928666;
double r3928668 = 2.0;
double r3928669 = r3928668 * r3928661;
double r3928670 = r3928667 / r3928669;
return r3928670;
}
double f(double a, double b, double c) {
double r3928671 = b;
double r3928672 = -4.639043916588305e+143;
bool r3928673 = r3928671 <= r3928672;
double r3928674 = c;
double r3928675 = r3928674 / r3928671;
double r3928676 = a;
double r3928677 = r3928671 / r3928676;
double r3928678 = r3928675 - r3928677;
double r3928679 = 5.046853365273247e-144;
bool r3928680 = r3928671 <= r3928679;
double r3928681 = 0.5;
double r3928682 = r3928681 / r3928676;
double r3928683 = 1.0;
double r3928684 = r3928671 * r3928671;
double r3928685 = 4.0;
double r3928686 = r3928674 * r3928676;
double r3928687 = r3928685 * r3928686;
double r3928688 = r3928684 - r3928687;
double r3928689 = sqrt(r3928688);
double r3928690 = r3928689 - r3928671;
double r3928691 = r3928683 / r3928690;
double r3928692 = r3928682 / r3928691;
double r3928693 = -r3928675;
double r3928694 = r3928680 ? r3928692 : r3928693;
double r3928695 = r3928673 ? r3928678 : r3928694;
return r3928695;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.4 |
|---|---|
| Target | 19.8 |
| Herbie | 10.0 |
if b < -4.639043916588305e+143Initial program 57.1
Simplified57.1
rmApplied *-un-lft-identity57.1
Applied associate-/l*57.1
rmApplied *-un-lft-identity57.1
Applied associate-/l*57.1
Simplified57.1
Taylor expanded around -inf 2.2
if -4.639043916588305e+143 < b < 5.046853365273247e-144Initial program 10.3
Simplified10.3
rmApplied *-un-lft-identity10.3
Applied associate-/l*10.4
rmApplied div-inv10.5
Applied associate-/r*10.5
Simplified10.5
if 5.046853365273247e-144 < b Initial program 49.8
Simplified49.8
Taylor expanded around inf 11.6
Simplified11.6
Final simplification10.0
herbie shell --seed 2019132
(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)))