Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

p.degrees()[-d-1] yields the exponent that belongs to a[d], even after we introduce a higher a[d]:

sage: R.<a> = InfinitePolynomialRing(QQ)
....: p = a[1]*a[2]^2
....: p.degrees()[-2-1]
2
sage: p.degrees()[-3-1]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In [2], line 1
----> 1 p.degrees()[-Integer(3)-Integer(1)]

IndexError: tuple index out of range
sage: a[3]
a_3
sage: p.degrees()[-2-1]
2

p.degrees()[-d-1] yields the exponent that belongs to a[d], even after we introduce a higher a[d]:

sage: R.<a> = InfinitePolynomialRing(QQ)
....: p = a[1]*a[2]^2
....: p.degrees()[-2-1]
2
sage: p.degrees()[-3-1]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In [2], line 1
----> 1 p.degrees()[-Integer(3)-Integer(1)]

IndexError: tuple index out of range
sage: a[3]
a_3
sage: p.degrees()[-2-1]
2

It would be nice to have 0 as the output instead of the error.