Legendre symbol #
This file contains results about Legendre symbols.
We define the Legendre symbol $\Bigl(\frac{a}{p}\Bigr)$ as legendreSym p a
.
Note the order of arguments! The advantage of this form is that then legendreSym p
is a multiplicative map.
The Legendre symbol is used to define the Jacobi symbol, jacobiSym a b
, for integers a
and (odd) natural numbers b
, which extends the Legendre symbol.
Main results #
We also prove the supplementary laws that give conditions for when -1
is a square modulo a prime p
:
legendreSym.at_neg_one
and ZMod.exists_sq_eq_neg_one_iff
for -1
.
See NumberTheory.LegendreSymbol.QuadraticReciprocity
for the conditions when 2
and -2
are squares:
legendreSym.at_two
and ZMod.exists_sq_eq_two_iff
for 2
,
legendreSym.at_neg_two
and ZMod.exists_sq_eq_neg_two_iff
for -2
.
Tags #
quadratic residue, quadratic nonresidue, Legendre symbol
Definition of the Legendre symbol and basic properties #
The Legendre symbol of a : ℤ
and a prime p
, legendreSym p a
,
is an integer defined as
0
ifa
is0
modulop
;1
ifa
is a nonzero square modulop
-1
otherwise.
Note the order of the arguments! The advantage of the order chosen here is
that legendreSym p
is a multiplicative function ℤ → ℤ
.
Equations
- legendreSym p a = (quadraticChar (ZMod p)) ↑a
Instances For
We have the congruence legendreSym p a ≡ a ^ (p / 2) mod p
.
If p ∤ a
, then legendreSym p a
is 1
or -1
.
The Legendre symbol of p
and a
is zero iff p ∣ a
.
The Legendre symbol is multiplicative in a
for p
fixed.
The Legendre symbol is a homomorphism of monoids with zero.
Equations
- legendreSym.hom p = { toFun := legendreSym p, map_zero' := ⋯, map_one' := ⋯, map_mul' := ⋯ }
Instances For
The square of the symbol is 1 if p ∤ a
.
The Legendre symbol of a^2
at p
is 1 if p ∤ a
.
The Legendre symbol depends only on a
mod p
.
When p ∤ a
, then legendreSym p a = 1
iff a
is a square mod p
.
legendreSym p a = -1
iff a
is a nonsquare mod p
.
Applications to binary quadratic forms #
The value of the Legendre symbol at -1
#
See jacobiSym.at_neg_one
for the corresponding statement for the Jacobi symbol.
legendreSym p (-1)
is given by χ₄ p
.