ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 06 Aug 2013 12:04:47 +0200Tuples or for loopshttps://ask.sagemath.org/question/10418/tuples-or-for-loops/Hi everybody, I would like to compute the $L$-function of an elliptic curve of the form $$y^2=x^3-d^2x$$
for multiple values of $d$ at $s=1$. I was hoping to use an $n$-tuple
d=(1,3,5,7,...,n)
with the hope that I could then do
E=EllipticCurve([0,0,0,-(d^2),0])
L = E.lseries().dokchitser()
L(1)
such that at every stage the data would be in a vector/$n$-tuple form, but this is not possible. Does anyone know how I can make this method work? With a for-loop perhaps? Thanks in advance for your help!Tue, 06 Aug 2013 06:56:01 +0200https://ask.sagemath.org/question/10418/tuples-or-for-loops/Answer by ppurka for <p>Hi everybody, I would like to compute the $L$-function of an elliptic curve of the form $$y^2=x^3-d^2x$$
for multiple values of $d$ at $s=1$. I was hoping to use an $n$-tuple </p>
<pre><code>d=(1,3,5,7,...,n)
</code></pre>
<p>with the hope that I could then do</p>
<pre><code>E=EllipticCurve([0,0,0,-(d^2),0])
L = E.lseries().dokchitser()
L(1)
</code></pre>
<p>such that at every stage the data would be in a vector/$n$-tuple form, but this is not possible. Does anyone know how I can make this method work? With a for-loop perhaps? Thanks in advance for your help!</p>
https://ask.sagemath.org/question/10418/tuples-or-for-loops/?answer=15320#post-id-15320Use the [map and lambda](http://docs.python.org/2/howto/functional.html) operators.
dlist = range(1, n+1, 2)
map(lambda d: EllipticCurve([0,0,0,-(d^2),0]).lseries().dokchitser()(1), dlist)
If it gets too complicated, then use a python function instead of the `lambda` so that the code retains readability.Tue, 06 Aug 2013 07:41:45 +0200https://ask.sagemath.org/question/10418/tuples-or-for-loops/?answer=15320#post-id-15320Answer by Volker Braun for <p>Hi everybody, I would like to compute the $L$-function of an elliptic curve of the form $$y^2=x^3-d^2x$$
for multiple values of $d$ at $s=1$. I was hoping to use an $n$-tuple </p>
<pre><code>d=(1,3,5,7,...,n)
</code></pre>
<p>with the hope that I could then do</p>
<pre><code>E=EllipticCurve([0,0,0,-(d^2),0])
L = E.lseries().dokchitser()
L(1)
</code></pre>
<p>such that at every stage the data would be in a vector/$n$-tuple form, but this is not possible. Does anyone know how I can make this method work? With a for-loop perhaps? Thanks in advance for your help!</p>
https://ask.sagemath.org/question/10418/tuples-or-for-loops/?answer=15321#post-id-15321List comprehensions are usually clearer than map/lambda where applicable:
[EllipticCurve([0,0,0,-d^2,0]).lseries().dokchitser()(1) for d in range(1, n+1, 2)]Tue, 06 Aug 2013 11:42:24 +0200https://ask.sagemath.org/question/10418/tuples-or-for-loops/?answer=15321#post-id-15321Comment by Blackadder for <p>List comprehensions are usually clearer than map/lambda where applicable:</p>
<pre><code>[EllipticCurve([0,0,0,-d^2,0]).lseries().dokchitser()(1) for d in range(1, n+1, 2)]
</code></pre>
https://ask.sagemath.org/question/10418/tuples-or-for-loops/?comment=17183#post-id-17183This is exactly what I was looking for thank you so much Volker!!Tue, 06 Aug 2013 12:04:47 +0200https://ask.sagemath.org/question/10418/tuples-or-for-loops/?comment=17183#post-id-17183