FP2 5.6 - Solving congruence equations

FP2 5.6 - Solving congruence equations

Decide whether a linear congruence has solutions, find multiplicative inverses using Bezout's identity, and solve with the correct modulus. Describe every solution, including the multiple residue classes that occur when the coefficient and modulus are not coprime.

Check the coefficient and modulus before trying to solve

Why does 42x≡30(mod66)42x\equiv30\pmod{66} have six solution residues modulo 6666, while changing 3030 to 3131 leaves none? Multiplication can merge remainder classes, so a congruence equation need not behave like an ordinary equation with one answer. The common factor of the coefficient and modulus controls what is possible.

You already know

a≡b(modn)a\equiv b\pmod n means n∣(a−b)n\mid(a-b). Euclid finds the positive highest common factor gcd⁡(a,n)\gcd(a,n), and back substitution expresses it as an integer combination of a,na,n. Cancelling a factor while keeping the modulus is safe only when that factor is coprime to the modulus. A residue class x≡r(modn)x\equiv r\pmod n means all integers r+knr+kn, k∈Zk\in\mathbb Z.

In a linear congruence ax≡b(modn)ax\equiv b\pmod n, the unknown is an integer xx, the coefficient and right-hand side are integers, and the modulus here is an integer n≥2n\ge2. Asking for solutions modulo nn means identifying which classes of integers satisfy the condition, usually using representatives 0,1,…,n−10,1,\ldots,n-1.

Existence of solutions

Let d=gcd⁡(a,n)>0d=\gcd(a,n)>0. Then

ax≡b(modn)has an integer solution exactly whend∣bax\equiv b\pmod n \quad\text{has an integer solution exactly when}\quad d\mid b

When solutions exist, there are exactly dd distinct solution classes modulo nn.

Not in the formula booklet: learn it.

Here is why the existence test works. The congruence is equivalent to ax+ny=bax+ny=b for some integer yy. Since dd divides both a,na,n, it must divide bb: this is necessary.

Conversely, suppose b=dhb=dh. Bezout gives integers u,vu,v with au+nv=dau+nv=d. Multiply this identity by hh:

a(uh)+n(vh)=dh=ba(uh)+n(vh)=dh=b

Thus x=uhx=uh is a solution. The condition is sufficient too. We will justify the count of dd classes when reducing the modulus below.

For the opening equation, d=gcd⁡(42,66)=6d=\gcd(42,66)=6. This divides 3030, so solutions exist, but does not divide 3131, so the changed equation has none. Having no multiplicative inverse of 4242 modulo 6666 does not rule out every right-hand side.

Key idea

Find gcd⁡(a,n)\gcd(a,n), using the coefficient and the modulus. Check whether it divides the right-hand side before attempting an inverse or searching for a residue.

Test the condition on a new equation.

Read a multiplicative inverse from an identity equal to one

To undo multiplication by aa while keeping modulus nn, seek an integer uu with au≡1(modn)au\equiv1\pmod n. Then multiplying a congruence by uu turns its coefficient into 11.

Multiplicative inverse

An inverse of aa modulo n≥2n\ge2 exists exactly when gcd⁡(a,n)=1\gcd(a,n)=1. If Bezout's identity gives

au+nv=1au+nv=1

then

au≡1(modn)au\equiv1\pmod n

and uu is a multiplicative inverse of aa. Any integer congruent to uu is also an inverse.

Not in the formula booklet: learn it.

The identity proves sufficiency. For necessity, au≡1(modn)au\equiv1\pmod n gives an integer combination of a,na,n equal to 11, so their highest common factor is 11. This is why 1/a1/a as an ordinary fraction is not a substitute for finding an integer inverse.

Worked example 1: a negative Bezout coefficient

Question. Use Bezout's identity to find a multiplicative inverse of 1717 modulo 4343, giving the least nonnegative representative.

Plan. Use Euclid and back substitution to express 11 in terms of 17,4317,43, then reduce the coefficient of 1717.

43=2(17)+917=9+89=8+18=8(1)+0highest common factor is 1\begin{aligned} 43&=2(17)+9\\ 17&=9+8\\ 9&=8+1\\ 8&=8(1)+0 && \text{highest common factor is }1 \end{aligned} 1=9−8last nonzero remainder=9−(17−9)=2(9)−17replace 8=2(43−2(17))−17replace 9=2(43)−5(17)original inputs only\begin{aligned} 1&=9-8 && \text{last nonzero remainder}\\ &=9-(17-9)=2(9)-17 && \text{replace }8\\ &=2(43-2(17))-17 && \text{replace }9\\ &=2(43)-5(17) && \text{original inputs only} \end{aligned}

Why this step? The coefficient of 1717, not the coefficient of the modulus, is the inverse. A negative coefficient is allowed.

