-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Labels
Wrong ResultThe output produced by SymPy is mathematically incorrect.The output produced by SymPy is mathematically incorrect.
Description
Whereas a Range with numerical args is canonical, the Range containing symbols is not:
>>> [Range(3,j,2) for j in range(4,10)]
[Range(3, 5, 2), Range(3, 5, 2), Range(3, 7, 2), Range(3, 7, 2), Range(3, 9, 2), Range(3, 9, 2)]
vs
>>> [Range(i,i+j,5) for j in range(1,6)]
[Range(i, i + 1, 5), Range(i, i + 2, 5), Range(i, i + 3, 5), Range(i, i + 4, 5), Range(i, i + 5, 5)]
which could be
[Range(i, i + 1, 5), Range(i, i + 1, 5), Range(i, i + 1, 5), Range(i, i + 1, 5), Range(i, i + 1, 5)]
The incorrect results are based on the assumption that the instantiated Range is canonical:
>> r=Range(2, 2 + 3, 5)
>>> r.inf,r.reversed.sup
(2, 2)
>>> r = Range(k, k + 3, 5)
>>> r.inf,r.reversed.sup
(k, k - 2)
Metadata
Metadata
Assignees
Labels
Wrong ResultThe output produced by SymPy is mathematically incorrect.The output produced by SymPy is mathematically incorrect.