Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One difference between [2,3,5,7] and list(primes(2, 10)) when you're running Sage in Python mode is that the types will be different, Python ints vs. Sage Integers:

from sage.all import *

i = [2,3,5,7]
j = list(primes(2, 10))

print i, map(type, i)
print j, map(type, j)

print i == j

gives

[2, 3, 5, 7] [<type 'int'>, <type 'int'>, <type 'int'>, <type 'int'>]
[2, 3, 5, 7] [<type 'sage.rings.integer.Integer'>, <type 'sage.rings.integer.Integer'>, <type 'sage.rings.integer.Integer'>, <type 'sage.rings.integer.Integer'>]
True

This will affect gamma_sq, for example:

sage: gamma_sq(2, theta1)                  
1/4*(e^(2*I*pi*theta1) - 2)*(e^(-2*I*pi*theta1) - 2)/((e^(2*I*pi*theta1) - 1)*(e^(-2*I*pi*theta1) - 1))
sage: gamma_sq(2, theta1).subs(theta1=1/2)
9/16
sage: gamma_sq(int(2), theta1)            
1/((e^(2*I*pi*theta1) - 1)*(e^(-2*I*pi*theta1) - 1))
sage: gamma_sq(int(2), theta1).subs(theta1=1/2)
1/4

due to truncating division: 1/2 gives 1/2 in QQ in Sage, but 0 in Python. (Note that I had to use the Python-loaded version of the function so that Sage's preparser didn't wrap the 2; preparser(False) would ahve worked too.)

I can't reproduce a MemoryError but I only have 5.5 at hand.

Using Integers, I get:

Representation Polynomial: x0 + x1 + x2
Prime number 2: 
First integral: -16*(e^(2*I*pi*theta2) - 1)*(e^(-2*I*pi*theta2) - 1)*(2*e^(6*I*pi*theta2) + 7*e^(4*I*pi*theta2) - 15*e^(2*I*pi*theta2) + 1)*pi^2*e^(-2*I*pi*theta2)/((e^(2*I*pi*theta2) - 2)*(e^(-2*I*pi*theta2) - 2)) 
Second Integral: 116*pi^2 
Prime number 3: 
First integral: -36*(e^(2*I*pi*theta2) - 1)*(e^(-2*I*pi*theta2) - 1)*(12*e^(6*I*pi*theta2) + 52*e^(4*I*pi*theta2) - 20*e^(2*I*pi*theta2) + 31)*pi^2*e^(-2*I*pi*theta2)/((e^(2*I*pi*theta2) - 3)*(e^(-2*I*pi*theta2) - 3)) 
Second Integral: -256*pi^2 
Prime number 5: 
First integral: -100*(e^(2*I*pi*theta2) - 1)*(e^(-2*I*pi*theta2) - 1)*(80*e^(6*I*pi*theta2) + 496*e^(4*I*pi*theta2) + 156*e^(2*I*pi*theta2) + 391)*pi^2*e^(-2*I*pi*theta2)/((e^(2*I*pi*theta2) - 5)*(e^(-2*I*pi*theta2) - 5)) 
Second Integral: -28144*pi^2 
Prime number 7: 
First integral: -196*(e^(2*I*pi*theta2) - 1)*(e^(-2*I*pi*theta2) - 1)*(252*e^(6*I*pi*theta2) + 2052*e^(4*I*pi*theta2) + 1100*e^(2*I*pi*theta2) + 1751)*pi^2*e^(-2*I*pi*theta2)/((e^(2*I*pi*theta2) - 7)*(e^(-2*I*pi*theta2) - 7)) 
Second Integral: -282944*pi^2

One difference between [2,3,5,7] and list(primes(2, 10)) when you're running Sage in Python mode is that the types will be different, Python ints vs. Sage Integers:

from sage.all import *

i = [2,3,5,7]
j = list(primes(2, 10))

print i, map(type, i)
print j, map(type, j)

print i == j

gives

[2, 3, 5, 7] [<type 'int'>, <type 'int'>, <type 'int'>, <type 'int'>]
[2, 3, 5, 7] [<type 'sage.rings.integer.Integer'>, <type 'sage.rings.integer.Integer'>, <type 'sage.rings.integer.Integer'>, <type 'sage.rings.integer.Integer'>]
True

This will affect gamma_sq, for example:

sage: gamma_sq(2, theta1)                  
1/4*(e^(2*I*pi*theta1) - 2)*(e^(-2*I*pi*theta1) - 2)/((e^(2*I*pi*theta1) - 1)*(e^(-2*I*pi*theta1) - 1))
sage: gamma_sq(2, theta1).subs(theta1=1/2)
9/16
sage: gamma_sq(int(2), theta1)            
1/((e^(2*I*pi*theta1) - 1)*(e^(-2*I*pi*theta1) - 1))
sage: gamma_sq(int(2), theta1).subs(theta1=1/2)
1/4

due to truncating division: 1/2 gives 1/2 in QQ in Sage, but 0 in Python. (Note that I had to use the Python-loaded version of the function so that Sage's preparser didn't wrap the 2; preparser(False) would ahve have worked too.)

I can't reproduce a MemoryError but I only have 5.5 at hand.

Using Integers, I get:

Representation Polynomial: x0 + x1 + x2
Prime number 2: 
First integral: -16*(e^(2*I*pi*theta2) - 1)*(e^(-2*I*pi*theta2) - 1)*(2*e^(6*I*pi*theta2) + 7*e^(4*I*pi*theta2) - 15*e^(2*I*pi*theta2) + 1)*pi^2*e^(-2*I*pi*theta2)/((e^(2*I*pi*theta2) - 2)*(e^(-2*I*pi*theta2) - 2)) 
Second Integral: 116*pi^2 
Prime number 3: 
First integral: -36*(e^(2*I*pi*theta2) - 1)*(e^(-2*I*pi*theta2) - 1)*(12*e^(6*I*pi*theta2) + 52*e^(4*I*pi*theta2) - 20*e^(2*I*pi*theta2) + 31)*pi^2*e^(-2*I*pi*theta2)/((e^(2*I*pi*theta2) - 3)*(e^(-2*I*pi*theta2) - 3)) 
Second Integral: -256*pi^2 
Prime number 5: 
First integral: -100*(e^(2*I*pi*theta2) - 1)*(e^(-2*I*pi*theta2) - 1)*(80*e^(6*I*pi*theta2) + 496*e^(4*I*pi*theta2) + 156*e^(2*I*pi*theta2) + 391)*pi^2*e^(-2*I*pi*theta2)/((e^(2*I*pi*theta2) - 5)*(e^(-2*I*pi*theta2) - 5)) 
Second Integral: -28144*pi^2 
Prime number 7: 
First integral: -196*(e^(2*I*pi*theta2) - 1)*(e^(-2*I*pi*theta2) - 1)*(252*e^(6*I*pi*theta2) + 2052*e^(4*I*pi*theta2) + 1100*e^(2*I*pi*theta2) + 1751)*pi^2*e^(-2*I*pi*theta2)/((e^(2*I*pi*theta2) - 7)*(e^(-2*I*pi*theta2) - 7)) 
Second Integral: -282944*pi^2