# Generate a list/table for cardinality of elliptic curve

Hi all. I am quite new in SAGE. I have tried SAGE to find the cardinality for every prime number like this:

sage: E = EllipticCurve(GF(13),[-2,3])
sage: E.cardinality()

For this, I try prime number 13 and get the answer 18. This mean that I need to input a new prime number every time manually. What the code to generate/make a list or table of answers for a set of prime numbers (hopefully can integrate "primes_first_n()") which can go to large prime?

Many thanks =)

edit retag close merge delete

Sort by » oldest newest most voted

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.

more

Thanks for the reply. It's really help! Yes, I have spent my time in dealing the elliptic curves =)

( 2011-02-08 21:28:25 -0500 )edit

Iie, nandemonai.

( 2011-02-08 21:30:25 -0500 )edit

I cannot understand your comment "Iie, nandemonai"...Google translate said it's German and no translations in English :(

( 2011-02-08 21:39:52 -0500 )edit

Aah! Sorry, my fault. :^) I have a relative named Kenji, and he's Japanese.

( 2011-02-08 21:58:36 -0500 )edit

Oh I see...It's ok..=)

( 2011-02-08 22:02:24 -0500 )edit