\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}}{2.0 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -3.0775171197265305 \cdot 10^{+143}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{2.0}}{a}\\
\mathbf{elif}\;b \le -6.459611810046018 \cdot 10^{-256}:\\
\;\;\;\;\left(\sqrt{b \cdot b - 4.0 \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{\frac{1}{2.0}}{a}\\
\mathbf{elif}\;b \le 5.413497103300552 \cdot 10^{+144}:\\
\;\;\;\;\frac{c \cdot -2.0}{\sqrt{b \cdot b - 4.0 \cdot \left(a \cdot c\right)} + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -1.0\\
\end{array}double f(double a, double b, double c) {
double r5698708 = b;
double r5698709 = -r5698708;
double r5698710 = r5698708 * r5698708;
double r5698711 = 4.0;
double r5698712 = a;
double r5698713 = r5698711 * r5698712;
double r5698714 = c;
double r5698715 = r5698713 * r5698714;
double r5698716 = r5698710 - r5698715;
double r5698717 = sqrt(r5698716);
double r5698718 = r5698709 + r5698717;
double r5698719 = 2.0;
double r5698720 = r5698719 * r5698712;
double r5698721 = r5698718 / r5698720;
return r5698721;
}
double f(double a, double b, double c) {
double r5698722 = b;
double r5698723 = -3.0775171197265305e+143;
bool r5698724 = r5698722 <= r5698723;
double r5698725 = -2.0;
double r5698726 = r5698725 * r5698722;
double r5698727 = 2.0;
double r5698728 = r5698726 / r5698727;
double r5698729 = a;
double r5698730 = r5698728 / r5698729;
double r5698731 = -6.459611810046018e-256;
bool r5698732 = r5698722 <= r5698731;
double r5698733 = r5698722 * r5698722;
double r5698734 = 4.0;
double r5698735 = c;
double r5698736 = r5698729 * r5698735;
double r5698737 = r5698734 * r5698736;
double r5698738 = r5698733 - r5698737;
double r5698739 = sqrt(r5698738);
double r5698740 = r5698739 - r5698722;
double r5698741 = 1.0;
double r5698742 = r5698741 / r5698727;
double r5698743 = r5698742 / r5698729;
double r5698744 = r5698740 * r5698743;
double r5698745 = 5.413497103300552e+144;
bool r5698746 = r5698722 <= r5698745;
double r5698747 = -2.0;
double r5698748 = r5698735 * r5698747;
double r5698749 = r5698739 + r5698722;
double r5698750 = r5698748 / r5698749;
double r5698751 = r5698735 / r5698722;
double r5698752 = -1.0;
double r5698753 = r5698751 * r5698752;
double r5698754 = r5698746 ? r5698750 : r5698753;
double r5698755 = r5698732 ? r5698744 : r5698754;
double r5698756 = r5698724 ? r5698730 : r5698755;
return r5698756;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.5 |
|---|---|
| Target | 20.9 |
| Herbie | 6.3 |
if b < -3.0775171197265305e+143Initial program 59.8
Simplified59.8
rmApplied add-sqr-sqrt59.8
Applied sqrt-prod59.8
Applied fma-neg59.8
Taylor expanded around -inf 3.0
Simplified3.0
if -3.0775171197265305e+143 < b < -6.459611810046018e-256Initial program 8.0
Simplified7.9
rmApplied *-un-lft-identity7.9
Applied div-inv7.9
Applied times-frac8.1
Simplified8.1
if -6.459611810046018e-256 < b < 5.413497103300552e+144Initial program 33.1
Simplified33.1
rmApplied *-un-lft-identity33.1
Applied div-inv33.1
Applied times-frac33.1
Simplified33.1
rmApplied flip--33.2
Applied associate-*l/33.2
Simplified13.6
Taylor expanded around 0 8.3
if 5.413497103300552e+144 < b Initial program 62.8
Simplified62.8
Taylor expanded around inf 1.4
Final simplification6.3
herbie shell --seed 2019165 +o rules:numerics
(FPCore (a b c)
:name "The quadratic formula (r1)"
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))