---
title: "Arithmetic"
canonical: "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/ModularForms/arithmetic.html"
source: "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/ModularForms/arithmetic.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": "$q$-Expansions", "source": "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/ModularForms/q-expansions.md"}
next: {"title": "Predicates", "source": "https://docs.magma-maths.org/v2.30-1/ModularArithmeticGeometry/ModularForms/predicates.md"}
intrinsics:
  - {"name": "+", "signature": "f + g: ModFrmElt, ModFrmElt -> ModFrmElt"}
  - {"name": "+", "signature": "f + g: ModFrmElt, RngSerPowElt -> RngSerPowElt"}
  - {"name": "-", "signature": "f - g: ModFrmElt, ModFrmElt -> ModFrmElt"}
  - {"name": "*", "signature": "a * f: RngElt, ModFrmElt -> ModFrmElt"}
  - {"name": "/", "signature": "f / a: ModFrmElt, RngElt -> ModFrmElt"}
  - {"name": "^", "signature": "f ^ n: ModFrmElt, RngIntElt -> ModFrmElt"}
  - {"name": "*", "signature": "f * g: ModFrmElt, ModFrmElt -> ModFrmElt"}
examples:
  - "ex-061f7d"
---

# Arithmetic

<a id="operation-op-plus-modfrmelt-modfrmelt"></a>
## `f + g: ModFrmElt, ModFrmElt -> ModFrmElt`

The sum of the modular forms $f$ and $g$.

<a id="operation-op-plus-modfrmelt-rngserpowelt"></a>
## `f + g: ModFrmElt, RngSerPowElt -> RngSerPowElt`

The sum of the modular form $f$ and the power series $g$. The $q$-expansion of $f$ must be coercible into the parent of $g$. The sum $g+f$ is also defined, as are the differences $f-g$ and $g-f$.

<a id="operation-op-minus-modfrmelt-modfrmelt"></a>
## `f - g: ModFrmElt, ModFrmElt -> ModFrmElt`

The difference of the modular forms $f$ and $g$.

<a id="operation-op-times-rngelt-modfrmelt"></a>
## `a * f: RngElt, ModFrmElt -> ModFrmElt`

The product of the scalar $a$ and the modular form $f$.

<a id="operation-op-div-modfrmelt-rngelt"></a>
## `f / a: ModFrmElt, RngElt -> ModFrmElt`

The product of the scalar $1/a$ and the modular form $f$.

<a id="operation-op-pow-modfrmelt-rngintelt"></a>
## `f ^ n: ModFrmElt, RngIntElt -> ModFrmElt`

The power $f^n$ of the modular form $f$, where $n\geq 1$ is an integer.

<a id="operation-op-times-modfrmelt-modfrmelt"></a>
## `f * g: ModFrmElt, ModFrmElt -> ModFrmElt`

The product of the modular forms $f$ and $g$. The only condition is that the base fields of $f$ and $g$ be the same. The weight of `f*g` is the sum of the weights of $f$ and $g$.

<a id="example-ex-061f7d"></a>
## `Example: Arithmetic with Modular Forms (ex-061f7d)`

```magma
> M2 := ModularForms(Gamma0(11), 2);
> f := M2.1;
> g := M2.2;
> f;
1 + 12*q^2 + 12*q^3 + 12*q^4 + 12*q^5 + 24*q^6 + 24*q^7 + O(q^8)
> g;
q - 2*q^2 - q^3 + 2*q^4 + q^5 + 2*q^6 - 2*q^7 + O(q^8)
> f+g;
1 + q + 10*q^2 + 11*q^3 + 14*q^4 + 13*q^5 + 26*q^6 + 22*q^7 + O(q^8)
> 2*f;
2 + 24*q^2 + 24*q^3 + 24*q^4 + 24*q^5 + 48*q^6 + 48*q^7 + O(q^8)
> MQ,phi := BaseExtend(M2, RationalField());
> phi(2*f)/2;
1 + 12*q^2 + 12*q^3 + 12*q^4 + 12*q^5 + 24*q^6 + 24*q^7 + O(q^8)
> f^2;
1 + 24*q^2 + 24*q^3 + 168*q^4 + 312*q^5 + 480*q^6 + 624*q^7 + O(q^8)
> Parent($1);
Space of modular forms on Gamma_0(11) of weight 4 and dimension 4 over
Integer Ring.
> M3 := ModularForms([DirichletGroup(11).1], 3); M3;
Space of modular forms on Gamma_1(11) with character all conjugates of
[$.1], weight 3, and dimension 3 over Integer Ring.
> M3.1*f;
1 + 12*q^2 + 2*q^3 + 6*q^4 - 126*q^5 - 168*q^6 - 384*q^7 + O(q^8)
> Parent($1);
Space of modular forms on Gamma_1(11) of weight 5 and dimension 25
over Integer Ring.
```
