---
title: "Elliptic and Modular Invariants"
canonical: "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/invar.html"
source: "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/invar.md"
part: "Lattices and Quadratic Forms"
chapter: "Binary Quadratic Forms"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Lattices and Quadratic Forms", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/index-lattices-quadratic-forms.md"}
  - {"title": "Binary Quadratic Forms", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/index-binary-quadratic-forms.md"}
prev: {"title": "Discrete Logarithms", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/log.md"}
next: {"title": "Class Invariants", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/invar-2.md"}
intrinsics:
  - {"name": "Lattice", "signature": "Lattice(f): QuadBinElt -> Lat"}
  - {"name": "GramMatrix", "signature": "GramMatrix(f): QuadBinElt -> AlgMatElt"}
  - {"name": "ThetaSeries", "signature": "ThetaSeries(f, n): QuadBinElt, RngIntElt -> RngSerElt"}
  - {"name": "RepresentationNumber", "signature": "RepresentationNumber(f, n): QuadBinElt, RngIntElt -> RngIntElt"}
  - {"name": "jInvariant", "signature": "jInvariant(f): QuadBinElt -> RngSerElt"}
  - {"name": "Eisenstein", "signature": "Eisenstein(k, f): RngIntElt, QuadBinElt -> RngSerElt"}
  - {"name": "WeierstrassSeries", "signature": "WeierstrassSeries(z, f): RngSerElt, QuadBinElt -> RngSerElt"}
examples:
  - "ex-f93e36"
---

# Elliptic and Modular Invariants

Binary quadratic forms of negative discriminant describe positive definite lattices in the complex plane, with integral-valued inner product. As such, it is possible to apply modular and elliptic functions to the form, interpreting this as an element of the upper half plane.

<a id="function-lattice-quadbinelt"></a>
## `Lattice(f): QuadBinElt -> Lat`

Given a binary quadratic form $f = ax^2 + bxy + cy^2$ of negative discriminant, returns the rank two lattice of $f$ having Gram matrix

$$
\left({\ a\ \ b/2\atop b/2\ \ c\ }\right).
$$

Note that the lattice $L$ is the half-integral lattice such that integral representations $f(x,y) = n$ are in bijection with vectors $(x,y)$ of norm $n$, which will be a rational number.

<a id="function-grammatrix-quadbinelt"></a>
## `GramMatrix(f): QuadBinElt -> AlgMatElt`

Returns the Gram matrix of the binary quadratic form $f$, which need not be of negative discriminant. The matrix will be half-integral and defined over the rationals.

<a id="function-thetaseries-quadbinelt-rngintelt"></a>
## `ThetaSeries(f, n): QuadBinElt, RngIntElt -> RngSerElt`

The integral theta series of the binary quadratic form $f$ to precision $n$.

<a id="function-representationnumber-quadbinelt-rngintelt"></a>
## `RepresentationNumber(f, n): QuadBinElt, RngIntElt -> RngIntElt`

The $n$th representation number of the form $f$ of negative discriminant.

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

For a binary quadratic form $f = ax^2 + bxy + cy^2$ with negative discriminant, return the $j$–invariant of $f$, equal to the $j$–invariant of $\tau = (-b + \sqrt{b^2 - 4ac})/2a$.

<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_k(L)$ at the complex lattice $L = \langle a, (-b + \sqrt{b^2-4ac}) /2\rangle$.

<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$, returns the $q$–expansion of the Weierstrass $\wp$-function at the complex lattice $L = \langle a, (-b + \sqrt{b^2 - 4ac} )/2\rangle$.

<a id="example-ex-f93e36"></a>
## `Example: Elliptic and Modular Invariants of a Form (ex-f93e36)`

```magma
> Q := QuadraticForms(-163);
> f := PrimeForm(Q,41);
> CC<i> := ComplexField();
> PC<z> := LaurentSeriesRing(CC);
> x := WeierstrassSeries(z,f);
> y := -Derivative(x)/2;
> A := -Eisenstein(4,f)/48;
> B := Eisenstein(6,f)/864;
> Evaluate(y^2 - (x^3 + A*x + B),1/2);
1.384608660824596881000000000 E-26 - 1.305091481190174818000000000 E-26*i
```
