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, 22 Apr 2020 17:49:50 +0200How to do arithmetic with a basis element from modular forms spacehttps://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/Hi, I'm new to Sage and coding in general. I want to look at the 1-dim'l space CuspForms(Gamma0(7), 3) but with character. Here's my code for that
S = G = DirichletGroup(7, QQ)
list(G)
G.gens()
e = G.0
S = CuspForms(e, 3, prec=20)
print(S)
print(Gamma0(7).cusps())
print(S.basis())
g = S.0
Here, g is the only basis element for S. I want to do `F = g*(L+4)` where L is some eta-quotient of level 7. However, I get a long error with `'NoneType' object is not iterable` at the end. So I'm thinking I need to define g in a different way, since it seems to be that g is not a q-series type object the way I've defined it?Mon, 23 Mar 2020 18:36:44 +0100https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/Comment by vdelecroix for <p>Hi, I'm new to Sage and coding in general. I want to look at the 1-dim'l space CuspForms(Gamma0(7), 3) but with character. Here's my code for that</p>
<pre><code>S = G = DirichletGroup(7, QQ)
list(G)
G.gens()
e = G.0
S = CuspForms(e, 3, prec=20)
print(S)
print(Gamma0(7).cusps())
print(S.basis())
g = S.0
</code></pre>
<p>Here, g is the only basis element for S. I want to do <code>F = g*(L+4)</code> where L is some eta-quotient of level 7. However, I get a long error with <code>'NoneType' object is not iterable</code> at the end. So I'm thinking I need to define g in a different way, since it seems to be that g is not a q-series type object the way I've defined it?</p>
https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50338#post-id-50338It would be helpful to have the complete code you used to produce `L` as well...Tue, 24 Mar 2020 20:07:11 +0100https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50338#post-id-50338Comment by FundamentalDomain for <p>Hi, I'm new to Sage and coding in general. I want to look at the 1-dim'l space CuspForms(Gamma0(7), 3) but with character. Here's my code for that</p>
<pre><code>S = G = DirichletGroup(7, QQ)
list(G)
G.gens()
e = G.0
S = CuspForms(e, 3, prec=20)
print(S)
print(Gamma0(7).cusps())
print(S.basis())
g = S.0
</code></pre>
<p>Here, g is the only basis element for S. I want to do <code>F = g*(L+4)</code> where L is some eta-quotient of level 7. However, I get a long error with <code>'NoneType' object is not iterable</code> at the end. So I'm thinking I need to define g in a different way, since it seems to be that g is not a q-series type object the way I've defined it?</p>
https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50355#post-id-50355Yes, sorry. It's `L = EtaProduct(7, {1:4, 7:-4})`. I also mixed up the level on accident but edited to fix. It's 7.Wed, 25 Mar 2020 16:19:19 +0100https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50355#post-id-50355Answer by dan_fulea for <p>Hi, I'm new to Sage and coding in general. I want to look at the 1-dim'l space CuspForms(Gamma0(7), 3) but with character. Here's my code for that</p>
<pre><code>S = G = DirichletGroup(7, QQ)
list(G)
G.gens()
e = G.0
S = CuspForms(e, 3, prec=20)
print(S)
print(Gamma0(7).cusps())
print(S.basis())
g = S.0
</code></pre>
<p>Here, g is the only basis element for S. I want to do <code>F = g*(L+4)</code> where L is some eta-quotient of level 7. However, I get a long error with <code>'NoneType' object is not iterable</code> at the end. So I'm thinking I need to define g in a different way, since it seems to be that g is not a q-series type object the way I've defined it?</p>
https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?answer=50918#post-id-50918The answer of FrédéricC is already wonderful, here is maybe a way to make your own way in the next similar situation.
First of all, let us consider the code:
G = DirichletGroup(7, QQ)
S = CuspForms(e, 3, prec=20)
g = S.gens()[0]
print( f"g = {g}" )
R = g.qexp().parent()
print( f"R = {R}\nIts default precision is {R.default_prec()}" )
q = R.gen()
L = EtaProduct(7, {1:4, 7:-4})
print( f"L = {L}" )
The above gives
g = q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
R = Power Series Ring in q over Rational Field
Its default precision is 20
L = Eta product of level 7 : (eta_1)^4 (eta_7)^-4
Now i noted that the method `L.qexp` needs an argument. At least for me in my version. This can be seen / asked in the ipython interpreter for sage as follows...
sage: L.qexp?
Signature: L.qexp(n)
Docstring:
Alias for "self.q_expansion()".
EXAMPLES:
sage: e = EtaProduct(36, {6:8, 3:-8})
sage: e.qexp(10)
q + 8*q^4 + 36*q^7 + O(q^10)
sage: e.qexp(30) == e.q_expansion(30)
True
Init docstring: Initialize self. See help(type(self)) for accurate signature.
File: /usr/lib/python3.8/site-packages/sage/modular/etaproducts.py
Type: method
sage:
and the above `L.qexp` goes to the doc string of the method `qexp` in the class `L` is an instance for:
sage: L.__class__
<class 'sage.modular.etaproducts.EtaGroupElement'>
So we really need an argument for it in my version.
sage: version()
'SageMath version 9.0, Release Date: 2020-01-01'
In my case `L.qexp()` produces an error, since one argument is needed, but this is easily corrected, `L.exp(20)` would be ok. Since the precision of the series for $g$ is $20$, we should use the same precision... Well:
sage: L.qexp(20)
q^-1 - 4 + 2*q + 8*q^2 - 5*q^3 - 4*q^4 - 10*q^5 + 12*q^6 - 7*q^7 + 8*q^8 + 46*q^9 - 36*q^10 - 26*q^11 - 44*q^12 + 46*q^13 - 28*q^14 + 42*q^15 + 188*q^16 - 132*q^17 - 96*q^18 + O(q^19)
sage: g.qexp()
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
and the series are stopping at the "multiplicative precision" equal to $20$. For $L$ we have an expression modulo $O(q^{19})$ (since it starts with $1/q$), for $g$ we have an expression modulo $O(q^{20})$ . This situation may lead to losing the initial precision.
Now i tried:
- `g + O(q^6)`, but it fails. (Although `fL + O(q^6)` works.)
- `g * fL`, but it fails. (Although `g(q) * fL` works.)
To make things work, replace `g` by `g(q)`...
----------
So finally, the following code does the job for me. Framework:
PREC = 20
G = DirichletGroup(7, QQ)
S = CuspForms(e, 3, prec=PREC)
g = S.gens()[0]
R = g.qexp().parent()
q = R.gen()
L = EtaProduct(7, {1:4, 7:-4})
fL = L.qexp(PREC)
g(q) * (fL + 4)(q) + O(q^6)
(Addition, multiplication, and truncation work.)
Final result:
1 - 3*q + 2*q^2 + 7*q^3 - 29*q^4 + 21*q^5 + O(q^6)
Wed, 22 Apr 2020 17:49:50 +0200https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?answer=50918#post-id-50918Answer by FrédéricC for <p>Hi, I'm new to Sage and coding in general. I want to look at the 1-dim'l space CuspForms(Gamma0(7), 3) but with character. Here's my code for that</p>
<pre><code>S = G = DirichletGroup(7, QQ)
list(G)
G.gens()
e = G.0
S = CuspForms(e, 3, prec=20)
print(S)
print(Gamma0(7).cusps())
print(S.basis())
g = S.0
</code></pre>
<p>Here, g is the only basis element for S. I want to do <code>F = g*(L+4)</code> where L is some eta-quotient of level 7. However, I get a long error with <code>'NoneType' object is not iterable</code> at the end. So I'm thinking I need to define g in a different way, since it seems to be that g is not a q-series type object the way I've defined it?</p>
https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?answer=50337#post-id-50337You can get the associated formal power series as follows:
sage: g
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(g)
Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [-1] and weight 3 over Rational Field
sage: g.q_expansion()
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(_)
Power Series Ring in q over Rational Field
Tue, 24 Mar 2020 19:18:39 +0100https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?answer=50337#post-id-50337Comment by FundamentalDomain for <p>You can get the associated formal power series as follows:</p>
<pre><code>sage: g
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(g)
Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [-1] and weight 3 over Rational Field
sage: g.q_expansion()
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(_)
Power Series Ring in q over Rational Field
</code></pre>
https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50356#post-id-50356Yes, but if I try something like `g*L.q_expansion()` or `g*L.qexp(20)` or things like that I get that error.Wed, 25 Mar 2020 16:21:06 +0100https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50356#post-id-50356Comment by FrédéricC for <p>You can get the associated formal power series as follows:</p>
<pre><code>sage: g
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(g)
Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [-1] and weight 3 over Rational Field
sage: g.q_expansion()
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(_)
Power Series Ring in q over Rational Field
</code></pre>
https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50359#post-id-50359Try `g.q_expansion() * L.q_expansion()`Wed, 25 Mar 2020 18:21:18 +0100https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50359#post-id-50359Comment by FundamentalDomain for <p>You can get the associated formal power series as follows:</p>
<pre><code>sage: g
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(g)
Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [-1] and weight 3 over Rational Field
sage: g.q_expansion()
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(_)
Power Series Ring in q over Rational Field
</code></pre>
https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50387#post-id-50387It worked!!! So when I do `print(g.q_expansion()*L.q_expansion)` something goes wrong, but leaving out "print" seems to fix this... weird.Fri, 27 Mar 2020 00:52:59 +0100https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50387#post-id-50387Comment by FrédéricC for <p>You can get the associated formal power series as follows:</p>
<pre><code>sage: g
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(g)
Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [-1] and weight 3 over Rational Field
sage: g.q_expansion()
q - 3*q^2 + 5*q^4 - 7*q^7 - 3*q^8 + 9*q^9 - 6*q^11 + 21*q^14 - 11*q^16 - 27*q^18 + O(q^20)
sage: parent(_)
Power Series Ring in q over Rational Field
</code></pre>
https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50388#post-id-50388missing pair of parentheses after expansionFri, 27 Mar 2020 07:38:34 +0100https://ask.sagemath.org/question/50330/how-to-do-arithmetic-with-a-basis-element-from-modular-forms-space/?comment=50388#post-id-50388