---
title: "Elliptic and Modular Functions"
canonical: "https://docs.magma-maths.org/v2.30-1/BasicRings/RealAndComplexFields/elliptic-modular.html"
source: "https://docs.magma-maths.org/v2.30-1/BasicRings/RealAndComplexFields/elliptic-modular.md"
part: "Basic Rings"
chapter: "Real and Complex Fields"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Basic Rings", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/index-basic-rings.md"}
  - {"title": "Real and Complex Fields", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/RealAndComplexFields/index-real-and-complex-fields.md"}
prev: {"title": "Transcendental Functions", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/RealAndComplexFields/transcendental.md"}
next: {"title": "Theta Functions", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/RealAndComplexFields/theta.md"}
intrinsics:
  - {"name": "Eisenstein", "signature": "Eisenstein(k, z): RngIntElt, RngSerElt -> RngSerElt"}
  - {"name": "Eisenstein", "signature": "Eisenstein(k, t): RngIntElt, FldComElt -> FldComElt"}
  - {"name": "Eisenstein", "signature": "Eisenstein(k, L): RngIntElt, SeqEnum -> FldComElt"}
  - {"name": "Eisenstein", "signature": "Eisenstein(k, F): RngIntElt, QuadBinElt -> RngSerElt"}
  - {"name": "WeierstrassSeries", "signature": "WeierstrassSeries(z, q): RngSerElt, RngSerElt -> RngSerElt"}
  - {"name": "WeierstrassSeries", "signature": "WeierstrassSeries(z, t): RngSerElt, FldComElt -> RngSerElt"}
  - {"name": "WeierstrassSeries", "signature": "WeierstrassSeries(z, L): RngSerElt, SeqEnum -> RngSerElt"}
  - {"name": "WeierstrassSeries", "signature": "WeierstrassSeries(z, F): RngSerElt, QuadBinElt -> RngSerElt"}
  - {"name": "JacobiTheta", "signature": "JacobiTheta(q, z): FldReElt, RngSerElt[FldRe] -> RngSerElt"}
  - {"name": "JacobiTheta", "signature": "JacobiTheta(q, z): FldComElt, RngSerElt[FldCom] -> RngSerElt"}
  - {"name": "JacobiTheta", "signature": "JacobiTheta(q, z): FldReElt, FldReElt -> FldReElt"}
  - {"name": "JacobiTheta", "signature": "JacobiTheta(q, z): FldComElt, FldComElt -> FldComElt"}
  - {"name": "JacobiThetaNullK", "signature": "JacobiThetaNullK(q, k): FldReElt, RngIntElt -> FldReElt"}
  - {"name": "DedekindEta", "signature": "DedekindEta(z): RngSerElt -> RngSerElt"}
  - {"name": "DedekindEta", "signature": "DedekindEta(s): FldComElt -> FldComElt"}
  - {"name": "jInvariant", "signature": "jInvariant(q): RngSerElt -> RngSerElt"}
  - {"name": "jInvariant", "signature": "jInvariant(s): FldComElt -> FldComElt"}
  - {"name": "jInvariant", "signature": "jInvariant(L): SeqEnum -> FldComElt"}
  - {"name": "jInvariant", "signature": "jInvariant(F): QuadBinElt -> FldComElt"}
  - {"name": "Delta", "signature": "Delta(z): RngSerElt -> RngSerElt"}
  - {"name": "Delta", "signature": "Delta(t): FldComElt -> FldComElt"}
  - {"name": "Delta", "signature": "Delta(L): SeqEnum -> FldComElt"}
  - {"name": "WeberF", "signature": "WeberF(s): FldComElt -> FldComElt"}
  - {"name": "WeberF2", "signature": "WeberF2(g): RngSerElt -> RngSerElt"}
  - {"name": "WeberF1", "signature": "WeberF1(s): FldComElt -> FldComElt"}
  - {"name": "WeberF2", "signature": "WeberF2(s): FldComElt -> FldComElt"}
examples:
  - "ex-db3e10"
  - "ex-3718fd"
---

# Elliptic and Modular Functions

More information on elliptic functions can be found for example in Chandrasekharan [[Cha85](https://docs.magma-maths.org/v2.30-1/references.md#cite-chand85)], and for modular functions and their use see Koblitz [[Kob84](https://docs.magma-maths.org/v2.30-1/references.md#cite-koblitz84)].

## Eisenstein Series

Let $f(z)$ be a modular function. Then $f(z)$ may be written as a Fourier series $f(z) = \sum_{n \in {\mathbb{Z}}} a_{n} q^{n},$ where $q = e^{2 \pi i z}$, which has at most finitely many nonzero coefficients $a_{n}$ with $n<0$. Such a Fourier expansion of a modular function is called its $q$*-expansion*. In this and the next section we present intrinsics for $q$-expansions of the Eisenstein series and the Weierstrass $\wp$-function.

Let $z$ be a point in the upper half-plane and let $L$ be a lattice in ${\mathbb{C}}$. The Eisenstein series are defined as the coefficients of the Laurent Series expansion of the Weierstrass $\wp$-function:

$$
\wp(z, L) = {{1}\over{z^2}} + \sum_{2\le k} G_k(L)(2k-1)z^{2k-2}
$$

where $G_k(L)$ are the Eisenstein series. The normalization $E_{2n}(z) = {{1}\over{2 \zeta(2n)}} G_{2n}(z)$ ensures that $E_{2n}(z)$ has a *rational* $q$-expansion.

<a id="function-eisenstein-rngintelt-rngserelt"></a>
### `Eisenstein(k, z): RngIntElt, RngSerElt -> RngSerElt`

```magma
Precision: RngIntElt                    Default: 
```

Given a positive even integer $k = 2n$ and a complex power series $z$ with positive valuation, return the $q$-expansion of the normalized Eisenstein series $E_{2n}(z)$. If $z$ has finite precision this is the default for `Precision` otherwise the default precision of the parent of $z$ is used.

<a id="function-eisenstein-rngintelt-fldcomelt"></a>
### `Eisenstein(k, t): RngIntElt, FldComElt -> FldComElt`

Given a positive even integer $k = 2n$ and a point $t$ in the upper half plane, return the value of $E_{2n}(z)$ at $t$.

<a id="function-eisenstein-rngintelt-seqenum"></a>
### `Eisenstein(k, L): RngIntElt, SeqEnum -> FldComElt`

Given a positive even integer $k = 2n$ and a lattice $L = [a, b]$ in the complex plane, return the value of the Eisenstein series $E_{2n}(z)$ relative to the lattice $L$.

<a id="function-eisenstein-rngintelt-quadbinelt"></a>
### `Eisenstein(k, F): RngIntElt, QuadBinElt -> RngSerElt`

Given a positive even integer $k = 2n$ and a binary quadratic form $F = ax^2+bxy+cy^2$, return the value of the Eisenstein series $E_{2n}(z)$ at the point $\tau = \left(-b+\sqrt{b^2-4ac} \right)/(2a)$ where $z$ is $e^{2\pi*{\mathrm{i}}*\tau}$.

<a id="example-ex-db3e10"></a>
### `Example: q-Expansion of an Eisenstein Series (ex-db3e10)`

We compute the $q$-expansion for the normalized Eisenstein series $E_{4}(z)$.

```magma
> C<i> := ComplexField();
> R<z> := PowerSeriesRing(C);
> E4<q> := Eisenstein(4, z);
> E4;
1.00000000000000000000000000000 +
    240.000000000000000000000000000*q +
    2160.00000000000000000000000000*q^2 +
    6720.00000000000000000000000000*q^3 +
    17520.0000000000000000000000000*q^4 +
    30240.0000000000000000000000000*q^5 +
    60480.0000000000000000000000000*q^6 +
    82560.0000000000000000000000000*q^7 +
    140400.000000000000000000000000*q^8 +
    181680.000000000000000000000000*q^9 +
    272160.000000000000000000000000*q^10 +
    319680.000000000000000000000000*q^11 +
    490560.000000000000000000000000*q^12 +
    527520.000000000000000000000000*q^13 +
    743040.000000000000000000000000*q^14 +
    846720.000000000000000000000000*q^15 +
    1123440.00000000000000000000000*q^16 +
    1179360.00000000000000000000000*q^17 +
    1635120.00000000000000000000000*q^18 +
    1646400.00000000000000000000000*q^19 + O(q^20)
```

We now evaluate this series at the point $z1 = 2.5 + i$. Since the expansion is in terms of $q$ rather than $z$ we first must calculate the point $q1$ that corresponds to $z1$.

```magma
> q1 := Exp(2*Pi(RealField())*i*(2.5 +i));
> Evaluate(E4, q1);
0.559302852856190773766762411942 +
3.67329046709782088758389413820E-31*i
```

If we are interested only in the value of $E_{4}$ at a single point, then we can compute it directly:

```magma
> Eisenstein(4, 2.5 + i);
0.559302852856190773766762411942 +
3.67329046709782088758389413820E-31*i
```

## Weierstrass Series

<a id="function-weierstrassseries-rngserelt-rngserelt"></a>
### `WeierstrassSeries(z, q): RngSerElt, RngSerElt -> RngSerElt`

```magma
Precision: RngIntElt                    Default: 
```

Return a normalized $q$-expansion of the Weierstrass $\wp$-function:

$$
\wp(z, L) = {{1}\over{z^2}} + \sum_{2\le k} G_k(L)(2k-1)z^{2k-2}
$$

where $G_k(L)$ are the Eisenstein series and

$$
\hbox{\tt WeierstrassSeries}(z,q) = (2 \pi i)^{-2}\wp(q, z/(2 \pi i))
$$

Each term is an Eisenstein series, calculated to precision `Precision`, which is by default the precision of $q$.

<a id="function-weierstrassseries-rngserelt-fldcomelt"></a>
### `WeierstrassSeries(z, t): RngSerElt, FldComElt -> RngSerElt`

Given a complex power series $z$ with positive valuation and a point $t =\tau$ in the upper-half complex plane, return the normalized $q$-expansion of the Weierstrass $\wp$-function. This is equivalent to evaluating the $q$-series expansion at $q = e^{2\pi i\tau}$.

<a id="function-weierstrassseries-rngserelt-seqenum"></a>
### `WeierstrassSeries(z, L): RngSerElt, SeqEnum -> RngSerElt`

Given a complex power series $z$ with positive valuation and a lattice $L = [a, b]$ in the complex plane, returns the normalized $q$-expansion of the Weierstrass $\wp$-function relative to the lattice $L$.

<a id="function-weierstrassseries-rngserelt-quadbinelt"></a>
### `WeierstrassSeries(z, F): RngSerElt, QuadBinElt -> RngSerElt`

Given a complex power series $z$ with positive valuation and a binary quadratic form $F = ax^2+bxy+cy^2$, this function returns the $q$-expansion of the Weierstrass $\wp$-function at $\tau = \left(-b+\sqrt{b^2-4ac} \right)/(2a)$.

## The Jacobi $\theta$ and Dedekind $\eta$-functions

The first Jacobi $\theta$-function, $\theta(q, z)$, is defined by

$$
\theta(q, z)={1\over{\mathrm{i}}}\sum_{n=-\infty}^\infty(-1)^nq^{(n+{1\over2})^2}e^{(2n+1){\mathrm{i}}z}=2\sum_{n=0}^\infty(-1)^nq^{(n+{1\over2})^2}\sin(2n+1)z.
$$

Defined this way, $\theta$ satisfies $\theta(q, -z)=-\theta(q, z)$, it is periodic with period $2\pi$ in the second variable: $\theta(q, z+2\pi)= \theta(q, z)$, and its zeroes are of the form $m_1\pi+m_2{\log x\over{\mathrm{i}}}$ for any integers $m_1, m_2$.

<a id="function-jacobitheta-fldreelt-rngserelt-fldre"></a>
### `JacobiTheta(q, z): FldReElt, RngSerElt[FldRe] -> RngSerElt`

<a id="function-jacobitheta-fldcomelt-rngserelt-fldcom"></a>
### `JacobiTheta(q, z): FldComElt, RngSerElt[FldCom] -> RngSerElt`

For a real or complex number $q$ satisfying $\vert q\vert<1$, return the first of Jacobi’s theta functions $\theta(q,z)$ as a power series expansion in $z$, a series over the complex numbers. Pari is used here.

<a id="function-jacobitheta-fldreelt-fldreelt"></a>
### `JacobiTheta(q, z): FldReElt, FldReElt -> FldReElt`

<a id="function-jacobitheta-fldcomelt-fldcomelt"></a>
### `JacobiTheta(q, z): FldComElt, FldComElt -> FldComElt`

For real or complex numbers $q, z$ satisfying $\vert q\vert<1$, return the value of $\theta(q, z)$, the first of Jacobi’s theta functions. Pari is used here.

<a id="function-jacobithetanullk-fldreelt-rngintelt"></a>
### `JacobiThetaNullK(q, k): FldReElt, RngIntElt -> FldReElt`

For integer $k\geq 0$, return the $k$-th derivative $\theta^{(k)}(q, 0)$ of $\theta(q, z)$ at $z=0$. Pari is used here.

<a id="function-dedekindeta-rngserelt"></a>
### `DedekindEta(z): RngSerElt -> RngSerElt`

Given a complex power series $z$ with positive valuation, return the $q$-expansion of Dedekind’s $\eta$-function. Note that the unnormalized series is returned, that is, the factor $q^{1/24}$ is *not* removed. See [[Lan87](https://docs.magma-maths.org/v2.30-1/references.md#cite-lang87)].

<a id="function-dedekindeta-fldcomelt"></a>
### `DedekindEta(s): FldComElt -> FldComElt`

For complex argument $s$ with positive imaginary part, this returns the actual value of Dedekind’s $\eta$-function which is defined by $\eta(s)=e^{2\pi{\mathrm{i}}s\over 24} \left(1 + \sum_{n=1}^\infty(-1)^n (q^{n(3n-1)/2} + q^{n(3n+1)/2}) \right)$ where $q = e^{2\pi{\mathrm{i}}s}$.

## The $j$-Invariant and the Discriminant

The discriminant of the elliptic curve corresponding to the complex lattice $L_{\tau}$, spanned by $1$ and $\tau$ is given by

$$
\Delta(\tau) = q \left(1 + \sum_{n=1}^\infty(-1)^n (q^{n(3n-1)/2} + q^{n(3n+1)/2}) \right)
$$

where $q = e^{2\pi{\mathrm{i}}\tau}$.

<a id="function-jinvariant-rngserelt"></a>
### `jInvariant(q): RngSerElt -> RngSerElt`

Given a power series $q$ over a real or complex field with positive valuation, return the $q$-expansion of the elliptic $j$-invariant. The expansion begins with

$$
j(q) = q^{-1} + 744 + 196884 q + \cdots.
$$

Note that:

$$
j(q) = {{{E_4(q)}^3}\over{\Delta(q)}}
$$

where $E_4(q)$ = `Eisenstein(4, q)` and $\Delta(q)$ = `Delta(q)`.

<a id="function-jinvariant-fldcomelt"></a>
### `jInvariant(s): FldComElt -> FldComElt`

For complex argument $s$ with positive imaginary part, this returns the value of the elliptic $j$-invariant at $s$. This is a modular function of weight $0$ whose Fourier expansion starts with

$$
j(s)=e^{-2\pi{\mathrm{i}}s}+744+196884e^{2\pi{\mathrm{i}}s}+\cdots.
$$

<a id="function-jinvariant-seqenum"></a>
### `jInvariant(L): SeqEnum -> FldComElt`

Given a lattice $L = [a, b]$ in the complex plane, this function returns the value of the elliptic $j$-invariant of $L$. This is the $j$-invariant of $\tau$ where $\tau = a/b$ or $\tau = b / a$, whichever is in the upper half complex plane.

<a id="function-jinvariant-quadbinelt"></a>
### `jInvariant(F): QuadBinElt -> FldComElt`

For a binary quadratic form $F = ax^2+bxy+cy^2$ with negative discriminant, this returns the elliptic $j$-invariant of $F$. This is the $j$-invariant of $\tau$ where $\tau = \left(-b + \sqrt{b^2-4ac}\right) / (2a)$.

<a id="function-delta-rngserelt"></a>
### `Delta(z): RngSerElt -> RngSerElt`

Given a complex power series $z$, this function returns a $q$-series expansion of the discriminant $\Delta(z)$.

<a id="function-delta-fldcomelt"></a>
### `Delta(t): FldComElt -> FldComElt`

Given a point $t$ in the upper half plane, return the $q$-series expansion of the discriminant $\Delta(q)$ evaluated at $q = e^{2\pi{\mathrm{i}}t}$.

<a id="function-delta-seqenum"></a>
### `Delta(L): SeqEnum -> FldComElt`

Given a pair $L$ = [$a$,$b$] of complex numbers generating a lattice in ${\mathbb{C}}$, return the $q$-series expansion of the discriminant $\Delta(q)$ evaluated at $q = e^{2\pi{\mathrm{i}}\tau}$ where $\tau = a/b$ or $\tau = b / a$, whichever is in the upper half complex plane.

<a id="weber-s-functions"></a>
## Weber’s Functions

<a id="function-weberf-fldcomelt"></a>
### `WeberF(s): FldComElt -> FldComElt`

For complex argument $s$ in the upper half-plane, this returns the value of Weber’s function $f$, defined in such a way that

$$
j(s)={(f(s)^{24}-16)^3\over f(s)^{24}}.
$$

<a id="function-weberf2-rngserelt"></a>
### `WeberF2(g): RngSerElt -> RngSerElt`

For a complex power series $g$ having positive valuation, this function returns the $q$-expansion of Weber’s $f_2$ function

$$
f_2(x)={\eta(2x)\sqrt{2}\over\eta(x)}
$$

defined in such a way that

$$
j(s)={(f_2(s)^{24}+16)^3\over f_2(s)^{24}}.
$$

<a id="function-weberf1-fldcomelt"></a>
### `WeberF1(s): FldComElt -> FldComElt`

<a id="function-weberf2-fldcomelt"></a>
### `WeberF2(s): FldComElt -> FldComElt`

For complex number $s$ lying in the upper half-plane, these return the value of Weber’s functions $f_1$ and $f_2$, defined in such a way that

$$
j(s)={(f_{1/2}(s)^{24}+16)^3\over f_{1/2}(s)^{24}}.
$$

In fact, $f_2$ is as defined above and

$$
f_1(x)=f_2(-1/x)={\eta(x/2)/\eta(x)}.
$$

<a id="example-ex-3718fd"></a>
### `Example: q-Expansion of a Weber Function (ex-3718fd)`

We compute the $q$-expansion for the Weber function $f_{2}(z)$.

```magma
> C<i> := ComplexField();
> R<x> := PowerSeriesRing(C);
> f2<q> := WeberF2(x);
> f2;
1.41421356237309504880168872421 +
    (1.41421356237309504880168872421 +
    0.370240244846530520584656749172*i)*q +
    (1.36574922765338060759226121771 +
    0.370240244846530520584656749172*i)*q^2 +
    (2.77996279002647565639394994192 +
    0.366010933793292419482272977081*i)*q^3 +
    (2.78023959778761313408864734217 +
    0.736251178639822940066929726253*i)*q^4 +
    (4.14598882544099374168090855987 +
    0.736265672260303709036837819528*i)*q^5 +
    (5.56020175541059398072755542234 +
    1.10227660605359612851911079661*i)*q^6 +
    ...
```
