Revision history [back]

Please 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 symmetric(ally extension of the) matrix with those entries

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()
[ 4 -1]
[-1  4]
sage: MA = matrix( QQ, 2, 2, [ 2, -1, -1, 2] )
sage: MA
[ 2 -1]
[-1  2]
sage:
sage:
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)


In the given posted situation with the Q, i suspect the quadratic form written for the above matrix MA instead is needed, 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)


This 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.

Please 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 symmetric(ally extension of the) symmetrically extended matrix with those entriesentries, 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()
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:
sage:
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.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, 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)


This is ...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.