\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 -1.555632367828988861043913196266489993904 \cdot 10^{101}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 7.455592343308264166675918758902222662503 \cdot 10^{-170}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r153004 = b;
double r153005 = -r153004;
double r153006 = r153004 * r153004;
double r153007 = 4.0;
double r153008 = a;
double r153009 = r153007 * r153008;
double r153010 = c;
double r153011 = r153009 * r153010;
double r153012 = r153006 - r153011;
double r153013 = sqrt(r153012);
double r153014 = r153005 + r153013;
double r153015 = 2.0;
double r153016 = r153015 * r153008;
double r153017 = r153014 / r153016;
return r153017;
}
double f(double a, double b, double c) {
double r153018 = b;
double r153019 = -1.555632367828989e+101;
bool r153020 = r153018 <= r153019;
double r153021 = 1.0;
double r153022 = c;
double r153023 = r153022 / r153018;
double r153024 = a;
double r153025 = r153018 / r153024;
double r153026 = r153023 - r153025;
double r153027 = r153021 * r153026;
double r153028 = 7.455592343308264e-170;
bool r153029 = r153018 <= r153028;
double r153030 = r153018 * r153018;
double r153031 = 4.0;
double r153032 = r153031 * r153024;
double r153033 = r153032 * r153022;
double r153034 = r153030 - r153033;
double r153035 = sqrt(r153034);
double r153036 = r153035 - r153018;
double r153037 = 2.0;
double r153038 = r153037 * r153024;
double r153039 = r153036 / r153038;
double r153040 = -1.0;
double r153041 = r153040 * r153023;
double r153042 = r153029 ? r153039 : r153041;
double r153043 = r153020 ? r153027 : r153042;
return r153043;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.2 |
|---|---|
| Target | 20.8 |
| Herbie | 11.6 |
if b < -1.555632367828989e+101Initial program 47.4
Simplified47.4
rmApplied div-inv47.4
rmApplied *-un-lft-identity47.4
Applied associate-*l*47.4
Simplified47.4
Taylor expanded around -inf 3.6
Simplified3.6
if -1.555632367828989e+101 < b < 7.455592343308264e-170Initial program 11.7
Simplified11.7
rmApplied div-inv11.8
rmApplied *-un-lft-identity11.8
Applied associate-*l*11.8
Simplified11.7
if 7.455592343308264e-170 < b Initial program 48.9
Simplified48.9
Taylor expanded around inf 14.1
Final simplification11.6
herbie shell --seed 2019323 +o rules:numerics
(FPCore (a b c)
:name "The quadratic formula (r1)"
:precision binary64
:herbie-target
(if (< b 0.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)))