The exercise presented here connects the most important results seen so far. It is a summary.
Exercise.
Find all integers x such that
717x2≡2395(mod970).
Hint.
97 is a prime.
Warning:
As always, if you read the solution before trying to solve the exercise yourself, you are likely wasting your time.
Solution.
Step 1: Linearize
I use the Euclidean algorithm to find the inverse of 717 mod 970. First, I iterate the Q-R formula:
Step
Equation
1
970=717×1+253
2
717=253×2+211
3
253=211×1+42
4
211=42×5+1
5
42=1×42+0(optional)
Second, I plug the remainders back in reverse order:
Step
Equation
4
1=211+(–5)42
3
=211+(–5)[253+(–1)211]=6×211+(–5)253
2
=6[717+(–2)253]+(–5)253=(6)717+(–17)253
1
=(6)717+(–17)[970+(–1)253]=(23)717+(–17)970
Reducing mod 970, I have 1≡23⋅717, hence the inverse is 23. Substituting y=x2, the congruence to solve becomes
y≡2396(mod970).
Step 2: Divide
Factoring 970=2⋅5⋅97. By the Chinese remainder theorem, solving the above is equivalent to solving the system
y≡2396(mod2)y≡2396(mod5)y≡2396(mod97)
The middle congruence easily reduces to y≡22396≡2196=1. And the only integer whose square is 1 mod 2 is 1, thus x≡21.
The right congruence simplifies to y≡52396≡5(−2)96=296.
Hint.
The latter can easily be solved by cases since 5 is small. However, if the prime factor were large, such as the case of 97, guessing and checking is unfeasible.
By Fermat’s little theorem, 24≡51, and since 4∣96,
296=24⋅(96/4)=(24)96/4≡5196/4=1.
In the lectures I prove that the only square roots of 1 mod a prime are ±1. Then, x≡51,4.
Now, again by Fermat’s little theorem, 2396≡1(mod97). Therefore, the system reduces to
x≡1(mod2)x≡1,4(mod5)x≡1,96(mod97)
Hint.
What do the commas in the last two congruences mean precisely? I am no longer trying to solve one system, but four. Here is the precise logical statement:
Clearly x=1 solves one of the systems, so by the Chinese remainder theorem, x=1 is the only solution mod 970 to the first system. x=−1 is a solution to another one of the systems.
Since the first congruence only says x is odd, I omit it to reduce clutter. The remaining two systems are
x≡1(mod5)x≡96(mod97)x≡4(mod5)x≡1(mod97)
The top one is solved by taking the second congruence as x=97k−1 for some k, and plugging it into the second one: 1≡x=97k−1≡2k−1(mod5), from where k=5ℓ+1 for some ℓ. Hence, x=97(5ℓ+1)−1; but I want x to be odd, so I can pick ℓ=1 and get x=581.
Reflect.
Any value of ℓ that makes 97(5ℓ+1)−1 odd produces a valid solution x. You have understood how to solve systems of congruences when you can explain why. Also, why did I plug the second congruence into the first one and not the other way around?
The bottom one is solved exactly the same way to get x=389.
Step 4: Multiply
By the Chinese remainder theorem, the final answer is
x≡1,389,581,969(mod970),
so the set of all integer solutions is
{970n+m:n∈Z,m∈{1,389,581,969}}.
Exercise.
What is the shortest computer program you can write that solves this problem? What about the fastest?
Solution.
# This is Python3.*[x for x in range(970) if (717*x**2)%970 == 23**95%970]>>>1, 389, 581, 969
Exercise.
Try solving the same initial congruence but with x3 instead of x2. Do you expect to find more solutions or fewer mod 970?