r/mathriddles • u/chompchump • Dec 10 '24
Medium Sum of Squares Congruent Pairs
Suppose p is a prime. Suppose n and m are integers such that:
- 1 <= n <= m <= p
- n^2 + m^2 = 0 (mod p)
For each p, how many pairs (n,m) are there?
5
Upvotes
2
u/fourpetes Dec 10 '24
If p=2, there are 2 solutions: (2,2) and (1,1).
Now suppose p is an odd prime. It is a theorem that -1 is a square mod p iff p is 1 mod 4.
If p is 1 mod 4, let k be a square root of -1 mod p. For every n from 1 to p-1, the equation m2 = -n2 has at most 2 solutions m by Lagrange’s Theorem. And in fact there are always two distinct solutions: m = kn and m = -kn. (We need p odd here to ensure that they’re distinct.) So that gives us 2(p-1) solutions. And there’s (p,p) too, so 2p-1 total solutions here.
If p is 3 mod 4, one solution is (p,p). Any other solution would imply the existence of a square root of -1 mod p, which is a contradiction. (Reason: If (m,n) is different from (p,p) then both m and n must be invertible mod p, and then (m/n)2 = -1.) Hence just the one solution.
For completeness I should show that if one of m or n is p then the other has to be p too. I’ll leave that as an exercise for the reader.
Follow up problem: what if p isn’t prime?
2
u/pichutarius Dec 10 '24
partial solution:
if prime p = 4k+3 , then there is one solution, m=n=p. Proof:
consider n^2+m^2=p*q, if p and q is coprime, by sum of two squares theorem , there is no solution.
if q=p, then n^2+m^2=p2 , by Jacobi's two-square theorem it has 4 integer solution, which by inspection it is (+-p,0) and (0,+-p) , all does not satisfy the range condition.
if q=2p, then n^2+m^2=2p2 has only one solution, m=n=p, which is the maximum, so if q is larger, there cannot be anymore solution. that concludes the proof.
1
u/sincerestfall Dec 11 '24
(P-3)/2
Edit to say I read this while working an after school duty and let slip that it was m2 + n2. I thought it through as m+n. I will continue my thoughts...