# Elliptic and Modular Functions

More information on elliptic functions can be found for example in Chandrasekharan [[Chandrasekharan, 1985](../../references.md#cite-chand85)], and for modular functions and their use see Koblitz [[Koblitz, 1984](../../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.

### `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.

### `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$.

### `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$.

### `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}$.

### `Example: Eisenstein (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

### `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$.

### `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}$.

### `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$.

### `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$.

### `JacobiTheta(q, z): FldReElt, RngSerElt[FldRe] -> RngSerElt`

### `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.

### `JacobiTheta(q, z): FldReElt, FldReElt -> FldReElt`

### `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.

### `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.

### `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 [[Lang, 1987](../../references.md#cite-lang87)].

### `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}$.

### `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)`.

### `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.
$$

### `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.

### `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)$.

### `Delta(z): RngSerElt -> RngSerElt`

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

### `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}$.

### `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.

## Weber’s Functions

### `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}}.
$$

### `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}}.
$$

### `WeberF1(s): FldComElt -> FldComElt`

### `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)}.
$$

### `Example: Eisenstein (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 +
    ...

```
