\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.82289647433212 \cdot 10^{+153}:\\
\;\;\;\;\frac{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 2}{2}\\
\mathbf{elif}\;b \le 3.289226058156428 \cdot 10^{-70}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c}{b} \cdot -2}{2}\\
\end{array}double f(double a, double b, double c) {
double r3966005 = b;
double r3966006 = -r3966005;
double r3966007 = r3966005 * r3966005;
double r3966008 = 4.0;
double r3966009 = a;
double r3966010 = r3966008 * r3966009;
double r3966011 = c;
double r3966012 = r3966010 * r3966011;
double r3966013 = r3966007 - r3966012;
double r3966014 = sqrt(r3966013);
double r3966015 = r3966006 + r3966014;
double r3966016 = 2.0;
double r3966017 = r3966016 * r3966009;
double r3966018 = r3966015 / r3966017;
return r3966018;
}
double f(double a, double b, double c) {
double r3966019 = b;
double r3966020 = -4.82289647433212e+153;
bool r3966021 = r3966019 <= r3966020;
double r3966022 = c;
double r3966023 = r3966022 / r3966019;
double r3966024 = a;
double r3966025 = r3966019 / r3966024;
double r3966026 = r3966023 - r3966025;
double r3966027 = 2.0;
double r3966028 = r3966026 * r3966027;
double r3966029 = r3966028 / r3966027;
double r3966030 = 3.289226058156428e-70;
bool r3966031 = r3966019 <= r3966030;
double r3966032 = -4.0;
double r3966033 = r3966032 * r3966024;
double r3966034 = r3966033 * r3966022;
double r3966035 = fma(r3966019, r3966019, r3966034);
double r3966036 = sqrt(r3966035);
double r3966037 = r3966036 - r3966019;
double r3966038 = r3966037 / r3966024;
double r3966039 = r3966038 / r3966027;
double r3966040 = -2.0;
double r3966041 = r3966023 * r3966040;
double r3966042 = r3966041 / r3966027;
double r3966043 = r3966031 ? r3966039 : r3966042;
double r3966044 = r3966021 ? r3966029 : r3966043;
return r3966044;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 33.3 |
|---|---|
| Target | 20.7 |
| Herbie | 10.0 |
if b < -4.82289647433212e+153Initial program 60.9
Simplified60.9
rmApplied div-inv60.9
rmApplied div-inv60.9
Applied associate-*r*60.9
Simplified60.9
Taylor expanded around -inf 2.3
Simplified2.3
if -4.82289647433212e+153 < b < 3.289226058156428e-70Initial program 12.4
Simplified12.4
rmApplied div-inv12.6
rmApplied un-div-inv12.4
if 3.289226058156428e-70 < b Initial program 52.2
Simplified52.2
rmApplied div-inv52.2
rmApplied div-inv52.2
Applied associate-*r*52.2
Simplified52.2
Taylor expanded around inf 9.1
Final simplification10.0
herbie shell --seed 2019142 +o rules:numerics
(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)))