Repository: sympy/sympy

Issue:
Mul(AccumBounds(-1, 1), 0) gives AccumBounds(-1, 1)
```py
>>> Mul(AccumBounds(-1, 1), 0)
<-1, 1>
```

Even though

```py
>>> Mul(0, AccumBounds(-1, 1))
0
>>> 0*AccumBounds(-1, 1)
0
>>> AccumBounds(-1, 1)*0
0
```

This is resulting in a regression in https://github.com/sympy/sympy/pull/13059 for `limit(atan(x)*sin(1/x), x, 0)` because the limit heuristics are going through the args in a different order. Probably an example could be found for master where an AccumBounds is returned from limit instead of 0. 

Discussion:

Patch:
diff --git a/sympy/core/mul.py b/sympy/core/mul.py
index c956761dda..a7cd05b7d6 100644
--- a/sympy/core/mul.py
+++ b/sympy/core/mul.py
@@ -180,6 +180,7 @@ def flatten(cls, seq):
             a, b = seq
             if b.is_Rational:
                 a, b = b, a
+                seq = [a, b]
             assert not a is S.One
             if not a.is_zero and a.is_Rational:
                 r, b = b.as_coeff_Mul()


Test patch:
diff --git a/sympy/calculus/tests/test_util.py b/sympy/calculus/tests/test_util.py
index 4160ab0ef3..f496ecbbdc 100644
--- a/sympy/calculus/tests/test_util.py
+++ b/sympy/calculus/tests/test_util.py
@@ -359,3 +359,6 @@ def test_contains_AccumBounds():
         (cos(1)**2 + sin(1)**2 - 1) in AccumBounds(-1, 0))
     assert (-oo in AccumBounds(1, oo)) == S.true
     assert (oo in AccumBounds(-oo, 0)) == S.true
+
+    # issue 13159
+    assert Mul(0, AccumBounds(-1, 1)) == Mul(AccumBounds(-1, 1), 0) == 0