---
title: "Local Invariants"
canonical: "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/QuadraticForms/local-invariants.html"
source: "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/QuadraticForms/local-invariants.md"
part: "Lattices and Quadratic Forms"
chapter: "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": "Quadratic Forms", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/QuadraticForms/index-quadratic-forms.md"}
prev: {"title": "Constructions and Conversions", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/QuadraticForms/constructions-conversions.md"}
next: {"title": "Isotropic Subspaces", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/QuadraticForms/isotropic.md"}
intrinsics:
  - {"name": "pSignature", "signature": "pSignature(f, p): RngMPolElt, RngIntElt -> RngIntElt"}
  - {"name": "pSignature", "signature": "pSignature(M, p): Mtrx, RngIntElt -> RngIntElt"}
  - {"name": "pSignature", "signature": "pSignature(L, p): Lat, RngIntElt -> RngIntElt"}
  - {"name": "Oddity", "signature": "Oddity(f): RngMPolElt -> RngIntElt"}
  - {"name": "Oddity", "signature": "Oddity(L): Lat -> RngIntElt"}
  - {"name": "Oddity", "signature": "Oddity(M): Mtrx -> RngIntElt"}
  - {"name": "pExcess", "signature": "pExcess(f, p): RngMPolElt, RngIntElt -> RngIntElt"}
  - {"name": "pExcess", "signature": "pExcess(M, p): Mtrx, RngIntElt -> RngIntElt"}
  - {"name": "pExcess", "signature": "pExcess(L, p): Lat, RngIntElt -> RngIntElt"}
  - {"name": "WittInvariant", "signature": "WittInvariant(f, p): RngMPolElt, RngIntElt -> RngIntElt"}
  - {"name": "WittInvariant", "signature": "WittInvariant(M, p): AlgMatElt, RngIntElt -> RngIntElt"}
  - {"name": "WittInvariant", "signature": "WittInvariant(L, p): Lat, RngIntElt -> RngIntElt"}
  - {"name": "WittInvariant", "signature": "WittInvariant(L, P): Lat, RngInt -> RngIntElt"}
  - {"name": "WittInvariant", "signature": "WittInvariant(L, P): LatNF, RngOrdIdl -> RngIntElt"}
  - {"name": "HasseInvariant", "signature": "HasseInvariant(f, p): RngMPolElt, RngIntElt -> RngIntElt"}
  - {"name": "HasseInvariant", "signature": "HasseInvariant(M, p): AlgMatElt, RngIntElt -> RngIntElt"}
  - {"name": "HasseMinkowskiInvariant", "signature": "HasseMinkowskiInvariant(f, p): RngMPolElt, RngIntElt -> RngIntElt"}
  - {"name": "HasseMinkowskiInvariant", "signature": "HasseMinkowskiInvariant(M, p): AlgMatElt, RngIntElt -> RngIntElt"}
  - {"name": "HasseInvariant", "signature": "HasseInvariant(L, p): Lat, RngIntElt -> RngIntElt"}
  - {"name": "HasseMinkowskiInvariant", "signature": "HasseMinkowskiInvariant(L, p): Lat, RngIntElt -> RngIntElt"}
  - {"name": "HasseInvariant", "signature": "HasseInvariant(L, P): Lat, RngInt -> RngIntElt"}
  - {"name": "HasseInvariant", "signature": "HasseInvariant(L, P): LatNF, RngOrdIdl -> RngIntElt"}
  - {"name": "HasseMinkowskiInvariant", "signature": "HasseMinkowskiInvariant(L, P): Lat, RngInt -> RngIntElt"}
  - {"name": "WittInvariants", "signature": "WittInvariants(f): RngMPolElt -> SeqEnum"}
  - {"name": "WittInvariants", "signature": "WittInvariants(M): AlgMatElt -> SeqEnum"}
  - {"name": "WittInvariants", "signature": "WittInvariants(L): Lat -> SeqEnum"}
  - {"name": "HasseInvariants", "signature": "HasseInvariants(f): RngMPolElt -> SeqEnum"}
  - {"name": "HasseInvariants", "signature": "HasseInvariants(M): AlgMatElt -> SeqEnum"}
  - {"name": "HasseInvariants", "signature": "HasseInvariants(L): Lat -> SeqEnum"}
  - {"name": "HasseMinkowskiInvariants", "signature": "HasseMinkowskiInvariants(f): RngMPolElt -> SeqEnum"}
  - {"name": "HasseMinkowskiInvariants", "signature": "HasseMinkowskiInvariants(M): AlgMatElt -> SeqEnum"}
  - {"name": "HasseMinkowskiInvariants", "signature": "HasseMinkowskiInvariants(L): Lat -> SeqEnum"}
  - {"name": "QuadraticFormInvariants", "signature": "QuadraticFormInvariants(f): RngMPolElt -> FldElt, SetEnum, SeqEnum[RngIntElt]"}
  - {"name": "QuadraticFormInvariants", "signature": "QuadraticFormInvariants(M): AlgMatElt -> FldElt, SetEnum, SeqEnum[RngIntElt]"}
  - {"name": "QuadraticFormInvariants", "signature": "QuadraticFormInvariants(L): LatNF -> FldElt, SetEnum, SeqEnum[RngIntElt]"}
---

# Local Invariants

These commands calculate the standard invariants that characterize a quadratic form over the rationals. Definitions of the invariants may be found in Conway-Sloane [[JC98](https://docs.magma-maths.org/v2.30-1/references.md#cite-conwaysloane)], Chapter 15, Section 5.1.

<a id="function-psignature-rngmpolelt-rngintelt"></a>
## `pSignature(f, p): RngMPolElt, RngIntElt -> RngIntElt`

<a id="function-psignature-mtrx-rngintelt"></a>
## `pSignature(M, p): Mtrx, RngIntElt -> RngIntElt`

<a id="function-psignature-lat-rngintelt"></a>
## `pSignature(L, p): Lat, RngIntElt -> RngIntElt`

The $p$-signature of the specified quadratic form over the rationals, where $p$ is a prime number or $-1$ (designating the real place).

For odd primes $p$, this is defined by diagonalizing the form, and adding $p$-parts of these entries to 4 times the number of anti-squares (mod $p$) amongst these entries. The term “anti-square” modulo $p$ denotes something that has: odd valuation at $p$; and the prime-to-$p$ part, called $u$, has Kronecker symbol $({u\over p})=-1$.

At $p=2$ it is the sum of the odd parts of the diagonalized entries plus 4 times the number of anti-squares. In either case, the final answer is really only defined modulo 8 (this is so that $p$-signatures are invariant under rational equivalence).

At the real place, it is the difference between the number of positive and negative eigenvalues (the terminology here can be murky).

<a id="function-oddity-rngmpolelt"></a>
## `Oddity(f): RngMPolElt -> RngIntElt`

<a id="function-oddity-lat"></a>
## `Oddity(L): Lat -> RngIntElt`

<a id="function-oddity-mtrx"></a>
## `Oddity(M): Mtrx -> RngIntElt`

This returns the $2$-signature of the given quadratic form over the rationals.

<a id="function-pexcess-rngmpolelt-rngintelt"></a>
## `pExcess(f, p): RngMPolElt, RngIntElt -> RngIntElt`

<a id="function-pexcess-mtrx-rngintelt"></a>
## `pExcess(M, p): Mtrx, RngIntElt -> RngIntElt`

<a id="function-pexcess-lat-rngintelt"></a>
## `pExcess(L, p): Lat, RngIntElt -> RngIntElt`

The $p$-excess of the specified quadratic form over the rationals, where $p$ is a prime number or $-1$ (designating the real place). The $p$-excess is the difference between the $p$-signature and dimension for odd primes (including $-1$), and is the negation of this for $p=2$. The sum of $p$-excesses over all primes should be 0 modulo 8.

<a id="function-wittinvariant-rngmpolelt-rngintelt"></a>
## `WittInvariant(f, p): RngMPolElt, RngIntElt -> RngIntElt`

<a id="function-wittinvariant-algmatelt-rngintelt"></a>
## `WittInvariant(M, p): AlgMatElt, RngIntElt -> RngIntElt`

Calculates the Witt invariant over ${\mathbb{Q}}_p$ of the given quadratic form. Again the form must be defined over either the rationals or the integers. The result is returned as something in the set $\{-1,+1\}$. This is the class in the Brauer group of the Clifford algebra for even dimension, of the even Clifford algebra for odd dimension, see §3 of Chapter V of Lam [[Lam05](https://docs.magma-maths.org/v2.30-1/references.md#cite-lam05)].

<a id="function-wittinvariant-lat-rngintelt"></a>
## `WittInvariant(L, p): Lat, RngIntElt -> RngIntElt`

<a id="function-wittinvariant-lat-rngint"></a>
## `WittInvariant(L, P): Lat, RngInt -> RngIntElt`

<a id="function-wittinvariant-latnf-rngordidl"></a>
## `WittInvariant(L, P): LatNF, RngOrdIdl -> RngIntElt`

```magma
AmbientSpace: BoolElt                    Default: false
```

The Witt invariant of the quadratic form at $p$ (or $P$). If `AmbientSpace` is set to `true`, returns the Witt invariant of the ambient quadratic space.

<a id="function-hasseinvariant-rngmpolelt-rngintelt"></a>
## `HasseInvariant(f, p): RngMPolElt, RngIntElt -> RngIntElt`

<a id="function-hasseinvariant-algmatelt-rngintelt"></a>
## `HasseInvariant(M, p): AlgMatElt, RngIntElt -> RngIntElt`

<a id="function-hasseminkowskiinvariant-rngmpolelt-rngintelt"></a>
## `HasseMinkowskiInvariant(f, p): RngMPolElt, RngIntElt -> RngIntElt`

<a id="function-hasseminkowskiinvariant-algmatelt-rngintelt"></a>
## `HasseMinkowskiInvariant(M, p): AlgMatElt, RngIntElt -> RngIntElt`

Calculates the Hasse (or Hasse-Minkowski) invariant over ${\mathbb{Q}}_p$ of the given quadratic form. Again the form must be defined over either the rationals or the integers. The result is returned as something in the set $\{-1,+1\}$. One definition of this invariant is to diagonalize the form and then take the product (in our multiplicative notation) of the Hilbert symbols of the ${n\choose 2}$ pairs of distinct nonzero diagonal entries, as in §5.3 of Chapter 15 of Conway-Sloane [[JC98](https://docs.magma-maths.org/v2.30-1/references.md#cite-conwaysloane)], which is what is implemented here. Another method would be to use a comparison of $p$-excesses with the standard form (also in Conway-Sloane). Starting with a $p$-adic input could lead to precision problems at the diagonalization step, and so is not allowed. Can also be called via `HasseMinkowskiInvariant`.

<a id="function-hasseinvariant-lat-rngintelt"></a>
## `HasseInvariant(L, p): Lat, RngIntElt -> RngIntElt`

<a id="function-hasseminkowskiinvariant-lat-rngintelt"></a>
## `HasseMinkowskiInvariant(L, p): Lat, RngIntElt -> RngIntElt`

<a id="function-hasseinvariant-lat-rngint"></a>
## `HasseInvariant(L, P): Lat, RngInt -> RngIntElt`

<a id="function-hasseinvariant-latnf-rngordidl"></a>
## `HasseInvariant(L, P): LatNF, RngOrdIdl -> RngIntElt`

<a id="function-hasseminkowskiinvariant-lat-rngint"></a>
## `HasseMinkowskiInvariant(L, P): Lat, RngInt -> RngIntElt`

```magma
AmbientSpace: BoolElt                    Default: false
```

The Hasse invariant of the quadratic form at $p$ (or at $P$). If `AmbientSpace` is set to `true`, returns the Hasse invariant of the ambient quadratic space.

<a id="function-wittinvariants-rngmpolelt"></a>
## `WittInvariants(f): RngMPolElt -> SeqEnum`

<a id="function-wittinvariants-algmatelt"></a>
## `WittInvariants(M): AlgMatElt -> SeqEnum`

<a id="function-wittinvariants-lat"></a>
## `WittInvariants(L): Lat -> SeqEnum`

<a id="function-hasseinvariants-rngmpolelt"></a>
## `HasseInvariants(f): RngMPolElt -> SeqEnum`

<a id="function-hasseinvariants-algmatelt"></a>
## `HasseInvariants(M): AlgMatElt -> SeqEnum`

<a id="function-hasseinvariants-lat"></a>
## `HasseInvariants(L): Lat -> SeqEnum`

<a id="function-hasseminkowskiinvariants-rngmpolelt"></a>
## `HasseMinkowskiInvariants(f): RngMPolElt -> SeqEnum`

<a id="function-hasseminkowskiinvariants-algmatelt"></a>
## `HasseMinkowskiInvariants(M): AlgMatElt -> SeqEnum`

<a id="function-hasseminkowskiinvariants-lat"></a>
## `HasseMinkowskiInvariants(L): Lat -> SeqEnum`

```magma
Minimize: BoolElt                    Default: false
AA      : BoolElt                    Default: false
```

Compute `WittInvariant(f,p)` or `HasseInvariant(f,p)`, repsectively, for all bad primes $p$, and return the result of a sequence of tuples, each entry given by $\langle p,W_p(f)\rangle$. The set of bad primes includes the real place, the prime $p=2$, and all primes that divide either the numerator or the denominator of the determinant or symmetric matrix associated to $f$. If `Minimize` is set, the primes greater than 2 must have odd valuation in the determinant to appear. If `AA` is set, the result is return as an associative array. Can also be called via `HasseMinkowskiInvariants`.

<a id="function-quadraticforminvariants-rngmpolelt"></a>
## `QuadraticFormInvariants(f): RngMPolElt -> FldElt, SetEnum, SeqEnum[RngIntElt]`

<a id="function-quadraticforminvariants-algmatelt"></a>
## `QuadraticFormInvariants(M): AlgMatElt -> FldElt, SetEnum, SeqEnum[RngIntElt]`

<a id="function-quadraticforminvariants-latnf"></a>
## `QuadraticFormInvariants(L): LatNF -> FldElt, SetEnum, SeqEnum[RngIntElt]`

```magma
Minimize: BoolElt                    Default: false
AA      : BoolElt                    Default: false
```

The determinant of the diagonalization, the set of Hasse-Minkowski invariants, and the number of negative eigenvalues (in each real place) of the quadratic form M. If `AA` is set, the Hasse-Minkowski invariants are returned as an associative array. If `Minimize` is set, the set of Hasse-Minkowski invariants is minimized, returning only the prime ideals for which the Hasse-Minkowski invariant is $-1$.
