Ask Your Question

Revision history [back]

Indeed, the newforms are returned over a number field without specified embedding.

So a workaround is to choose an embedding and to tweak the coefficients to live there.

Here is one way to do that.

Define the newforms.

sage: C = CuspForms(group=Gamma0(2), weight=26)
sage: C
Cuspidal subspace of dimension 5 of Modular Forms space of dimension 7
  for Congruence Subgroup Gamma0(2) of weight 26 over Rational Field
sage: N = C.newforms(names='a')
sage: N
[q - 4096*q^2 + 97956*q^3 + 16777216*q^4 + 341005350*q^5 + O(q^6),
 q + 4096*q^2 + (-a1 + 4096)*q^3 + 16777216*q^4 + (324*a1 + 431184822)*q^5 + O(q^6)]

Name the polynomials obtained by truncating the two newforms to order 10.

sage: g = N[0].q_expansion(prec=10).truncate()
sage: h = N[1].q_expansion(prec=10).truncate()

Observe that one is defined over the rationals, the other one over a number field.

sage: g[:6]
341005350*q^5 + 16777216*q^4 + 97956*q^3 - 4096*q^2 + q
sage: parent(g)
Univariate Polynomial Ring in q over Rational Field

sage: h[:6]
(324*a1 + 431184822)*q^5 + 16777216*q^4 + (-a1 + 4096)*q^3 + 4096*q^2 + q
sage: parent(h)
Univariate Polynomial Ring in q over Number Field in a1
  with defining polynomial x^2 + 371656*x - 2423951154416

Explore the parent of the coefficients of h:

sage: K = parent(h[0])
sage: K
Number Field in a1 with defining polynomial x^2 + 371656*x - 2423951154416

List its embeddings to RR:

sage: emb = K.embeddings(RR)
sage: emb
[
Ring morphism:
  From: Number Field in a1 with defining polynomial x^2 + 371656*x - 2423951154416
  To:   Real Field with 53 bits of precision
  Defn: a1 |--> -1.75378310139800e6,
Ring morphism:
  From: Number Field in a1 with defining polynomial x^2 + 371656*x - 2423951154416
  To:   Real Field with 53 bits of precision
  Defn: a1 |--> 1.38212710139800e6
]

Define an embedded version of the number field K, choosing one of the embeddings:

sage: phi = emb[1]
sage: KK = NumberField(K.polynomial(), K.variable_name(), embedding=phi(K.gen()))
sage: KK

Take the polynomial of interest to that field:

sage: hh = KK['q']([KK(c.list()) for c in h.list()])

Inspect the result:

sage: hh[:6]
(324*a1 + 431184822)*q^5 + 16777216*q^4 + (-a1 + 4096)*q^3 + 4096*q^2 + q

Now the polynomial can be evaluated at reals:

sage: hh(-10.)
-3.06119845368516e17
sage: hh(exp(-10.))
0.0000537135354901745

Indeed, the newforms are returned over a number field without specified embedding.

So Possibly an option could be added to use an embedded number field.

Not sure how to achieve that, so here is a workaround is to workaround.

Idea:

  • choose an embedding and embedding
  • define a new version of the coefficient field
  • tweak the polynomial to tweak the have coefficients to live there.

    Here is one way to do that.

    there

Define the newforms.

sage: C = CuspForms(group=Gamma0(2), weight=26)
sage: C
Cuspidal subspace of dimension 5 of Modular Forms space of dimension 7
  for Congruence Subgroup Gamma0(2) of weight 26 over Rational Field
sage: N = C.newforms(names='a')
sage: N
[q - 4096*q^2 + 97956*q^3 + 16777216*q^4 + 341005350*q^5 + O(q^6),
 q + 4096*q^2 + (-a1 + 4096)*q^3 + 16777216*q^4 + (324*a1 + 431184822)*q^5 + O(q^6)]

Name the polynomials obtained by truncating the two newforms to order 10.

sage: g = N[0].q_expansion(prec=10).truncate()
sage: h = N[1].q_expansion(prec=10).truncate()

Observe that one is defined over the rationals, the other one over a number field.

sage: g[:6]
341005350*q^5 + 16777216*q^4 + 97956*q^3 - 4096*q^2 + q
sage: parent(g)
Univariate Polynomial Ring in q over Rational Field

sage: h[:6]
(324*a1 + 431184822)*q^5 + 16777216*q^4 + (-a1 + 4096)*q^3 + 4096*q^2 + q
sage: parent(h)
Univariate Polynomial Ring in q over Number Field in a1
  with defining polynomial x^2 + 371656*x - 2423951154416

Explore the parent of the coefficients of h:

sage: K = parent(h[0])
sage: K
Number Field in a1 with defining polynomial x^2 + 371656*x - 2423951154416

List its embeddings to RR:

sage: emb = K.embeddings(RR)
sage: emb
[
Ring morphism:
  From: Number Field in a1 with defining polynomial x^2 + 371656*x - 2423951154416
  To:   Real Field with 53 bits of precision
  Defn: a1 |--> -1.75378310139800e6,
Ring morphism:
  From: Number Field in a1 with defining polynomial x^2 + 371656*x - 2423951154416
  To:   Real Field with 53 bits of precision
  Defn: a1 |--> 1.38212710139800e6
]

Define an embedded version of the number field K, choosing one of the embeddings:

sage: phi = emb[1]
sage: KK Ke = NumberField(K.polynomial(), K.variable_name(), embedding=phi(K.gen()))
sage: KK
Ke

Take the polynomial of interest to that embedded field:

sage: hh = KK['q']([KK(c.list()) he = Ke['q']([Ke(c.list()) for c in h.list()])

Inspect the result:

sage: hh[:6]
he[:6]
(324*a1 + 431184822)*q^5 + 16777216*q^4 + (-a1 + 4096)*q^3 + 4096*q^2 + q

Now the polynomial can be evaluated at reals:

sage: hh(-10.)
he(-10.)
-3.06119845368516e17
sage: hh(exp(-10.))
he(exp(-10.))
0.0000537135354901745