Revision history [back]

How to compute on cypthon mode with 64-bit integers?

The computation is on SageMath 8.3, on a 64-bit computer.
If the integers are less than $2^{31}$ everything is alright:

sage: %time champions(2**30,2**30+10)
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 2.15 ms


But if the integers are greater than $2^{31}$, there is a problem OverflowError: value too large to convert to int.

sage: champions(2**31,2**31+10)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-7-2a762f4cafd8> in <module>()
----> 1 champions(Integer(2)**Integer(31),Integer(2)**Integer(31)+Integer(10))

/home/sage/.sage/temp/LAPTOP-7O5QV19T/9856/spyx/_home_sage_SAGE_EulerRH_spyx/_home_sage_SAGE_EulerRH_spyx_0.pyx in _home_sage_SAGE_EulerRH_spyx_0.champions()
12         return len(list(factor(n)))
13
---> 14 cpdef champions(int m1, int m2):
15         cdef int n,o,s,p,pr
16         cdef float a,c

OverflowError: value too large to convert to int


Here is the code:

from sage.all import *

cpdef g(float x):
return x/(exp(float(euler_gamma))*ln(ln(x)))

cpdef omega(int n):
return len(list(factor(n)))

cpdef champions(int m1, int m2):
cdef int n,o,s,p,pr
cdef float a,c
a=1.7683358; s=2; p=3; pr=6; n=m1
while n<=m2:
if mod(n,10**7)==0:
print(n)
if n>pr:
p=next_prime(p); pr*=p; s+=1
o=omega(n)
if n<>pr:
c=(euler_phi(n)/g(float(n)))**(1/float(s-o))
if c>a:
a=c
print([n,a,factor(Integer(pr)/Integer(n))])
n+=1


How to compute on cypthon mode with 64-bit integers?

The computation is on SageMath 8.3, on a 64-bit computer.
If the integers are less than $2^{31}$ everything is alright:

sage: %time champions(2**30,2**30+10)
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 2.15 ms


But if the integers are greater than $2^{31}$, there is a problem OverflowError: value too large to convert to int.

sage: champions(2**31,2**31+10)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-7-2a762f4cafd8> in <module>()
----> 1 champions(Integer(2)**Integer(31),Integer(2)**Integer(31)+Integer(10))

/home/sage/.sage/temp/LAPTOP-7O5QV19T/9856/spyx/_home_sage_SAGE_EulerRH_spyx/_home_sage_SAGE_EulerRH_spyx_0.pyx in _home_sage_SAGE_EulerRH_spyx_0.champions()
12         return len(list(factor(n)))
13
---> 14 cpdef champions(int m1, int m2):
15         cdef int n,o,s,p,pr
16         cdef float a,c

OverflowError: value too large to convert to int


Here is the code:

from sage.all import *

cpdef g(float x):
return x/(exp(float(euler_gamma))*ln(ln(x)))

cpdef omega(int n):
return len(list(factor(n)))

cpdef champions(int m1, int m2):
cdef int n,o,s,p,pr
cdef float a,c
a=1.7683358; s=2; p=3; pr=6; n=m1
while n<=m2:
if mod(n,10**7)==0:
print(n)
if n>pr:
p=next_prime(p); pr*=p; s+=1
o=omega(n)
if n<>pr:
c=(euler_phi(n)/g(float(n)))**(1/float(s-o))
if c>a:
a=c
print([n,a,factor(Integer(pr)/Integer(n))])
n+=1


How to compute on cypthon cython mode with 64-bit integers?

The computation is on SageMath 8.3, on a 64-bit computer.
If the integers are less than $2^{31}$ everything is alright:

sage: %time champions(2**30,2**30+10)
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 2.15 ms


But if the integers are greater than $2^{31}$, there is a problem OverflowError: value too large to convert to int.

sage: champions(2**31,2**31+10)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-7-2a762f4cafd8> in <module>()
----> 1 champions(Integer(2)**Integer(31),Integer(2)**Integer(31)+Integer(10))

/home/sage/.sage/temp/LAPTOP-7O5QV19T/9856/spyx/_home_sage_SAGE_EulerRH_spyx/_home_sage_SAGE_EulerRH_spyx_0.pyx in _home_sage_SAGE_EulerRH_spyx_0.champions()
12         return len(list(factor(n)))
13
---> 14 cpdef champions(int m1, int m2):
15         cdef int n,o,s,p,pr
16         cdef float a,c

OverflowError: value too large to convert to int


Here is the code:

from sage.all import *

cpdef g(float x):
return x/(exp(float(euler_gamma))*ln(ln(x)))

cpdef omega(int n):
return len(list(factor(n)))

cpdef champions(int m1, int m2):
cdef int n,o,s,p,pr
cdef float a,c
a=1.7683358; s=2; p=3; pr=6; n=m1
while n<=m2:
if mod(n,10**7)==0:
print(n)
if n>pr:
p=next_prime(p); pr*=p; s+=1
o=omega(n)
if n<>pr:
c=(euler_phi(n)/g(float(n)))**(1/float(s-o))
if c>a:
a=c
print([n,a,factor(Integer(pr)/Integer(n))])
n+=1


How to compute on cython mode with 64-bit integers?int?

The computation is on SageMath 8.3, on a 64-bit computer.
If the integers are less than $2^{31}$ everything is alright:

sage: %time champions(2**30,2**30+10)
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 2.15 ms


But if the integers are greater than $2^{31}$, there is a problem OverflowError: value too large to convert to int.

sage: champions(2**31,2**31+10)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-7-2a762f4cafd8> in <module>()
----> 1 champions(Integer(2)**Integer(31),Integer(2)**Integer(31)+Integer(10))

/home/sage/.sage/temp/LAPTOP-7O5QV19T/9856/spyx/_home_sage_SAGE_EulerRH_spyx/_home_sage_SAGE_EulerRH_spyx_0.pyx in _home_sage_SAGE_EulerRH_spyx_0.champions()
12         return len(list(factor(n)))
13
---> 14 cpdef champions(int m1, int m2):
15         cdef int n,o,s,p,pr
16         cdef float a,c

OverflowError: value too large to convert to int


Here is the code:

from sage.all import *

cpdef g(float x):
return x/(exp(float(euler_gamma))*ln(ln(x)))

cpdef omega(int n):
return len(list(factor(n)))

cpdef champions(int m1, int m2):
cdef int n,o,s,p,pr
cdef float a,c
a=1.7683358; s=2; p=3; pr=6; n=m1
while n<=m2:
if mod(n,10**7)==0:
print(n)
if n>pr:
p=next_prime(p); pr*=p; s+=1
o=omega(n)
if n<>pr:
c=(euler_phi(n)/g(float(n)))**(1/float(s-o))
if c>a:
a=c
print([n,a,factor(Integer(pr)/Integer(n))])
n+=1