Base of Eigenforms

I am beginning to learn SAGE. I have been working on a project that requires me to have an (orthogonal) eigenbasis for $S_2^{\text{new}}(\Gamma_0(N))$. Is there an easy way to get that?

I think I can use CuspForms(Gamma0(N),2).new_submodule().hecke_matrix(p) (for many primes) with some linear algebra to, after some effort, build an eigenbasis. But since this is something basic in the theory of modular forms, I thought it would be already implemented in SAGE (but I could not find it). Is that so?

edit:----

Thank you very much for the answers below, I am about to accept them. However, I have been trying to use those commands and encountered some issues. In some cases, they don't seem to give me a complete basis. I am trying to understand why. For example, for N=89, k=2

sage: S_new = CuspForms(89,2).new_submodule()
sage: S_new.dimension()
7
sage: Newforms(89,names='a')
[q - q^2 - q^3 - q^4 - q^5 + O(q^6),
q + q^2 + 2*q^3 - q^4 - 2*q^5 + O(q^6),
q + a2*q^2 + (-1/2*a2^4 + 1/2*a2^3 + 7/2*a2^2 - 5/2*a2 - 4)*q^3 + (a2^2 - 2)*q^4 + (-a2^2 + 4)*q^5 + O(q^6)]


Why does it not calculate the remaining eigenforms in this case? Is it because the coefficient fields are too complicated? LMFDB says one of them has degree 140 https://www.lmfdb.org/ModularForm/GL2...

Using Cremona's answer with d.q_eigenform(50,names='a') yields the same.

I see that I can change the base field to $\overline{\mathbb{Q}}$ to get the full collection:

sage: Newforms(89,names='a',base_ring=QQbar)
[q - 2.47725271?*q^2 - 2.759353854?*q^3 + 4.1367810?*q^4 - 2.13678098?*q^5 + O(q^6),
q - 2.098127745?*q^2 + 2.3452649700?*q^3 + 2.402140034?*q^4 - 0.402140035?*q^5 + O(q^6),
q - q^2 - q^3 - q^4 - q^5 + O(q^6),
q - 0.74595374?*q^2 - 0.54990973?*q^3 - 1.44355303?*q^4 + 3.44355303?*q^5 + O(q^6),
q + 1.00000000000000?*q^2 + 2.00000000000000?*q^3 - 1.00000000000000?*q^4 - 2.00000000000000?*q^5 + O(q^6),
q + 1.62790662528?*q^2 - 0.14890720385?*q^3 + 0.6500799807?*q^4 + 1.34992001936?*q^5 + O(q^6),
q + 2.693427562?*q^2 - 1.8870941866?*q^3 + 5.254552031?*q^4 - 3.254552031?*q^5 + O(q^6)]


But then I have to work with these approximations and lose some information. For example, I cannot recover the Hecke eigenvalue fields from these forms.

I think one solution would be to compute the eigenvalues of the Hecke matrixes (say, for the rational basis that SAGE gives me via CuspForms(89,2).basis()). And then try to recover the coefficient fields from them. To finally use Newforms(89,names='a',base_ring=K) with K being the compositum of coefficient fields. The problem is that it takes too long in cases like this one.

I am wondering if that is all that I can do in this case? Or maybe there is a better way to use those commands, to avoids these issues?

edit retag close merge delete

1

