\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.91962817906715367126033645969528543778 \cdot 10^{153}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 2.071930020515770918527743961403466592109 \cdot 10^{-74}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \left(-2 \cdot \frac{c}{b}\right)\\
\end{array}double f(double a, double b, double c) {
double r55949 = b;
double r55950 = -r55949;
double r55951 = r55949 * r55949;
double r55952 = 4.0;
double r55953 = a;
double r55954 = r55952 * r55953;
double r55955 = c;
double r55956 = r55954 * r55955;
double r55957 = r55951 - r55956;
double r55958 = sqrt(r55957);
double r55959 = r55950 + r55958;
double r55960 = 2.0;
double r55961 = r55960 * r55953;
double r55962 = r55959 / r55961;
return r55962;
}
double f(double a, double b, double c) {
double r55963 = b;
double r55964 = -4.919628179067154e+153;
bool r55965 = r55963 <= r55964;
double r55966 = 1.0;
double r55967 = c;
double r55968 = r55967 / r55963;
double r55969 = a;
double r55970 = r55963 / r55969;
double r55971 = r55968 - r55970;
double r55972 = r55966 * r55971;
double r55973 = 2.071930020515771e-74;
bool r55974 = r55963 <= r55973;
double r55975 = 1.0;
double r55976 = 2.0;
double r55977 = r55975 / r55976;
double r55978 = r55963 * r55963;
double r55979 = 4.0;
double r55980 = r55979 * r55969;
double r55981 = r55980 * r55967;
double r55982 = r55978 - r55981;
double r55983 = sqrt(r55982);
double r55984 = r55983 - r55963;
double r55985 = r55984 / r55969;
double r55986 = r55977 * r55985;
double r55987 = -2.0;
double r55988 = r55987 * r55968;
double r55989 = r55977 * r55988;
double r55990 = r55974 ? r55986 : r55989;
double r55991 = r55965 ? r55972 : r55990;
return r55991;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.8 |
|---|---|
| Target | 20.4 |
| Herbie | 10.3 |
if b < -4.919628179067154e+153Initial program 63.8
Simplified63.8
Taylor expanded around -inf 2.1
Simplified2.1
if -4.919628179067154e+153 < b < 2.071930020515771e-74Initial program 12.8
Simplified12.8
rmApplied clear-num13.0
rmApplied div-inv13.0
Applied add-cube-cbrt13.0
Applied times-frac13.0
Simplified13.0
Simplified12.9
rmApplied add-sqr-sqrt12.9
Applied times-frac12.9
Applied associate-*l*12.9
Simplified12.8
if 2.071930020515771e-74 < b Initial program 53.2
Simplified53.2
rmApplied clear-num53.2
rmApplied div-inv53.2
Applied add-cube-cbrt53.2
Applied times-frac53.2
Simplified53.2
Simplified53.2
rmApplied add-sqr-sqrt53.2
Applied times-frac53.2
Applied associate-*l*53.2
Simplified53.2
Taylor expanded around inf 9.2
Final simplification10.3
herbie shell --seed 2019208 +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)))