\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -4.78285893492843261 \cdot 10^{-126}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \le 3.6627135292415903 \cdot 10^{111}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\end{array}double f(double a, double b, double c) {
double r73874 = b;
double r73875 = -r73874;
double r73876 = r73874 * r73874;
double r73877 = 4.0;
double r73878 = a;
double r73879 = c;
double r73880 = r73878 * r73879;
double r73881 = r73877 * r73880;
double r73882 = r73876 - r73881;
double r73883 = sqrt(r73882);
double r73884 = r73875 - r73883;
double r73885 = 2.0;
double r73886 = r73885 * r73878;
double r73887 = r73884 / r73886;
return r73887;
}
double f(double a, double b, double c) {
double r73888 = b;
double r73889 = -4.7828589349284326e-126;
bool r73890 = r73888 <= r73889;
double r73891 = -1.0;
double r73892 = c;
double r73893 = r73892 / r73888;
double r73894 = r73891 * r73893;
double r73895 = 3.6627135292415903e+111;
bool r73896 = r73888 <= r73895;
double r73897 = -r73888;
double r73898 = r73888 * r73888;
double r73899 = 4.0;
double r73900 = a;
double r73901 = r73900 * r73892;
double r73902 = r73899 * r73901;
double r73903 = r73898 - r73902;
double r73904 = sqrt(r73903);
double r73905 = r73897 - r73904;
double r73906 = 2.0;
double r73907 = r73906 * r73900;
double r73908 = r73905 / r73907;
double r73909 = 1.0;
double r73910 = r73888 / r73900;
double r73911 = r73893 - r73910;
double r73912 = r73909 * r73911;
double r73913 = r73896 ? r73908 : r73912;
double r73914 = r73890 ? r73894 : r73913;
return r73914;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.5 |
|---|---|
| Target | 20.6 |
| Herbie | 10.5 |
if b < -4.7828589349284326e-126Initial program 51.3
Taylor expanded around -inf 11.3
if -4.7828589349284326e-126 < b < 3.6627135292415903e+111Initial program 12.0
rmApplied div-inv12.1
rmApplied *-un-lft-identity12.1
Applied associate-*l*12.1
Simplified12.0
if 3.6627135292415903e+111 < b Initial program 49.7
rmApplied div-inv49.8
rmApplied *-un-lft-identity49.8
Applied associate-*l*49.8
Simplified49.7
Taylor expanded around inf 3.4
Simplified3.4
Final simplification10.5
herbie shell --seed 2020047 +o rules:numerics
(FPCore (a b c)
:name "The quadratic formula (r2)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))