(2) As you can see in the documentation, the "Newforms" command returns one from each Galois orbit of newforms. In the first of your added examples, q + a2*q^2 + (-1/2*a2^4 +, the number field generated by $a_2$ can be embedded into CC in 5 different ways and these fill up the space.

(3) Sage's QQbar class does not lose information via inexact approximations. QQbar is not CC. Internally, an element of QQbar consists of a polynomial with Q coefficients, together with intervals (with exact, rational endpoints) containing the real and imaginary parts of a unique root of that polynomial.

( 2021-05-05 09:50:28 +0200 )edit

Example to show you can recover exact values:

sage: f = Newforms(89,names='a',base_ring=QQbar)[-1]

sage: f[2].as_number_field_element()

(Number Field in a with defining polynomial y^5 - 2*y^4 - 6*y^3 + 4*y^2 + 4*y - 2,
-a^4 + 2*a^3 + 5*a^2 - 2*a - 1,
...)

( 2021-05-05 09:52:53 +0200 )edit

@David Loeffler. Thank you very much! Your comment was incredibly helpful, now I understand how I have to use Newforms.

My apologies about editing the post with the example. This was my first question here, and I didn't know editing like that was bad manners. Thank you for letting me know.

Would it be better if I edit it again to revert it to its original state? And make that example into a comment?

( 2021-05-05 17:44:26 +0200 )edit

Sort by » oldest newest most voted

John Cremona's solution will work, but you can get to the answer a little more quickly as follows:

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.2, Release Date: 2020-10-24                     │
│ Using Python 3.8.5. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
sage: N = 120
sage: Newforms(N)
[q + q^3 - q^5 + O(q^6), q + q^3 + q^5 + O(q^6)]


The weight defaults to 2, but you can ask for larger weights with Newforms(2, weight=6) etc. If there isn't a basis of newforms with coefficients in QQ, which happens most of the time for larger weights and levels, you need to give it a name to use for the coefficient fields:

sage: Newforms(1000,names='a')
[q + a0*q^3 + O(q^6),
q - a1*q^3 + O(q^6),
q + a2*q^3 + O(q^6),
q - 1/2*a3*q^3 + O(q^6),
q + a4*q^3 + O(q^6),
q + a5*q^3 + O(q^6),
q + a6*q^3 + O(q^6),
q - a7*q^3 + O(q^6)]
sage: f = _[0]; f.hecke_eigenvalue_field()
Number Field in a0 with defining polynomial x^2 + x - 1


(Exercise for the reader: why do all of these forms have no $q^2$ term?)

more

Thank you for this answer!! It is exactly what I needed. However, in some cases, it doesn't give me the complete eigenbasis. Do you know why? I edited the post with an example.

( 2021-05-05 02:17:56 +0200 )edit

Thanks David for improvng my rather hasty asnwer and for clearing up the follow-up questions.

( 2021-05-05 18:20:37 +0200 )edit

The solution is to use modular symbols:

sage: N=120
sage: S=ModularSymbols(N,2,+1)
sage: NS=S.new_submodule()
sage: CNS=NS.cuspidal_submodule()
sage: D=CNS.decomposition()
sage: D
[
Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 32 for Gamma_0(120) of weight 2 with sign 1 over Rational Field,
Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 32 for Gamma_0(120) of weight 2 with sign 1 over Rational Field
]
sage: [d.q_eigenform(50) for d in D]
[q + q^3 - q^5 + 4*q^7 + q^9 - 6*q^13 - q^15 - 2*q^17 + 4*q^19 + 4*q^21 - 8*q^23 + q^25 + q^27 - 6*q^29 - 4*q^35 - 6*q^37 - 6*q^39 + 10*q^41 - 4*q^43 - q^45 + 8*q^47 + 9*q^49 + O(q^50),
q + q^3 + q^5 + q^9 - 4*q^11 + 6*q^13 + q^15 - 6*q^17 - 4*q^19 + q^25 + q^27 - 2*q^29 - 8*q^31 - 4*q^33 - 2*q^37 + 6*q^39 - 6*q^41 + 12*q^43 + q^45 + 8*q^47 - 7*q^49 + O(q^50)]


You can also see this space (weight 2, level 120, trivial character) on the LMFDB at http://www.lmfdb.org/ModularForm/GL2/... and then go to each newform's home page, e.g. http://www.lmfdb.org/ModularForm/GL2/...

more

Thank you for this answer!! It is exactly what I needed. However, in some cases, it doesn't give me the complete eigenbasis. Do you know why? I edited the post with an example.

( 2021-05-05 02:12:43 +0200 )edit