0

I want to calculate, how many solutions there are that satisfy the equation $x^2 \equiv x^4 \mod n$

My approach is to write $x$ as the $t$-th power of a primitive root $g$ and solve

$(g^{t})^2 \equiv (g^{t})^4 \mod n$

$g^{2t} \equiv g^{4t} \mod n$

Knowing that $g$ is a generator we get

$2t \equiv 4t \mod \phi(n)$

$2t \equiv 0 \mod \phi(n)$

So knowing that $ \phi(n) \ | \ 2t$ , the amount of solutions t we get is

$\gcd(2t, \phi(n))$ as the amount of solutions.

As experiments show, that solution is false. Does anyone see the error or know how to find the number of solutions?

Bill Dubuque
  • 272,048
  • 2
    Primitive roots do not exist for all $n$, only for some $n$ (such as primes). Even where you have a primitive root, powers of that would only give you residues relatively prime to $n$ and, clearly, your congruence has solutions which share factors with $n$. – lulu May 28 '21 at 09:56
  • 1
    For this question to make sense you need to specify the domain over which you are trying to solve the equation. Is it ${ 0,1,2,\ldots,n-1}$ or are you restricting to elements coprime to $n$? – Derek Holt May 28 '21 at 10:42

1 Answers1

1

Hint: It suffices to count the number of roots mod the prime factors $\,p^k\,$ of $\,n.\,$ Multiplying these counts yields the result, as follows by CRT as explained here.

Note that odd $\,p^k \mid x^4-x^2 = x^2(x-1)(x+1)\iff p^k\mid x^2\,$ or $\,p^k\mid x-1\,$ or $\,p^k\mid x+1\,$ since the three factors are pairwise coprime to $\,p\,$ (e.g. $\,(x\!-\!1,x\!+\!1,p) = (x\!-\!1,2,p) = 1\,$ by $\,p\,$ odd), and its easy to count the number of roots $\!\bmod p^k\,$ in each of the $3$ cases.

For $\,p=2\,$ we have to account for the fact that they are no longer coprime since $\,x\!-\!1\equiv x\!+\!1,\,$ but this presents no great difficulty.

Bill Dubuque
  • 272,048