Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are a couple of ways to do this. You could use a loop and print it to the screen:

sage: for p in primes(3, 100):
....:         print p, EllipticCurve(GF(p), [-2, 3]).cardinality()
....: 
3 4
5 5
7 6
11 11
13 13
[etc.]

but then you can't really do anything with it afterwards. Better, you can make a list of them:

sage: Es = [EllipticCurve(GF(p), [-2, 3]).cardinality() for p in primes(3, 100)]
sage: Es
[4, 5, 6, 11, 13, 18, 25, 30, 40, 30, 45, 44, 35, 45, 64, 56, 54, 72, 77, 84, 71, 76, 86, 86]
sage: Es = list(EllipticCurve(GF(p), [-2, 3]).cardinality() for p in primes(3, 100))
sage: Es
[4, 5, 6, 11, 13, 18, 25, 30, 40, 30, 45, 44, 35, 45, 64, 56, 54, 72, 77, 84, 71, 76, 86, 86]

Or you can even make a dictionary of them, so that referring to them later is easy:

sage: EE = dict((p, EllipticCurve(GF(p), [-2, 3]).cardinality()) for p in primes(3, 100))
sage: EE
{3: 4, 5: 5, 7: 6, 11: 11, 13: 13, 17: 18, 19: 25, 23: 30, 29: 40, 31: 30, 37: 45, 41: 44, 43: 35, 47: 45, 53: 64, 59: 56, 61: 54, 67: 72, 71: 77, 73: 84, 79: 71, 83: 76, 89: 86, 97: 86}
sage: EE[47]
45

I wouldn't worry much about the speed of the primes -- you'll almost certainly spend most of the time dealing with the elliptic curves themselves.

????????!

There are a couple of ways to do this. You could use a loop and print it to the screen:

sage: for p in primes(3, 100):
....:         print p, EllipticCurve(GF(p), [-2, 3]).cardinality()
....: 
3 4
5 5
7 6
11 11
13 13
[etc.]

but then you can't really do anything with it afterwards. Better, you can make a list of them:

sage: Es = [EllipticCurve(GF(p), [-2, 3]).cardinality() for p in primes(3, 100)]
sage: Es
[4, 5, 6, 11, 13, 18, 25, 30, 40, 30, 45, 44, 35, 45, 64, 56, 54, 72, 77, 84, 71, 76, 86, 86]
sage: Es = list(EllipticCurve(GF(p), [-2, 3]).cardinality() for p in primes(3, 100))
sage: Es
[4, 5, 6, 11, 13, 18, 25, 30, 40, 30, 45, 44, 35, 45, 64, 56, 54, 72, 77, 84, 71, 76, 86, 86]

Or you can even make a dictionary of them, so that referring to them later is easy:

sage: EE = dict((p, EllipticCurve(GF(p), [-2, 3]).cardinality()) for p in primes(3, 100))
sage: EE
{3: 4, 5: 5, 7: 6, 11: 11, 13: 13, 17: 18, 19: 25, 23: 30, 29: 40, 31: 30, 37: 45, 41: 44, 43: 35, 47: 45, 53: 64, 59: 56, 61: 54, 67: 72, 71: 77, 73: 84, 79: 71, 83: 76, 89: 86, 97: 86}
sage: EE[47]
45

I wouldn't worry much about the speed of the primes -- you'll almost certainly spend most of the time dealing with the elliptic curves themselves.

????????!