LegendreSymbol
The Legendre symbol (n/p): whether n is a quadratic residue mod the odd prime p.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wikipedia
Legendre symbolMathWorldLegendreSymbolWikidataQ748339Wolfram LanguageJacobiSymbol!LegendreSymbol(n, p)the Legendre symbol .SageMath
legendre_symbol(n, p)SymPylegendre_symbol(n, p)Typed signatures
| Type | Package | Applies |
|---|---|---|
(integer, integer) -> integer | compute-engine | always |
Details
- 1 if is a nonzero quadratic residue mod , if it is a nonresidue, 0 if .
- Defined only for an odd prime ; compute-engine leaves the call symbolic for any other .
- The prime case of JacobiSymbol and KroneckerSymbol — all three agree wherever the domains overlap.
Plot
Examples
Basic #
Properties #
Possible issues #
About
| Examples | 7 |
|---|---|
| Checked against | Wolfram Language 6 agree1 differSageMath 6 agree1 errorSymPy 6 agree1 errormathlib4 4 agree1 unevaluated1 error |
| Crosswalk | WikipediaMathWorldWikidataWolfram LanguageSageMathSymPy |
Implementation
mapped
sympypackages/oracle/src/mappings.tsSymPy's legendre_symbol raises unless the lower argument is an odd prime.
mapped
sagepackages/oracle/src/mappings.tsmapped
mathlib4packages/oracle/src/mappings.tsMathlib's legendreSym needs a Fact p.Prime instance a literal cannot supply, so this reads jacobiSym a p, which Mathlib proves equal to legendreSym p a at an odd prime p (jacobiSym.legendreSym.to_jacobiSym); a composite or even p is outside the Legendre domain and gives the Jacobi value or zero.
See also: JacobiSymbol, KroneckerSymbol