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.Wed, 05 May 2021 18:20:37 +0200Base of Eigenformshttps://ask.sagemath.org/question/56896/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/Q/holomorphic/?level=89&weight=2&search_type=List
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?Sun, 02 May 2021 01:34:16 +0200https://ask.sagemath.org/question/56896/base-of-eigenforms/Comment by Mathomancer for <p>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?</p>
<p>I think I can use <code>CuspForms(Gamma0(N),2).new_submodule().hecke_matrix(p)</code> (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?</p>
<p>edit:----</p>
<p>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</p>
<pre><code>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)]
</code></pre>
<p>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 <a href="https://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/?level=89&weight=2&search_type=List">https://www.lmfdb.org/ModularForm/GL2...</a></p>
<p>Using Cremona's answer with <code>d.q_eigenform(50,names='a')</code> yields the same.</p>
<p>I see that I can change the base field to $\overline{\mathbb{Q}}$ to get the full collection:</p>
<pre><code>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)]
</code></pre>
<p>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.</p>
<p>I think one solution would be to compute the eigenvalues of the Hecke matrixes (say, for the rational basis that SAGE gives me via <code>CuspForms(89,2).basis()</code>). And then try to recover the coefficient fields from them. To finally use <code>Newforms(89,names='a',base_ring=K)</code> with K being the compositum of coefficient fields. The problem is that it takes too long in cases like this one.</p>
<p>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?</p>
https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56978#post-id-56978@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?Wed, 05 May 2021 17:44:26 +0200https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56978#post-id-56978Comment by David Loeffler for <p>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?</p>
<p>I think I can use <code>CuspForms(Gamma0(N),2).new_submodule().hecke_matrix(p)</code> (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?</p>
<p>edit:----</p>
<p>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</p>
<pre><code>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)]
</code></pre>
<p>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 <a href="https://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/?level=89&weight=2&search_type=List">https://www.lmfdb.org/ModularForm/GL2...</a></p>
<p>Using Cremona's answer with <code>d.q_eigenform(50,names='a')</code> yields the same.</p>
<p>I see that I can change the base field to $\overline{\mathbb{Q}}$ to get the full collection:</p>
<pre><code>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)]
</code></pre>
<p>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.</p>
<p>I think one solution would be to compute the eigenvalues of the Hecke matrixes (say, for the rational basis that SAGE gives me via <code>CuspForms(89,2).basis()</code>). And then try to recover the coefficient fields from them. To finally use <code>Newforms(89,names='a',base_ring=K)</code> with K being the compositum of coefficient fields. The problem is that it takes too long in cases like this one.</p>
<p>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?</p>
https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56966#post-id-56966Example 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,
...)Wed, 05 May 2021 09:52:53 +0200https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56966#post-id-56966Comment by David Loeffler for <p>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?</p>
<p>I think I can use <code>CuspForms(Gamma0(N),2).new_submodule().hecke_matrix(p)</code> (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?</p>
<p>edit:----</p>
<p>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</p>
<pre><code>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)]
</code></pre>
<p>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 <a href="https://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/?level=89&weight=2&search_type=List">https://www.lmfdb.org/ModularForm/GL2...</a></p>
<p>Using Cremona's answer with <code>d.q_eigenform(50,names='a')</code> yields the same.</p>
<p>I see that I can change the base field to $\overline{\mathbb{Q}}$ to get the full collection:</p>
<pre><code>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)]
</code></pre>
<p>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.</p>
<p>I think one solution would be to compute the eigenvalues of the Hecke matrixes (say, for the rational basis that SAGE gives me via <code>CuspForms(89,2).basis()</code>). And then try to recover the coefficient fields from them. To finally use <code>Newforms(89,names='a',base_ring=K)</code> with K being the compositum of coefficient fields. The problem is that it takes too long in cases like this one.</p>
<p>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?</p>
https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56965#post-id-56965Three comments on your edited question:
(1) It's considered rather bad manners to edit a question after it's been answered.
(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.Wed, 05 May 2021 09:50:28 +0200https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56965#post-id-56965Answer by David Loeffler for <p>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?</p>
<p>I think I can use <code>CuspForms(Gamma0(N),2).new_submodule().hecke_matrix(p)</code> (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?</p>
<p>edit:----</p>
<p>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</p>
<pre><code>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)]
</code></pre>
<p>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 <a href="https://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/?level=89&weight=2&search_type=List">https://www.lmfdb.org/ModularForm/GL2...</a></p>
<p>Using Cremona's answer with <code>d.q_eigenform(50,names='a')</code> yields the same.</p>
<p>I see that I can change the base field to $\overline{\mathbb{Q}}$ to get the full collection:</p>
<pre><code>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)]
</code></pre>
<p>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.</p>
<p>I think one solution would be to compute the eigenvalues of the Hecke matrixes (say, for the rational basis that SAGE gives me via <code>CuspForms(89,2).basis()</code>). And then try to recover the coefficient fields from them. To finally use <code>Newforms(89,names='a',base_ring=K)</code> with K being the compositum of coefficient fields. The problem is that it takes too long in cases like this one.</p>
<p>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?</p>
https://ask.sagemath.org/question/56896/base-of-eigenforms/?answer=56920#post-id-56920John 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?)Mon, 03 May 2021 13:56:24 +0200https://ask.sagemath.org/question/56896/base-of-eigenforms/?answer=56920#post-id-56920Comment by John Cremona for <p>John Cremona's solution will work, but you can get to the answer a little more quickly as follows:</p>
<pre><code>┌────────────────────────────────────────────────────────────────────┐
│ 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)]
</code></pre>
<p>The weight defaults to 2, but you can ask for larger weights with <code>Newforms(2, weight=6)</code> 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:</p>
<pre><code>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
</code></pre>
<p>(Exercise for the reader: why do all of these forms have no $q^2$ term?)</p>
https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56979#post-id-56979Thanks David for improvng my rather hasty asnwer and for clearing up the follow-up questions.Wed, 05 May 2021 18:20:37 +0200https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56979#post-id-56979Comment by Mathomancer for <p>John Cremona's solution will work, but you can get to the answer a little more quickly as follows:</p>
<pre><code>┌────────────────────────────────────────────────────────────────────┐
│ 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)]
</code></pre>
<p>The weight defaults to 2, but you can ask for larger weights with <code>Newforms(2, weight=6)</code> 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:</p>
<pre><code>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
</code></pre>
<p>(Exercise for the reader: why do all of these forms have no $q^2$ term?)</p>
https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56960#post-id-56960Thank 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.Wed, 05 May 2021 02:17:56 +0200https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56960#post-id-56960Answer by John Cremona for <p>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?</p>
<p>I think I can use <code>CuspForms(Gamma0(N),2).new_submodule().hecke_matrix(p)</code> (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?</p>
<p>edit:----</p>
<p>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</p>
<pre><code>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)]
</code></pre>
<p>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 <a href="https://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/?level=89&weight=2&search_type=List">https://www.lmfdb.org/ModularForm/GL2...</a></p>
<p>Using Cremona's answer with <code>d.q_eigenform(50,names='a')</code> yields the same.</p>
<p>I see that I can change the base field to $\overline{\mathbb{Q}}$ to get the full collection:</p>
<pre><code>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)]
</code></pre>
<p>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.</p>
<p>I think one solution would be to compute the eigenvalues of the Hecke matrixes (say, for the rational basis that SAGE gives me via <code>CuspForms(89,2).basis()</code>). And then try to recover the coefficient fields from them. To finally use <code>Newforms(89,names='a',base_ring=K)</code> with K being the compositum of coefficient fields. The problem is that it takes too long in cases like this one.</p>
<p>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?</p>
https://ask.sagemath.org/question/56896/base-of-eigenforms/?answer=56916#post-id-56916The 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)]
Sorry about bad formatting.
You can also see this space (weight 2, level 120, trivial character) on the LMFDB at http://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/?level=120&weight=2&char_order=1&search_type=List
and then go to each newform's home page, e.g. http://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/120/2/a/a/Mon, 03 May 2021 10:05:14 +0200https://ask.sagemath.org/question/56896/base-of-eigenforms/?answer=56916#post-id-56916Comment by Mathomancer for <p>The solution is to use modular symbols:</p>
<pre><code>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)]
</code></pre>
<p>Sorry about bad formatting.</p>
<p>You can also see this space (weight 2, level 120, trivial character) on the LMFDB at <a href="http://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/?level=120&weight=2&char_order=1&search_type=List">http://www.lmfdb.org/ModularForm/GL2/...</a>
and then go to each newform's home page, e.g. <a href="http://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/120/2/a/a/">http://www.lmfdb.org/ModularForm/GL2/...</a></p>
https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56959#post-id-56959Thank 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.Wed, 05 May 2021 02:12:43 +0200https://ask.sagemath.org/question/56896/base-of-eigenforms/?comment=56959#post-id-56959