Skip to content

KroneckerSymbol ​

The Kronecker symbol (a/n): the Jacobi symbol extended to every integer n.

✓ checked against that system · ! checked, with disagreements (hover a chip)FungrimKroneckerSymbolWolfram LanguageKroneckerSymbol✓
KroneckerSymbol(a, n)the Kronecker symbol (an)\left(\frac{a}{n}\right).
SageMathkronecker(a, n)SymPykronecker_symbol(a, n)Oscarkronecker_symbol(ZZ(a), ZZ(n))Juliakronecker_symbol(ZZ(a), ZZ(n))
Typed signatures
TypePackageApplies
(integer, integer) -> integermodularalways

Domain: Number theory

Details
  • Agrees with JacobiSymbol wherever nn is odd and positive, and with LegendreSymbol where nn is also prime — this is the head above both.
  • (a0)=1\left(\frac{a}{0}\right)=1 if a=±1a=\pm1, else 0; (a−1)=1\left(\frac{a}{-1}\right)=1 if a≥0a\ge0, −1-1 if a<0a<0.
  • (a2)=0\left(\frac{a}{2}\right)=0 for even aa; 11 if a≡±1(mod8)a\equiv\pm1\pmod 8; −1-1 if a≡±3(mod8)a\equiv\pm3\pmod 8 — this is the piece Jacobi's odd-nn restriction leaves out.
  • Completely multiplicative in nn: (an1n2)=(an1)(an2)\left(\frac{a}{n_1n_2}\right)=\left(\frac{a}{n_1}\right)\left(\frac{a}{n_2}\right).
  • Bignum-safe: both arguments may exceed the double-precision range.

Plot

Examples

37 more kept as data, checked against the oracles
Basic #
live ↗
InKroneckerSymbol(17,6)\mathrm{KroneckerSymbol}(17, 6)Out−1-1
live ↗
InKroneckerSymbol(10,13)\mathrm{KroneckerSymbol}(10, 13)Out11

0 whenever |a| ≠ 1 and n = 0

live ↗
InKroneckerSymbol(5,0)\mathrm{KroneckerSymbol}(5, 0)Out00

(a/-1) is the sign of a — here a < 0

live ↗
InKroneckerSymbol(−3,−1)\mathrm{KroneckerSymbol}(-3, -1)Out−1-1

(a/2): odd a, and 3 mod 8 = 3, one of the two residues giving -1

live ↗
InKroneckerSymbol(3,2)\mathrm{KroneckerSymbol}(3, 2)Out−1-1
Scope #

Threads element-wise over a list, as Wolfram's Listable heads do

live ↗
InKroneckerSymbol([2,3,5,7,11],6)\mathrm{KroneckerSymbol}(\bigl\lbrack2, 3, 5, 7, 11\bigr\rbrack, 6)Out[0,0,1,1,1]\bigl\lbrack0, 0, 1, 1, 1\bigr\rbrack

Larger arguments: 1011+110^{11}+1 against the 2000th prime, 17389

live ↗
InKroneckerSymbol(1011+1,NthPrime(2 000))\mathrm{KroneckerSymbol}(10^{11}+1, \mathrm{NthPrime}(2\,000))Out−1-1

Even nn, where JacobiSymbol is undefined: (7/2)(7/3)=1⋅1(7/2)(7/3)=1\cdot1

live ↗
InKroneckerSymbol(7,6)\mathrm{KroneckerSymbol}(7, 6)Out11

A character periodic mod 77 has a rational generating function with denominator of degree 66

live ↗
InGeneratingFunction(KroneckerSymbol(n,7),n,x)\mathrm{GeneratingFunction}(\mathrm{KroneckerSymbol}(n, 7), n, x)Outx5+2x4+x3+2x2+xx6+x5+x4+x3+x2+x+1\frac{x^5+2x^4+x^3+2x^2+x}{x^6+x^5+x^4+x^3+x^2+x+1}
Applications #

The character mod 4: (−4/p)=−1(-4/p)=-1 for primes p≡3(mod4)p\equiv3\pmod4

live ↗
InKroneckerSymbol(−4,7)\mathrm{KroneckerSymbol}(-4, 7)Out−1-1

Depends only on the residue mod 77: 23≡223 \equiv 2

live ↗
InKroneckerSymbol(2,7)=KroneckerSymbol(23,7)\mathrm{KroneckerSymbol}(2, 7)=\mathrm{KroneckerSymbol}(23, 7)OutTrue\mathrm{True}

Threads over moduli; −4-4 is a square mod 11 and 55 but not mod 77 or 1111

live ↗
InKroneckerSymbol(−4,[1,5,7,11])\mathrm{KroneckerSymbol}(-4, \bigl\lbrack1, 5, 7, 11\bigr\rbrack)Out[1,1,−1,−1]\bigl\lbrack1, 1, -1, -1\bigr\rbrack
Properties #

Completely multiplicative in n

live ↗
InKroneckerSymbol(7,3×5)=KroneckerSymbol(7,3)KroneckerSymbol(7,5)\mathrm{KroneckerSymbol}(7, 3×5)=\mathrm{KroneckerSymbol}(7, 3)\mathrm{KroneckerSymbol}(7, 5)OutTrue\mathrm{True}

Zero whenever gcd⁡(9,12)>1\gcd(9,12) > 1

live ↗
InKroneckerSymbol(9,12)\mathrm{KroneckerSymbol}(9, 12)Out00

Multiplicative in the top argument

live ↗
InKroneckerSymbol(12,7)=KroneckerSymbol(3,7)KroneckerSymbol(4,7)\mathrm{KroneckerSymbol}(12, 7)=\mathrm{KroneckerSymbol}(3, 7)\mathrm{KroneckerSymbol}(4, 7)OutTrue\mathrm{True}

Multiplicative in the bottom argument: 63=9⋅763 = 9\cdot7

live ↗
InKroneckerSymbol(3,63)=KroneckerSymbol(3,9)KroneckerSymbol(3,7)\mathrm{KroneckerSymbol}(3, 63)=\mathrm{KroneckerSymbol}(3, 9)\mathrm{KroneckerSymbol}(3, 7)OutTrue\mathrm{True}
Possible issues #

(a/0)=1(a/0)=1 for a=±1a=\pm1

live ↗
InKroneckerSymbol(−1,0)\mathrm{KroneckerSymbol}(-1, 0)Out11
About
Examples54
Checked againstWolfram Language 54 agreeSageMath 53 agreeSymPy 53 agreeOscar 50 agreeJulia 52 agree
CrosswalkFungrimWolfram LanguageSageMathSymPyOscarJulia

Implementation

mappedoscarpackages/oracle/src/mappings.ts
mappedwolframpackages/oracle/src/mappings.ts
mappedsympypackages/oracle/src/mappings.ts

kronecker_symbol is SymPy's extension of the Jacobi symbol to every integer n.

mappedsagepackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts

See also: JacobiSymbol, LegendreSymbol