FP2 5.3 - Modular arithmetic and congruences

FP2 5.3 - Modular arithmetic and congruences

Calculate with remainders using congruence notation (FP2 5.3). You will use the equivalence, addition, subtraction, multiplication and power laws, while keeping the modulus fixed and checking before cancelling.

Congruence means the same remainder

A machine returns to its starting setting after every seven turns. Can one backwards turn leave it at the same setting as six forwards turns? We need a language that remembers the setting and discards complete cycles.

You already know

The division theorem writes an integer as a=nq+ra=nq+r, where n>0n>0 and 0≤r<n0\leq r<n. Two integers have the same remainder precisely when their difference is a multiple of nn. Euclid finds gcd⁡(a,n)\gcd(a,n), and Bezout's identity expresses it as an integer combination.

A congruence compares remainders, rather than asserting that two integers are equal.

Congruence and residues

For integers a,ba,b and a positive integer modulus nn,

a≡b(modn)⟺n∣(a−b)a\equiv b\pmod n \quad\Longleftrightarrow\quad n\mid(a-b)

Equivalently, a,ba,b have the same remainder on division by nn.

The least nonnegative residue is the representative rr with 0≤r<n0\leq r<n. The least positive residue is the representative ss with 1≤s≤n1\leq s\leq n. These agree unless the remainder is zero; the zero class has least positive representative nn.

Every integer congruent to rr has the form r+knr+kn, where k∈Zk\in\mathbb Z.

Not in the formula booklet: learn it.

The word “least” selects a representative from infinitely many integers. Writing −2-2 may be useful during working, but it is not a positive final residue.

Worked example 1: a negative input, a positive remainder

Question. Find the least nonnegative and least positive residues of −38-38 modulo 99. Write the congruence and describe all integers in its class.

Plan. Use division with a nonnegative remainder, then check whether that remainder is zero.

−38=9(−5)+7division theorem−38≡7(mod9)same remainderx=7+9k,k∈Zall representatives\begin{aligned} -38&=9(-5)+7 &&\text{division theorem}\\ -38&\equiv7\pmod9 &&\text{same remainder}\\ x&=7+9k,\qquad k\in\mathbb Z &&\text{all representatives} \end{aligned}

Why this step? Reducing a negative integer requires the remainder interval 0≤r<90\leq r<9; taking the absolute value would give a different class.

Answer. Both requested residues are 77. The class consists of the integers 7+9k7+9k.

Check. −38−7=−45=9(−5)-38-7=-45=9(-5); for example, −2,7,16-2,7,16 are also in this class.

Change only the input from −38-38 to −36-36. This time the distinction between the two requested representatives matters.

Worked example 2: the zero class

Question. Find the least nonnegative and least positive residues of −36-36 modulo 99.

Plan. Reduce first; if the remainder is zero, move one complete modulus forwards to obtain a positive representative.

−36=9(−4)+0remainder zero−36≡0≡9(mod9)both represent the same class0≤0<9,1≤9≤9the two requested ranges\begin{aligned} -36&=9(-4)+0 &&\text{remainder zero}\\ -36&\equiv0\equiv9\pmod9 &&\text{both represent the same class}\\ 0&\leq0<9,\qquad 1\leq9\leq9 &&\text{the two requested ranges} \end{aligned}

Why this step? Zero is nonnegative but not positive. The smallest positive integer congruent to zero modulo 99 is 99.

Answer. Least nonnegative residue 00; least positive residue 99.

Check. The representatives are the multiples of 99; no integer strictly between 00 and 99 is in this class.

A zero remainder is the boundary case where the requested representative range changes the answer.

Watch out

“Least positive residue =0=0” is wrong because zero is not positive. For the zero class modulo 99, write least nonnegative residue 00, but least positive residue 99.

A modulus belongs to the whole congruence statement. Include it in each displayed line so the reader knows which remainders are being compared.

Link congruences without changing the modulus

Integers with the same remainder form a class. This explains why a congruence can be reversed or linked to another congruence with the same modulus.

Three equivalence properties

For integers a,b,ca,b,c and the same positive integer modulus nn:

