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.Fri, 14 Jun 2019 15:22:43 -0500Series expansion for theta function of even latticehttp://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/I am new to sage and trying to figure out how to calculate the series expansion of the theta function for an even lattice $L$, i.e. $$\Theta_L(q)=\sum_{x\in L} q^{\langle x,x\rangle/2}$$
I tried the following code for the $A_2$ lattice, but I doesn't really do what its supposed to do
<pre>
Q=QuadraticForm(QQ,2,[2,-1,2]); Q
Q.theta_series(20)
</pre>
I found the following code on [OEIS](https://oeis.org/A004016), which gives the correct result:
<pre>
ModularForms( Gamma1(3), 1, prec=81).0
</pre>Wed, 21 Jun 2017 19:45:53 -0500http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/Answer by MikeBattaglia for <p>I am new to sage and trying to figure out how to calculate the series expansion of the theta function for an even lattice $L$, i.e. $$\Theta_L(q)=\sum_{x\in L} q^{\langle x,x\rangle/2}$$</p>
<p>I tried the following code for the $A_2$ lattice, but I doesn't really do what its supposed to do</p>
<pre>Q=QuadraticForm(QQ,2,[2,-1,2]); Q
Q.theta_series(20)
</pre>
<p>I found the following code on https://oeis.org/A004016 (OEIS), which gives the correct result:</p>
<pre>ModularForms( Gamma1(3), 1, prec=81).0
</pre>
http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?answer=46916#post-id-46916There is a simpler explanation, which is that the quadratic form
[ 2 -1 ]
[ * 2 ]
Maps to the matrix
[ 2 -1 ]
[ 0 2 ]
Which is equivalent to the symmetric matrix
[2 -1/2]
[-1/2 2]
Which can be gotten with A.Gram_matrix().
The A.matrix() function listed in the answer above is the Hessian, which is double the Gram matrix.
The documentation for Gram matrix gives as an example a Quadratic form with diagonal matrix. Should probably be updated to include off-diagonal terms to make this clearer.Fri, 14 Jun 2019 15:22:43 -0500http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?answer=46916#post-id-46916Answer by dan_fulea for <p>I am new to sage and trying to figure out how to calculate the series expansion of the theta function for an even lattice $L$, i.e. $$\Theta_L(q)=\sum_{x\in L} q^{\langle x,x\rangle/2}$$</p>
<p>I tried the following code for the $A_2$ lattice, but I doesn't really do what its supposed to do</p>
<pre>Q=QuadraticForm(QQ,2,[2,-1,2]); Q
Q.theta_series(20)
</pre>
<p>I found the following code on https://oeis.org/A004016 (OEIS), which gives the correct result:</p>
<pre>ModularForms( Gamma1(3), 1, prec=81).0
</pre>
http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?answer=38058#post-id-38058Please let me answer using an epic style, since it reflects my experience with these objects.
Let $A$ be the quadratic form from the above post...
sage: A = QuadraticForm( QQ, 2, [2, -1, 2] )
sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
A longer time i thought this is the quadratic form corresponding to the symmetrically extended matrix with those entries, i.e. to...
sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
since what else should be the star?! ...till i got an error, then searching for it was typing something like...
sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
sage: A.matrix() # oh, there is a matrix method!
[ 4 -1]
[-1 4]
sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
sage: v = vector( [100, 10] )
sage: A(v)
19200
sage: 2 * 100^2 - 2*100*10 + 10^2
18100
sage: 2 * 100^2 - 100*10 + 10^2
19100
sage: ( v * A.matrix() * v.column() ) / 2
(19200)
sage: ( v * MA * v.column() ) / 2
(9100)
sage: ( v * MA * v.column() )
(18200)
And the quadratic form `A` is not quite reflected by the symmetic matrix `MA`. What is going on here?
I think, the answer to the question is already here, despite of the fact that there is only one more question...
In the given posted situation with the `Q`, i suspect the quadratic form written for the above matrix `MA` instead is needed / intended, the one which maps the vector $x$ with components $s,t$ to
$$ q_A(x)=\frac 12\langle x,x\rangle_A =\frac 12(2s^2-2st+t^2) = x^2-xy+y^2\ . $$
Since the expected theta series is an other one, let us consider "the other quadratic form", and the theta series associated to it...
sage: B = QuadraticForm( QQ, 2, [1, -1, 1] )
sage: B
Quadratic form in 2 variables over Rational Field with coefficients:
[ 1 -1 ]
[ * 1 ]
sage: B.theta_series( 20 )
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
...is in agreement with
sage: ModularForms( Gamma1(3), 1, prec=20 ).0
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
and in fact the first $1000$ coefficients do coincide... For this we may try successively to get them (right):
sage: b = B.theta_series( 1000 )
sage: m = ModularForms( Gamma1(3), 1, prec=20 ).0
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: m.coefficients( 1000 )[:20] # !first coeff is not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: b.polynomial().coeffs()[:20]
[1, 6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12]
sage: m.coefficients(1000)[:20] # !first coefficient, the starting one, not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.polynomial().coeffs()[1:20] == m.coefficients(1000)[:19]
True
sage: b.polynomial().coeffs()[1:1000] == m.coefficients(1000)[:999]
True
I hope we are both at home now, know which maths object is which sage object.Thu, 22 Jun 2017 14:37:13 -0500http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?answer=38058#post-id-38058Comment by kcrisman for <p>Please let me answer using an epic style, since it reflects my experience with these objects. </p>
<p>Let $A$ be the quadratic form from the above post...</p>
<pre><code>sage: A = QuadraticForm( QQ, 2, [2, -1, 2] )
sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
</code></pre>
<p>A longer time i thought this is the quadratic form corresponding to the symmetrically extended matrix with those entries, i.e. to...</p>
<pre><code>sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
</code></pre>
<p>since what else should be the star?! ...till i got an error, then searching for it was typing something like...</p>
<pre><code>sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
sage: A.matrix() # oh, there is a matrix method!
[ 4 -1]
[-1 4]
sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
sage: v = vector( [100, 10] )
sage: A(v)
19200
sage: 2 * 100^2 - 2*100*10 + 10^2
18100
sage: 2 * 100^2 - 100*10 + 10^2
19100
sage: ( v * A.matrix() * v.column() ) / 2
(19200)
sage: ( v * MA * v.column() ) / 2
(9100)
sage: ( v * MA * v.column() )
(18200)
</code></pre>
<p>And the quadratic form <code>A</code> is not quite reflected by the symmetic matrix <code>MA</code>. What is going on here?
I think, the answer to the question is already here, despite of the fact that there is only one more question...</p>
<p>In the given posted situation with the <code>Q</code>, i suspect the quadratic form written for the above matrix <code>MA</code> instead is needed / intended, the one which maps the vector $x$ with components $s,t$ to
$$ q_A(x)=\frac 12\langle x,x\rangle_A =\frac 12(2s^2-2st+t^2) = x^2-xy+y^2\ . $$</p>
<p>Since the expected theta series is an other one, let us consider "the other quadratic form", and the theta series associated to it...</p>
<pre><code>sage: B = QuadraticForm( QQ, 2, [1, -1, 1] )
sage: B
Quadratic form in 2 variables over Rational Field with coefficients:
[ 1 -1 ]
[ * 1 ]
sage: B.theta_series( 20 )
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>...is in agreement with </p>
<pre><code>sage: ModularForms( Gamma1(3), 1, prec=20 ).0
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>and in fact the first $1000$ coefficients do coincide... For this we may try successively to get them (right):</p>
<pre><code>sage: b = B.theta_series( 1000 )
sage: m = ModularForms( Gamma1(3), 1, prec=20 ).0
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: m.coefficients( 1000 )[:20] # !first coeff is not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: b.polynomial().coeffs()[:20]
[1, 6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12]
sage: m.coefficients(1000)[:20] # !first coefficient, the starting one, not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.polynomial().coeffs()[1:20] == m.coefficients(1000)[:19]
True
sage: b.polynomial().coeffs()[1:1000] == m.coefficients(1000)[:999]
True
</code></pre>
<p>I hope we are both at home now, know which maths object is which sage object.</p>
http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38431#post-id-38431@dan_fulea - I didn't realize you didn't have a Trac account. See http://doc.sagemath.org/html/en/developer/trac.html#section-trac-account to get started (there may be a delay in creation). We welcome this contribution - even a typo fix is great!Fri, 28 Jul 2017 22:04:49 -0500http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38431#post-id-38431Comment by dan_fulea for <p>Please let me answer using an epic style, since it reflects my experience with these objects. </p>
<p>Let $A$ be the quadratic form from the above post...</p>
<pre><code>sage: A = QuadraticForm( QQ, 2, [2, -1, 2] )
sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
</code></pre>
<p>A longer time i thought this is the quadratic form corresponding to the symmetrically extended matrix with those entries, i.e. to...</p>
<pre><code>sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
</code></pre>
<p>since what else should be the star?! ...till i got an error, then searching for it was typing something like...</p>
<pre><code>sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
sage: A.matrix() # oh, there is a matrix method!
[ 4 -1]
[-1 4]
sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
sage: v = vector( [100, 10] )
sage: A(v)
19200
sage: 2 * 100^2 - 2*100*10 + 10^2
18100
sage: 2 * 100^2 - 100*10 + 10^2
19100
sage: ( v * A.matrix() * v.column() ) / 2
(19200)
sage: ( v * MA * v.column() ) / 2
(9100)
sage: ( v * MA * v.column() )
(18200)
</code></pre>
<p>And the quadratic form <code>A</code> is not quite reflected by the symmetic matrix <code>MA</code>. What is going on here?
I think, the answer to the question is already here, despite of the fact that there is only one more question...</p>
<p>In the given posted situation with the <code>Q</code>, i suspect the quadratic form written for the above matrix <code>MA</code> instead is needed / intended, the one which maps the vector $x$ with components $s,t$ to
$$ q_A(x)=\frac 12\langle x,x\rangle_A =\frac 12(2s^2-2st+t^2) = x^2-xy+y^2\ . $$</p>
<p>Since the expected theta series is an other one, let us consider "the other quadratic form", and the theta series associated to it...</p>
<pre><code>sage: B = QuadraticForm( QQ, 2, [1, -1, 1] )
sage: B
Quadratic form in 2 variables over Rational Field with coefficients:
[ 1 -1 ]
[ * 1 ]
sage: B.theta_series( 20 )
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>...is in agreement with </p>
<pre><code>sage: ModularForms( Gamma1(3), 1, prec=20 ).0
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>and in fact the first $1000$ coefficients do coincide... For this we may try successively to get them (right):</p>
<pre><code>sage: b = B.theta_series( 1000 )
sage: m = ModularForms( Gamma1(3), 1, prec=20 ).0
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: m.coefficients( 1000 )[:20] # !first coeff is not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: b.polynomial().coeffs()[:20]
[1, 6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12]
sage: m.coefficients(1000)[:20] # !first coefficient, the starting one, not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.polynomial().coeffs()[1:20] == m.coefficients(1000)[:19]
True
sage: b.polynomial().coeffs()[1:1000] == m.coefficients(1000)[:999]
True
</code></pre>
<p>I hope we are both at home now, know which maths object is which sage object.</p>
http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38425#post-id-38425I am rather new in the sage community, how can i do this? (Open a ticket, implement - in this case rather only add documentation in the doc string of some modules, some examples for instance, then commit changes, etc.) Is there a page or a mailing list i could subscribe to?! Thanks!Fri, 28 Jul 2017 11:52:09 -0500http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38425#post-id-38425Comment by kcrisman for <p>Please let me answer using an epic style, since it reflects my experience with these objects. </p>
<p>Let $A$ be the quadratic form from the above post...</p>
<pre><code>sage: A = QuadraticForm( QQ, 2, [2, -1, 2] )
sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
</code></pre>
<p>A longer time i thought this is the quadratic form corresponding to the symmetrically extended matrix with those entries, i.e. to...</p>
<pre><code>sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
</code></pre>
<p>since what else should be the star?! ...till i got an error, then searching for it was typing something like...</p>
<pre><code>sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
sage: A.matrix() # oh, there is a matrix method!
[ 4 -1]
[-1 4]
sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
sage: v = vector( [100, 10] )
sage: A(v)
19200
sage: 2 * 100^2 - 2*100*10 + 10^2
18100
sage: 2 * 100^2 - 100*10 + 10^2
19100
sage: ( v * A.matrix() * v.column() ) / 2
(19200)
sage: ( v * MA * v.column() ) / 2
(9100)
sage: ( v * MA * v.column() )
(18200)
</code></pre>
<p>And the quadratic form <code>A</code> is not quite reflected by the symmetic matrix <code>MA</code>. What is going on here?
I think, the answer to the question is already here, despite of the fact that there is only one more question...</p>
<p>In the given posted situation with the <code>Q</code>, i suspect the quadratic form written for the above matrix <code>MA</code> instead is needed / intended, the one which maps the vector $x$ with components $s,t$ to
$$ q_A(x)=\frac 12\langle x,x\rangle_A =\frac 12(2s^2-2st+t^2) = x^2-xy+y^2\ . $$</p>
<p>Since the expected theta series is an other one, let us consider "the other quadratic form", and the theta series associated to it...</p>
<pre><code>sage: B = QuadraticForm( QQ, 2, [1, -1, 1] )
sage: B
Quadratic form in 2 variables over Rational Field with coefficients:
[ 1 -1 ]
[ * 1 ]
sage: B.theta_series( 20 )
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>...is in agreement with </p>
<pre><code>sage: ModularForms( Gamma1(3), 1, prec=20 ).0
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>and in fact the first $1000$ coefficients do coincide... For this we may try successively to get them (right):</p>
<pre><code>sage: b = B.theta_series( 1000 )
sage: m = ModularForms( Gamma1(3), 1, prec=20 ).0
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: m.coefficients( 1000 )[:20] # !first coeff is not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: b.polynomial().coeffs()[:20]
[1, 6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12]
sage: m.coefficients(1000)[:20] # !first coefficient, the starting one, not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.polynomial().coeffs()[1:20] == m.coefficients(1000)[:19]
True
sage: b.polynomial().coeffs()[1:1000] == m.coefficients(1000)[:999]
True
</code></pre>
<p>I hope we are both at home now, know which maths object is which sage object.</p>
http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38082#post-id-38082@dan_fulea, can you open a ticket since you understand this better?Sat, 24 Jun 2017 09:30:12 -0500http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38082#post-id-38082Comment by Marcel for <p>Please let me answer using an epic style, since it reflects my experience with these objects. </p>
<p>Let $A$ be the quadratic form from the above post...</p>
<pre><code>sage: A = QuadraticForm( QQ, 2, [2, -1, 2] )
sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
</code></pre>
<p>A longer time i thought this is the quadratic form corresponding to the symmetrically extended matrix with those entries, i.e. to...</p>
<pre><code>sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
</code></pre>
<p>since what else should be the star?! ...till i got an error, then searching for it was typing something like...</p>
<pre><code>sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
sage: A.matrix() # oh, there is a matrix method!
[ 4 -1]
[-1 4]
sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
sage: v = vector( [100, 10] )
sage: A(v)
19200
sage: 2 * 100^2 - 2*100*10 + 10^2
18100
sage: 2 * 100^2 - 100*10 + 10^2
19100
sage: ( v * A.matrix() * v.column() ) / 2
(19200)
sage: ( v * MA * v.column() ) / 2
(9100)
sage: ( v * MA * v.column() )
(18200)
</code></pre>
<p>And the quadratic form <code>A</code> is not quite reflected by the symmetic matrix <code>MA</code>. What is going on here?
I think, the answer to the question is already here, despite of the fact that there is only one more question...</p>
<p>In the given posted situation with the <code>Q</code>, i suspect the quadratic form written for the above matrix <code>MA</code> instead is needed / intended, the one which maps the vector $x$ with components $s,t$ to
$$ q_A(x)=\frac 12\langle x,x\rangle_A =\frac 12(2s^2-2st+t^2) = x^2-xy+y^2\ . $$</p>
<p>Since the expected theta series is an other one, let us consider "the other quadratic form", and the theta series associated to it...</p>
<pre><code>sage: B = QuadraticForm( QQ, 2, [1, -1, 1] )
sage: B
Quadratic form in 2 variables over Rational Field with coefficients:
[ 1 -1 ]
[ * 1 ]
sage: B.theta_series( 20 )
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>...is in agreement with </p>
<pre><code>sage: ModularForms( Gamma1(3), 1, prec=20 ).0
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>and in fact the first $1000$ coefficients do coincide... For this we may try successively to get them (right):</p>
<pre><code>sage: b = B.theta_series( 1000 )
sage: m = ModularForms( Gamma1(3), 1, prec=20 ).0
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: m.coefficients( 1000 )[:20] # !first coeff is not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: b.polynomial().coeffs()[:20]
[1, 6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12]
sage: m.coefficients(1000)[:20] # !first coefficient, the starting one, not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.polynomial().coeffs()[1:20] == m.coefficients(1000)[:19]
True
sage: b.polynomial().coeffs()[1:1000] == m.coefficients(1000)[:999]
True
</code></pre>
<p>I hope we are both at home now, know which maths object is which sage object.</p>
http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38073#post-id-38073Thanks a lot. I figured this in the meanwhile and wrote my own answer which i guess needed moderating. I definitely think the documentation should be updated. Or an example like $A_2$ should be given.Fri, 23 Jun 2017 18:19:12 -0500http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38073#post-id-38073Comment by dan_fulea for <p>Please let me answer using an epic style, since it reflects my experience with these objects. </p>
<p>Let $A$ be the quadratic form from the above post...</p>
<pre><code>sage: A = QuadraticForm( QQ, 2, [2, -1, 2] )
sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
</code></pre>
<p>A longer time i thought this is the quadratic form corresponding to the symmetrically extended matrix with those entries, i.e. to...</p>
<pre><code>sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
</code></pre>
<p>since what else should be the star?! ...till i got an error, then searching for it was typing something like...</p>
<pre><code>sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
sage: A.matrix() # oh, there is a matrix method!
[ 4 -1]
[-1 4]
sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
sage: v = vector( [100, 10] )
sage: A(v)
19200
sage: 2 * 100^2 - 2*100*10 + 10^2
18100
sage: 2 * 100^2 - 100*10 + 10^2
19100
sage: ( v * A.matrix() * v.column() ) / 2
(19200)
sage: ( v * MA * v.column() ) / 2
(9100)
sage: ( v * MA * v.column() )
(18200)
</code></pre>
<p>And the quadratic form <code>A</code> is not quite reflected by the symmetic matrix <code>MA</code>. What is going on here?
I think, the answer to the question is already here, despite of the fact that there is only one more question...</p>
<p>In the given posted situation with the <code>Q</code>, i suspect the quadratic form written for the above matrix <code>MA</code> instead is needed / intended, the one which maps the vector $x$ with components $s,t$ to
$$ q_A(x)=\frac 12\langle x,x\rangle_A =\frac 12(2s^2-2st+t^2) = x^2-xy+y^2\ . $$</p>
<p>Since the expected theta series is an other one, let us consider "the other quadratic form", and the theta series associated to it...</p>
<pre><code>sage: B = QuadraticForm( QQ, 2, [1, -1, 1] )
sage: B
Quadratic form in 2 variables over Rational Field with coefficients:
[ 1 -1 ]
[ * 1 ]
sage: B.theta_series( 20 )
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>...is in agreement with </p>
<pre><code>sage: ModularForms( Gamma1(3), 1, prec=20 ).0
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>and in fact the first $1000$ coefficients do coincide... For this we may try successively to get them (right):</p>
<pre><code>sage: b = B.theta_series( 1000 )
sage: m = ModularForms( Gamma1(3), 1, prec=20 ).0
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: m.coefficients( 1000 )[:20] # !first coeff is not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: b.polynomial().coeffs()[:20]
[1, 6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12]
sage: m.coefficients(1000)[:20] # !first coefficient, the starting one, not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.polynomial().coeffs()[1:20] == m.coefficients(1000)[:19]
True
sage: b.polynomial().coeffs()[1:1000] == m.coefficients(1000)[:999]
True
</code></pre>
<p>I hope we are both at home now, know which maths object is which sage object.</p>
http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38069#post-id-38069The present documentation is strong enough. But because many people in all ages, countries, and target fields are using the software, some of them will always be confused at some point.
In this case, one could for instance...
- set a 0 instead of each subdiagonal star in the print (in the __str__ or __repr__ method) of the quadratic form
- or even better mention its discriminant in it,
- give some examples at the top of the doc that eliminates this misleading point... (In my course, immediately after introducing a quadratic form, the matrix for it was defined and assumed to be symmetric. There was no discussion about how to initialize it best in a software. And so it is on my own HD.)
- and also give some examples (with a special count in low degrees) for the `theta_series` method.Fri, 23 Jun 2017 16:45:36 -0500http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38069#post-id-38069Comment by kcrisman for <p>Please let me answer using an epic style, since it reflects my experience with these objects. </p>
<p>Let $A$ be the quadratic form from the above post...</p>
<pre><code>sage: A = QuadraticForm( QQ, 2, [2, -1, 2] )
sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
</code></pre>
<p>A longer time i thought this is the quadratic form corresponding to the symmetrically extended matrix with those entries, i.e. to...</p>
<pre><code>sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
</code></pre>
<p>since what else should be the star?! ...till i got an error, then searching for it was typing something like...</p>
<pre><code>sage: A
Quadratic form in 2 variables over Rational Field with coefficients:
[ 2 -1 ]
[ * 2 ]
sage: A.matrix() # oh, there is a matrix method!
[ 4 -1]
[-1 4]
sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1 2]
sage: v = vector( [100, 10] )
sage: A(v)
19200
sage: 2 * 100^2 - 2*100*10 + 10^2
18100
sage: 2 * 100^2 - 100*10 + 10^2
19100
sage: ( v * A.matrix() * v.column() ) / 2
(19200)
sage: ( v * MA * v.column() ) / 2
(9100)
sage: ( v * MA * v.column() )
(18200)
</code></pre>
<p>And the quadratic form <code>A</code> is not quite reflected by the symmetic matrix <code>MA</code>. What is going on here?
I think, the answer to the question is already here, despite of the fact that there is only one more question...</p>
<p>In the given posted situation with the <code>Q</code>, i suspect the quadratic form written for the above matrix <code>MA</code> instead is needed / intended, the one which maps the vector $x$ with components $s,t$ to
$$ q_A(x)=\frac 12\langle x,x\rangle_A =\frac 12(2s^2-2st+t^2) = x^2-xy+y^2\ . $$</p>
<p>Since the expected theta series is an other one, let us consider "the other quadratic form", and the theta series associated to it...</p>
<pre><code>sage: B = QuadraticForm( QQ, 2, [1, -1, 1] )
sage: B
Quadratic form in 2 variables over Rational Field with coefficients:
[ 1 -1 ]
[ * 1 ]
sage: B.theta_series( 20 )
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>...is in agreement with </p>
<pre><code>sage: ModularForms( Gamma1(3), 1, prec=20 ).0
1 + 6*q + 6*q^3 + 6*q^4 + 12*q^7 + 6*q^9 + 6*q^12 + 12*q^13 + 6*q^16 + 12*q^19 + O(q^20)
</code></pre>
<p>and in fact the first $1000$ coefficients do coincide... For this we may try successively to get them (right):</p>
<pre><code>sage: b = B.theta_series( 1000 )
sage: m = ModularForms( Gamma1(3), 1, prec=20 ).0
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: m.coefficients( 1000 )[:20] # !first coeff is not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.coefficients()[:20] # !only non zero coefficients shown
[1, 6, 6, 6, 12, 6, 6, 12, 6, 12, 12, 6, 6, 12, 12, 6, 12, 12, 12, 6]
sage: b.polynomial().coeffs()[:20]
[1, 6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12]
sage: m.coefficients(1000)[:20] # !first coefficient, the starting one, not shown
[6, 0, 6, 6, 0, 0, 12, 0, 6, 0, 0, 6, 12, 0, 0, 6, 0, 0, 12, 0]
sage: b.polynomial().coeffs()[1:20] == m.coefficients(1000)[:19]
True
sage: b.polynomial().coeffs()[1:1000] == m.coefficients(1000)[:999]
True
</code></pre>
<p>I hope we are both at home now, know which maths object is which sage object.</p>
http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38062#post-id-38062Very interesting. Do you think that the documentation for `QuadraticForm` needs updating to make all this clearer?Thu, 22 Jun 2017 21:41:18 -0500http://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/?comment=38062#post-id-38062