Ask Your Question
1

Generate a list/table for cardinality of elliptic curve

asked 2011-02-09 03:22:18 +0100

Kenji gravatar image

updated 2015-01-13 21:02:02 +0100

FrédéricC gravatar image

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 flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2011-02-09 04:04:46 +0100

DSM gravatar image

updated 2011-02-09 04:05:24 +0100

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.

edit flag offensive delete link more

Comments

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

Kenji gravatar imageKenji ( 2011-02-09 04:28:25 +0100 )edit

Iie, nandemonai.

DSM gravatar imageDSM ( 2011-02-09 04:30:25 +0100 )edit

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

Kenji gravatar imageKenji ( 2011-02-09 04:39:52 +0100 )edit

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

DSM gravatar imageDSM ( 2011-02-09 04:58:36 +0100 )edit

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

Kenji gravatar imageKenji ( 2011-02-09 05:02:24 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-02-09 03:22:18 +0100

Seen: 966 times

Last updated: Feb 09 '11