a≡a(modn)reflexivea≡b(modn) ⟹ b≡a(modn)symmetrica≡b(modn), b≡c(modn) ⟹ a≡c(modn)transitive\begin{aligned} a&\equiv a\pmod n &&\text{reflexive}\\ a\equiv b\pmod n&\ \Longrightarrow\ b\equiv a\pmod n &&\text{symmetric}\\ a\equiv b\pmod n,\ b\equiv c\pmod n &\ \Longrightarrow\ a\equiv c\pmod n &&\text{transitive} \end{aligned}

These follow because 00, the negative of a multiple of nn, and the sum of two multiples of nn are all multiples of nn.

Not in the formula booklet: learn it.

The modulus is part of the information. A chain of remainder comparisons works only when every link uses the same modulus.

Worked example 3: a valid chain

Question. Suppose a≡5(mod12)a\equiv5\pmod{12} and b≡a(mod12)b\equiv a\pmod{12}. Show that b≡5(mod12)b\equiv5\pmod{12}. Must b=5b=5?

Plan. Link the two given congruences, then distinguish a congruence class from a single integer.

b≡a≡5(mod12)transitivityb=5+12k,k∈Zall possible valuesk=2 ⟹ b=29one value other than 5\begin{aligned} b&\equiv a\equiv5\pmod{12} &&\text{transitivity}\\ b&=5+12k,\qquad k\in\mathbb Z &&\text{all possible values}\\ k=2&\ \Longrightarrow\ b=29 &&\text{one value other than }5 \end{aligned}

Why this step? Transitivity identifies the remainder, not the number of whole moduli added to it.

Answer. b≡5(mod12)b\equiv5\pmod{12}, but bb need not equal 55.

Check. 29−5=24=2(12)29-5=24=2(12), so 2929 is a valid alternative.

Change only the modulus in the second premise from 1212 to 88. A counterexample now tests whether the same conclusion is guaranteed.

Worked example 4: an invalid mixed-modulus chain

Question. Suppose a≡5(mod12)a\equiv5\pmod{12} and b≡a(mod8)b\equiv a\pmod8. Must b≡5(mod12)b\equiv5\pmod{12}?

Plan. Find values satisfying both premises but failing the proposed conclusion.

a=5,b=13choose a difference of 8a−5=0a multiple of 12b−a=8a multiple of 8b−5=8not a multiple of 12\begin{aligned} a&=5,\qquad b=13 &&\text{choose a difference of }8\\ a-5&=0 &&\text{a multiple of }12\\ b-a&=8 &&\text{a multiple of }8\\ b-5&=8 &&\text{not a multiple of }12 \end{aligned}

Why this step? One counterexample disproves a claim that is supposed to hold for every pair of integers satisfying the premises.

Answer. No. The two different moduli do not form a transitive chain modulo 1212.

Check. 13≡1(mod12)13\equiv1\pmod{12}, while the claimed residue was 55.

Transitivity is a statement about one fixed remainder system.

Watch out

The proposed chain b≡a(mod8)b\equiv a\pmod8, a≡5(mod12)a\equiv5\pmod{12}, therefore b≡5(mod12)b\equiv5\pmod{12}, is invalid: its links use different moduli. With a=5, b=13a=5,\ b=13, both premises hold but the conclusion fails.

Reverse a congruence when the direction is inconvenient; preserve its modulus. Then link it only to congruences using that same modulus.

Add and subtract reduced representatives

Once the modulus is fixed, replace large integers by convenient representatives before doing arithmetic. Representatives can be negative during the calculation; reduce to the requested final range afterwards.

Addition and subtraction laws

If a≡b(modn)a\equiv b\pmod n and c≡d(modn)c\equiv d\pmod n, then

a+c≡b+d(modn),a−c≡b−d(modn)a+c\equiv b+d\pmod n,\qquad a-c\equiv b-d\pmod n

For example, writing a−b=kna-b=kn and c−d=ℓnc-d=\ell n gives

(a±c)−(b±d)=(k±ℓ)n(a\pm c)-(b\pm d)=(k\pm\ell)n

Thus the differences are still multiples of the same modulus.

Not in the formula booklet: learn it.

Continue this lesson.

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

Create free account