Answer. An inverse is −5≡38(mod43)-5\equiv38\pmod{43}, so the requested representative is 3838.

Check. 17(38)=646=15(43)+117(38)=646=15(43)+1.

Keep modulus 4343; change only the coefficient from 1717 to 1818.

Worked example 2: recalculate the inverse after changing the coefficient

Question. Find the least nonnegative inverse of 1818 modulo 4343 using Bezout's identity.

Plan. Recompute the remainder chain and substitute backwards; the inverse of 1717 cannot be reused.

43=2(18)+718=2(7)+47=4+34=3+13=3(1)+0\begin{aligned} 43&=2(18)+7\\ 18&=2(7)+4\\ 7&=4+3\\ 4&=3+1\\ 3&=3(1)+0 \end{aligned} 1=4−3=4−(7−4)replace 3=2(4)−7collect terms=2(18−2(7))−7replace 4=2(18)−5(7)=2(18)−5(43−2(18))replace 7=12(18)−5(43)\begin{aligned} 1&=4-3=4-(7-4) && \text{replace }3\\ &=2(4)-7 && \text{collect terms}\\ &=2(18-2(7))-7 && \text{replace }4\\ &=2(18)-5(7)\\ &=2(18)-5(43-2(18)) && \text{replace }7\\ &=12(18)-5(43) \end{aligned}

Why this step? Reducing this identity modulo 4343 removes its 4343-term and leaves 12(18)≡112(18)\equiv1.

Answer. The inverse is 1212.

Check. 18(12)=216=5(43)+118(12)=216=5(43)+1.

The inverse is a residue class, so −5-5 and 3838 are equally valid during working in the first example. A requested least nonnegative answer must be in 00 to 4242.

Watch out

Wrong: take 22 as the inverse of 1717 from 1=2(43)−5(17)1=2(43)-5(17). Right: take −5-5, the coefficient multiplying 1717, then reduce it if a representative is requested.

Change the coefficient by one again.

Multiply by the inverse and state the full residue class

When gcd⁡(a,n)=1\gcd(a,n)=1, an inverse uu gives

ax≡b(modn)⟺x≡ub(modn)ax\equiv b\pmod n \quad\Longleftrightarrow\quad x\equiv ub\pmod n

The forward step multiplies by uu; the reverse step multiplies by aa. Thus the method preserves all solutions, not just one candidate. This solving rule follows from the inverse and is not separately printed in the formula booklet.

There is one solution class modulo nn, containing infinitely many integers. A bare integer is only one representative unless the question asks for a single value in a specified range.

Worked example 3: use the inverse already found

Question. Solve 17x≡9(mod43)17x\equiv9\pmod{43}, giving all integer solutions.

Plan. Multiply both sides by the inverse 3838, reduce the right-hand side, then write the full class.

38(17x)≡38(9)(mod43)multiply both sidesx≡342≡41(mod43)342=7(43)+41\begin{aligned} 38(17x)&\equiv38(9)\pmod{43} && \text{multiply both sides}\\ x&\equiv342\equiv41\pmod{43} && 342=7(43)+41 \end{aligned}

Why this step? The modulus stays 4343 because multiplying by an inverse is reversible. No division by 1717 as an ordinary fraction is used.

Answer. x≡41(mod43)x\equiv41\pmod{43}, or x=41+43kx=41+43k for k∈Zk\in\mathbb Z.

Check. 17(41)−9=688=16(43)17(41)-9=688=16(43). Increasing xx by 4343 changes 17x17x by a multiple of 4343, so the whole class works.

Keep the coefficient and modulus fixed; change only the right-hand side from 99 to 1010.

Worked example 4: a changed right-hand side uses the same inverse

Question. Solve 17x≡10(mod43)17x\equiv10\pmod{43}.

Plan. Retain inverse 3838 and apply it to the new right-hand side.

x≡38(10)=380(mod43)multiply by the inverse≡36(mod43)380=8(43)+36\begin{aligned} x&\equiv38(10)=380\pmod{43} && \text{multiply by the inverse}\\ &\equiv36\pmod{43} && 380=8(43)+36 \end{aligned}

Why this step? The inverse depends on the coefficient and modulus, so changing only the right-hand side does not require a new Euclidean algorithm.

Answer. x≡36(mod43)x\equiv36\pmod{43}, equivalently x=36+43kx=36+43k, k∈Zk\in\mathbb Z.

Check. 17(36)−10=602=14(43)17(36)-10=602=14(43).

The final statement must retain the modulus. It describes which repeated integer values work, rather than suggesting that xx equals just its smallest nonnegative representative.

Watch out

Wrong: finish “x=36x=36” when asked to solve over the integers. Right: state x≡36(mod43)x\equiv36\pmod{43}, or x=36+43kx=36+43k with k∈Zk\in\mathbb Z.

Change only the right-hand side again.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account