ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 08 Feb 2011 22:02:24 -0600Generate a list/table for cardinality of elliptic curvehttp://ask.sagemath.org/question/7933/generate-a-listtable-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 =)Tue, 08 Feb 2011 20:22:18 -0600http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/Answer by DSM for <p>Hi all. I am quite new in SAGE. I have tried SAGE to find the cardinality for every prime number like this:</p>
<p>sage: E = EllipticCurve(GF(13),[-2,3]) <br/>
sage: E.cardinality()</p>
<p>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?</p>
<p>Many thanks =)</p>
http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?answer=12080#post-id-12080There are a couple of ways to do this. You could use a loop and print it to the screen:
<pre><code>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.]
</code></pre>
but then you can't really do anything with it afterwards. Better, you can make a list of them:
<pre><code>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]
</code></pre>
Or you can even make a dictionary of them, so that referring to them later is easy:
<pre><code>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
</code></pre>
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.Tue, 08 Feb 2011 21:04:46 -0600http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?answer=12080#post-id-12080Comment by Kenji for <p>There are a couple of ways to do this. You could use a loop and print it to the screen:</p>
<pre><code>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.]
</code></pre>
<p>but then you can't really do anything with it afterwards. Better, you can make a list of them:</p>
<pre><code>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]
</code></pre>
<p>Or you can even make a dictionary of them, so that referring to them later is easy:</p>
<pre><code>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
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22160#post-id-22160Oh I see...It's ok..=)Tue, 08 Feb 2011 22:02:24 -0600http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22160#post-id-22160Comment by DSM for <p>There are a couple of ways to do this. You could use a loop and print it to the screen:</p>
<pre><code>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.]
</code></pre>
<p>but then you can't really do anything with it afterwards. Better, you can make a list of them:</p>
<pre><code>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]
</code></pre>
<p>Or you can even make a dictionary of them, so that referring to them later is easy:</p>
<pre><code>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
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22161#post-id-22161Aah! Sorry, my fault. :^) I have a relative named Kenji, and he's Japanese.Tue, 08 Feb 2011 21:58:36 -0600http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22161#post-id-22161Comment by Kenji for <p>There are a couple of ways to do this. You could use a loop and print it to the screen:</p>
<pre><code>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.]
</code></pre>
<p>but then you can't really do anything with it afterwards. Better, you can make a list of them:</p>
<pre><code>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]
</code></pre>
<p>Or you can even make a dictionary of them, so that referring to them later is easy:</p>
<pre><code>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
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22164#post-id-22164Thanks for the reply. It's really help! Yes, I have spent my time in dealing the elliptic curves =)Tue, 08 Feb 2011 21:28:25 -0600http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22164#post-id-22164Comment by DSM for <p>There are a couple of ways to do this. You could use a loop and print it to the screen:</p>
<pre><code>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.]
</code></pre>
<p>but then you can't really do anything with it afterwards. Better, you can make a list of them:</p>
<pre><code>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]
</code></pre>
<p>Or you can even make a dictionary of them, so that referring to them later is easy:</p>
<pre><code>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
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22163#post-id-22163Iie, nandemonai.Tue, 08 Feb 2011 21:30:25 -0600http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22163#post-id-22163Comment by Kenji for <p>There are a couple of ways to do this. You could use a loop and print it to the screen:</p>
<pre><code>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.]
</code></pre>
<p>but then you can't really do anything with it afterwards. Better, you can make a list of them:</p>
<pre><code>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]
</code></pre>
<p>Or you can even make a dictionary of them, so that referring to them later is easy:</p>
<pre><code>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
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22162#post-id-22162I cannot understand your comment "Iie, nandemonai"...Google translate said it's German and no translations in English :(Tue, 08 Feb 2011 21:39:52 -0600http://ask.sagemath.org/question/7933/generate-a-listtable-for-cardinality-of-elliptic-curve/?comment=22162#post-id-22162