---
title: "Subspaces"
canonical: "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/ModularForms/subspaces.html"
source: "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/ModularForms/subspaces.md"
part: "Modular Arithmetic Geometry"
chapter: "Modular Forms"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Modular Arithmetic Geometry", "source": "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/index-modular-arithmetic-geometry.md"}
  - {"title": "Modular Forms", "source": "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/ModularForms/index-modular-forms.md"}
prev: {"title": "Properties", "source": "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/ModularForms/properties.md"}
next: {"title": "Operators", "source": "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/ModularForms/operators.md"}
intrinsics:
  - {"name": "ZeroSubspace", "signature": "ZeroSubspace(M): ModFrm -> ModFrm"}
  - {"name": "CuspidalSubspace", "signature": "CuspidalSubspace(M): ModFrm -> ModFrm"}
  - {"name": "EisensteinSubspace", "signature": "EisensteinSubspace(M): ModFrm -> ModFrm"}
  - {"name": "EisensteinProjection", "signature": "EisensteinProjection(f): ModFrmElt -> ModFrmElt"}
  - {"name": "CuspidalProjection", "signature": "CuspidalProjection(f): ModFrmElt -> ModFrmElt"}
  - {"name": "NewSubspace", "signature": "NewSubspace(M): ModFrm -> ModFrm"}
  - {"name": "DihedralSubspace", "signature": "DihedralSubspace(M): ModFrm -> ModFrm"}
examples:
  - "ex-fd9fb5"
---

# Subspaces

The following functions compute the cuspidal, Eisenstein, and new subspaces.

<a id="function-zerosubspace-modfrm"></a>
## `ZeroSubspace(M): ModFrm -> ModFrm`

The trivial subspace of the space of modular forms $M$.

<a id="function-cuspidalsubspace-modfrm"></a>
## `CuspidalSubspace(M): ModFrm -> ModFrm`

The subspace of forms $f$ in $M$ such that the constant term of the Fourier expansion of $f$ at every cusp is $0$.

<a id="function-eisensteinsubspace-modfrm"></a>
## `EisensteinSubspace(M): ModFrm -> ModFrm`

The Eisenstein subspace of the space of modular forms $M$.

<a id="function-eisensteinprojection-modfrmelt"></a>
## `EisensteinProjection(f): ModFrmElt -> ModFrmElt`

<a id="function-cuspidalprojection-modfrmelt"></a>
## `CuspidalProjection(f): ModFrmElt -> ModFrmElt`

The projection of a given modular form to the `EisensteinSubspace` or to the `CuspidalSubspace`. The sum of the two projections equals the original form (after coercion).

The base ring of the given form must contain the rationals.

<a id="function-newsubspace-modfrm"></a>
## `NewSubspace(M): ModFrm -> ModFrm`

The new subspace of the space of modular forms $M$.

<a id="function-dihedralsubspace-modfrm"></a>
## `DihedralSubspace(M): ModFrm -> ModFrm`

For a space $M$ of weight $1$ forms, this returns the subspace spanned by the cusp forms attached to dihedral Galois representations.

<a id="example-ex-fd9fb5"></a>
## `Example: q-Expansion Bases of Subspaces (ex-fd9fb5)`

We compute a basis of $q$-expansions for each of the above subspace of $M_2(\Gamma_0(33))$.

```magma
> M := ModularForms(Gamma0(33),2); M;
Space of modular forms on Gamma_0(33) of weight 2 and dimension 6 over
Integer Ring.
> Basis(M);
[
    1 + O(q^8),
    q - q^5 + 2*q^7 + O(q^8),
    q^2 + 2*q^7 + O(q^8),
    q^3 + O(q^8),
    q^4 + q^5 + O(q^8),
    q^6 + O(q^8)
]
> Basis(CuspidalSubspace(M));
[
    q - q^5 - 2*q^6 + 2*q^7 + O(q^8),
    q^2 - q^4 - q^5 - q^6 + 2*q^7 + O(q^8),
    q^3 - 2*q^6 + O(q^8)
]
> Basis(EisensteinSubspace(M));
[
    1 + O(q^8),
    q + 3*q^2 + 7*q^4 + 6*q^5 + 8*q^7 + O(q^8),
    q^3 + 3*q^6 + O(q^8)
]
> Basis(NewSubspace(M));
[
    q + q^2 - q^3 - q^4 - 2*q^5 - q^6 + 4*q^7 + O(q^8)
]
> Basis(NewSubspace(EisensteinSubspace(M)));
[]
> Basis(NewSubspace(CuspidalSubspace(M)));
[
    q + q^2 - q^3 - q^4 - 2*q^5 - q^6 + 4*q^7 + O(q^8)
]
> ZeroSubspace(M);
Space of modular forms on Gamma_0(33) of weight 2 and dimension 0 over
Integer Ring.
> MQ := BaseChange(M, Rationals()); SetPrecision(MQ, 20);
> b := Basis(MQ); b[5];
q^4 + q^5 + 2*q^8 - q^9 + 2*q^10 + 2*q^11 - q^12 + 2*q^13 +
 2*q^14 - q^15 + 3*q^16 + 2*q^17 - 2*q^18 + 2*q^19 + O(q^20)
> CuspidalProjection(b[5]);
-1/10*q - 3/10*q^2 + 1/10*q^3 + 3/10*q^4 + 2/5*q^5 + 3/10*q^6 - 4/5*q^7
+ 1/2*q^8 - 3/10*q^9 + 1/5*q^10 - 1/10*q^11 - 3/10*q^12 + 3/5*q^13 -
2/5*q^14 - 2/5*q^15 - 1/10*q^16 + 1/5*q^17 + 1/10*q^18 + O(q^20)
> EisensteinProjection(b[5]);
1/10*q + 3/10*q^2 - 1/10*q^3 + 7/10*q^4 + 3/5*q^5 - 3/10*q^6 + 4/5*q^7
+ 3/2*q^8 - 7/10*q^9 + 9/5*q^10 + 21/10*q^11 - 7/10*q^12 + 7/5*q^13 +
12/5*q^14 - 3/5*q^15 + 31/10*q^16 + 9/5*q^17 - 21/10*q^18 + 2*q^19 +
O(q^20)
> MQ! $1 + MQ! $2;  // Add the previous two answers, inside MQ
q^4 + q^5 + 2*q^8 - q^9 + 2*q^10 + 2*q^11 - q^12 + 2*q^13 +
 2*q^14 - q^15 + 3*q^16 + 2*q^17 - 2*q^18 + 2*q^19 + O(q^20)
```

The two projections sum to the original form.
