Ask Your Question

Revision history [back]

The reason is that when you use [3..5], the iterator produces Sage Integers:

sage: for r1 in [3..5]:
....:     print type(r1)
<type 'sage.rings.integer.Integer'>
<type 'sage.rings.integer.Integer'>
<type 'sage.rings.integer.Integer'>

while when you use range(3,6), the iterator produces Python ints:

sage: for r1 in range(3,6):
    print type(r1)
<type 'int'>
<type 'int'>
<type 'int'>

Now when you write r2 / r1, if one of them is a Sage Integer, you get a rational nomber. If both are Python ints, then you get an int, that is the rounded fraction:

sage: ZZ(3)/int(2)
3/2
sage: int(3)/ZZ(2)
3/2
sage: ZZ(3)/ZZ(2)
3/2
sage: int(3)/int(2)
1

Hence, when both r1 and r2 are produced by 'range(), withr2 < r1, the value ofr2/r1* (pi ^ pi))will be0`, hence your plot starts and ends with the same value, which explains the error.

To solve the problem, you can use srange() function, which produces Sage integers instead of Pythoin ints, this will solve your problem.

The reason is that when you use [3..5], the iterator produces Sage Integers:

sage: for r1 in [3..5]:
....:     print type(r1)
<type 'sage.rings.integer.Integer'>
<type 'sage.rings.integer.Integer'>
<type 'sage.rings.integer.Integer'>

while when you use range(3,6), the iterator produces Python ints:

sage: for r1 in range(3,6):
    print type(r1)
<type 'int'>
<type 'int'>
<type 'int'>

Now when you write r2 / r1, if one of them is a Sage Integer, you get a rational nomber. If both are Python ints, then you get an int, that is the rounded fraction:

sage: ZZ(3)/int(2)
3/2
sage: int(3)/ZZ(2)
3/2
sage: ZZ(3)/ZZ(2)
3/2
sage: int(3)/int(2)
1

Hence, when both r1 and r2 are produced by 'range(), withrange(), with r2 < r1, the value ofof r2/r1* (pi ^ pi)) will be0`, be 0, hence your plot starts and ends with the same value, which explains the error.

To solve the problem, you can use srange() function, which produces Sage integers instead of Pythoin ints, this will solve your problem.