2

I am looking for a systematic way of deciding if a given number is a square in $\Bbb Z/n\Bbb Z$.

E.g. is $89$ a square in $\Bbb Z/n\Bbb Z$ for $n\in \{25,33,49\}$? Brute-forcing it would take too long here. How else can we do this?

MyNameIs
  • 1,007

3 Answers3

5

Legendre symbols are for quadratic residues modulo a prime number. Jacobi symbols are an extension to non-prime moduli, defined in terms of the Legendre symbols of the prime factors of the modulus. Unfortunately, they cannot be used to test if a number is a quadratic residue, unless the modulus itself is prime. They only can be used in some cases to prove a number is a non-quadratic residue.

Here, for for instance, the Jacobi symbols $\biggl(\dfrac{89}{25}\biggr)=\biggl(\dfrac{89}{5}\biggr)^2=\biggl(\dfrac{4}{5}\biggr)^2=1^2=1$ and $\biggl(\dfrac{89}{49}\biggr)=\biggl(\dfrac{89}{7}\biggr)^2=\biggl(\dfrac{5}{7}\biggr)^2=(-1)^2=1$ are necessarily equal to $1$ by the rule of signs.

Brute force computation show $89\equiv 14\equiv 8^2\mod 25$.

Legendre symbol $\biggl(\dfrac{89}{7}\biggr)=-1$ shows $89$ is a non-quadratic residue mod $7$, hence it can't be a quadratic residue mod $49$.

For $33$, which is square-free, it's simpler, as you can use the Chinese remainder theorem : $$\mathbf Z/33\mathbf Z\simeq \mathbf Z/3\mathbf Z\times \mathbf Z/11\mathbf Z$$ so $89$ is a quadratic residue mod $33$ if and only if it is a quadratic residue both mod $3$ and mod $11$. Now $\biggl(\dfrac{89}{3}\biggr)=\biggl(\dfrac{2}{3}\biggr)=-1$, so $89$ is a non-quadratic residue mod $33$.

Bernard
  • 175,478
2

A systematic way to check if some number $a$ is a square modulo $n$ is to investigate if $a$ is a square modulo $p$ for all prime factors of $n$ and try to draw conclusions from there. The Jacobi symbol can help but it can only assure that $a$ is not a square modulo $n$ unless $n$ is prime. Let's consider your cases.

We have $25 = 5^2$ so, if $89 \equiv 14 \equiv x^2 \pmod{25}$, then definitely $14 \equiv 4 \equiv x^2 \pmod 5$. We see that a solution must be of the form $x\equiv \pm 2 \pmod{5}$. In $\mathbb{Z}/25\mathbb{Z}$ these $x$ are of the form $\pm 2 + 5k$ with $k\in \{0,1,2,3,4\}$. We notice that $$(\pm 2 + 5k)^2 \equiv 4 \pm 20k + 25 k^2 \equiv 4 \mp 5k \pmod{25}.$$ We want to find a value for $k$ and a sign for $\mp$ such that this is equal to $14$ modulo $25$. Clearly such a solution exists for $k = 2$ and $\mp = +$. So $89$ is a square modulo $25$. We have also calculated a specific solution, namely $x \equiv -2 + 5\cdot 2 \equiv 8 \pmod{25}$.

For $n= 33 =3 \cdot 11$ the Jacobi symbol becomes useful. We see $$ \left(\frac{89}{33}\right)=\left(\frac{89}{3}\right)\cdot \left(\frac{89}{11}\right)=\left(\frac{2}{3}\right)\cdot \left(\frac{1}{11}\right)=-1\cdot 1 = -1. $$ This gives us a definitive answer that $89$ is not a square modulo $33$.

For $n = 49 = 7^2$ we again investigate if $89 \equiv 5 \equiv x^2 \pmod{7}$ has a solution. By a very small brute force you can see that it doesn't. So since $89$ is not a square modulo $7$, it certainly can't be a square modulo $49$.

Pjotr5
  • 2,187
  • 1
  • 13
  • 17
1

The other answers are incomplete (they are inconclusive when the Jacobi symbol $= 1)$. Better, the Euler criterion is easily generalized to yield the following test for modular squareness.

Theorem $\ $ Let $\ a,\,n\,$ be integers, with $\,a\,$ coprime to $\,n\ =\ 2^e \,p_1^{e_1}\cdots p_k^{e_k}\,,\ \ p_i\,$ primes.

$\quad\quad \ x^2\equiv a \pmod n\,\ $ is solvable for $\,x\,$

$\quad\quad \, \iff\ \ \, a^{\large (p_i - 1)/2} \equiv 1 \pmod{p_i}\quad\quad\ \ $ for all $\ i\le k$

$\quad\quad\ $ and $\quad\ \ e>1 \,\Rightarrow\, a\equiv 1\pmod{\! 2^{2+\delta}},\ \ \ \delta = 1\ \ {\rm if}\ \ e\ge 3\ \ {\rm else}\ \ \delta = 0$

Proof $ $ (Hint) $ $ Use the Chinese Remainder Theorem to reduce to the prime power case, and then use Hensel's lemma to reduce to the prime case. For details see e.g. Ireland and Rosen, A Classical Introduction to Modern Number Theory, Proposition 5.1.1 p.50.

The above criterion is practical if one knows a full factorization of $\,n,\,$ since the exponentiations may be quickly computed by repeated squaring.

Beware $\ $ The criterion cannot be expressed equivalently as a simple Jacobi symbol calculation. For example we have $(8|15) = 1\ $ but $\,8\,$ is not a square $\,\rm (mod\ 15)$.

Bill Dubuque
  • 272,048