# Congruences

## `CongruenceGroup(M1, M2, prec): ModFrm, ModFrm, RngIntElt -> GrpAb`

A group $C$ that measures all possible congruences (to precision $prec$) between some modular form in $M_1$ and some modular form in $M_2$. The group $C$ is defined as follows. Let $W_1$ be the finite-rank ${\mathbb{Z}}$-module $q$-exp$(M_1)\cap {\mathbb{Z}}[[q]]$ and let $W_2$ be $q$-exp$(M_2)\cap {\mathbb{Z}}[[q]]$. Let $V$ be the saturation of $W_1 + W_2$ in ${\mathbb{Z}}[[q]]$. Then $C=V/(W_1+W_2)$.

## `CongruenceGroupAnemic(M1, M2, prec): ModFrm, ModFrm, RngIntElt -> GrpAb`

Analogous to `CongruenceGroup`, but now considering congruences that hold for all q-expansion coefficients $a_n$ with $n$ coprime to the levels of both $M1$ and $M2$ (rather than for all q-expansion coefficients).

## `Example: Congruences (ex-71c3ed)`

We verify that the newform corresponding to the first elliptic curve of rank $2$ is congruent modulo $5$ to some Galois-conjugate newform corresponding to the winding quotient of $J_0(389)$ (there is also a congruence modulo $2$ to some conjugate form).

```magma
> M := ModularForms(Gamma0(389),2);
> f := Newform(M,1);
> Degree(f);
1
> g := Newform(M,5);
> Degree(g);
20
> CongruenceGroup(Parent(f),Parent(g),30);
Abelian Group isomorphic to Z/20
Defined on 1 generator
Relations:
    20*$.1 = 0

```

The congruence can be seen directly by computing the reductions of $f$ and $g$ modulo $5$:

```magma
> fmod5 := Reductions(f,5);
> gmod5 := Reductions(g,5);  // takes a few seconds.
> #gmod5;
7
> #fmod5;
1
> [gbar : gbar in gmod5 | #gbar eq 1];
[ [*
q + 4*q^2 + q^3 + 4*q^4 + q^5 + 4*q^6 + O(q^8)
*], [*
q + 3*q^2 + 3*q^3 + 2*q^4 + 2*q^5 + 4*q^6 + O(q^8)
*] ]
> fmod5[1][1];
q + 3*q^2 + 3*q^3 + 2*q^4 + 2*q^5 + 4*q^6 + O(q^8)

```
