\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 -2.880394710329243 \cdot 10^{+120}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \le 5.818192251940127 \cdot 10^{-227}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}\\
\mathbf{elif}\;b \le 6.6006279600139335 \cdot 10^{+131}:\\
\;\;\;\;\left(c \cdot -2\right) \cdot \frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r9571944 = b;
double r9571945 = -r9571944;
double r9571946 = r9571944 * r9571944;
double r9571947 = 4.0;
double r9571948 = a;
double r9571949 = r9571947 * r9571948;
double r9571950 = c;
double r9571951 = r9571949 * r9571950;
double r9571952 = r9571946 - r9571951;
double r9571953 = sqrt(r9571952);
double r9571954 = r9571945 + r9571953;
double r9571955 = 2.0;
double r9571956 = r9571955 * r9571948;
double r9571957 = r9571954 / r9571956;
return r9571957;
}
double f(double a, double b, double c) {
double r9571958 = b;
double r9571959 = -2.880394710329243e+120;
bool r9571960 = r9571958 <= r9571959;
double r9571961 = c;
double r9571962 = r9571961 / r9571958;
double r9571963 = a;
double r9571964 = r9571958 / r9571963;
double r9571965 = r9571962 - r9571964;
double r9571966 = 5.818192251940127e-227;
bool r9571967 = r9571958 <= r9571966;
double r9571968 = r9571958 * r9571958;
double r9571969 = r9571961 * r9571963;
double r9571970 = 4.0;
double r9571971 = r9571969 * r9571970;
double r9571972 = r9571968 - r9571971;
double r9571973 = sqrt(r9571972);
double r9571974 = r9571973 - r9571958;
double r9571975 = 2.0;
double r9571976 = r9571963 * r9571975;
double r9571977 = r9571974 / r9571976;
double r9571978 = 6.6006279600139335e+131;
bool r9571979 = r9571958 <= r9571978;
double r9571980 = -2.0;
double r9571981 = r9571961 * r9571980;
double r9571982 = 1.0;
double r9571983 = r9571973 + r9571958;
double r9571984 = r9571982 / r9571983;
double r9571985 = r9571981 * r9571984;
double r9571986 = -r9571962;
double r9571987 = r9571979 ? r9571985 : r9571986;
double r9571988 = r9571967 ? r9571977 : r9571987;
double r9571989 = r9571960 ? r9571965 : r9571988;
return r9571989;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 32.9 |
|---|---|
| Target | 20.3 |
| Herbie | 6.4 |
if b < -2.880394710329243e+120Initial program 49.1
Simplified49.1
Taylor expanded around -inf 2.7
if -2.880394710329243e+120 < b < 5.818192251940127e-227Initial program 9.3
Simplified9.3
if 5.818192251940127e-227 < b < 6.6006279600139335e+131Initial program 35.9
Simplified35.9
rmApplied *-un-lft-identity35.9
Applied *-un-lft-identity35.9
Applied distribute-lft-out--35.9
Applied associate-/l*35.9
rmApplied flip--36.0
Applied associate-/r/36.1
Applied *-un-lft-identity36.1
Applied times-frac36.1
Simplified13.6
Taylor expanded around inf 7.3
if 6.6006279600139335e+131 < b Initial program 60.5
Simplified60.5
Taylor expanded around inf 2.2
Simplified2.2
Final simplification6.4
herbie shell --seed 2019124
(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)))