]> Number Theory - Modular Arithmetic

Modular Arithmetic

Let n be a positive integer. We denote the set {0 ,...,n1 } by n.

We consider two integers x,y to be the same if x and y differ by a multiple of n, and we write this as x=y(modn), and say that x and y are congruent modulo n. The modn is sometimes omitted when it is clear from the context. Every integer x is the congruent some y in n. When we add or subtract multiples of n from an integer x to reach some yUnknown character/pUnknown characterUnknown character/divUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterTherearedifferentsetswecouldhavechosenfor\mathbb{Z}_n,e.g.wecouldaddntoeverymember,butourdefaultwillbe\{0,...,n-1\}.Theelementsinthisparticularrepresentationof\mathbb{Z}_narecalledtheUnknown characteremUnknown characterleastresiduesUnknown character/emUnknown character.Unknown character/pUnknown characterUnknown character/divUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterUnknown characterstrongUnknown characterExampleUnknown character/strongUnknown character:38 = 3 \pmod{5}since38 = 7\times 5 + 3.-3 = 11 \pmod{14}since-3 = (-1)\times 14 + 11.Unknown character/pUnknown characterUnknown character/divUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterWhatisthemostnaturalwayofdoingarithmeticin\mathbb{Z}_n?Giventwoelementsx, y \in \mathbb{Z}_n,wecanadd,subtractormultiplythemasintegers,andthentheresultwillbecongruenttooneoftheelementsin\mathbb{Z}_n.Unknown character/pUnknown characterUnknown character/divUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterUnknown characterstrongUnknown characterExampleUnknown character/strongUnknown character:6 + 7 = 1 \pmod{12},3 \times 20 = 10 \pmod{50},12 - 14 = 16 \pmod{18}.Unknown character/pUnknown characterUnknown character/divUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterTheseoperationsbehavesimilarlytotheirmundanecounterparts.However,thereisnonotionofsize.Saying0 \lt 4 \pmod{8}isnonsenseforexample,becauseifweadd4tobothsideswefind4 \lt 0 \pmod{8}.Theregularintegersarevisualizedaslyingonanumberline,whereintegerstotheleftaresmallerthanintegersontheright.Integersmodulonhoweverarevisualizedaslyingonacircle(e.g.thinkofaclockwhenworkingmodulo12).Unknown character/pUnknown characterUnknown character/divUnknown characterUnknown character/divUnknown characterUnknown characterh2 id=Unknown character divisionUnknown characterUnknown characterDivisionUnknown character/h2 Unknown characterUnknown characterdivclass=Unknown charactersectionbodyUnknown characterUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterDivisionisnotablyabsentfromtheabovediscussion.Ifydividesxasintegers,thenonemightguesswecouldusetheusualdefinition.Letusseewherethisleads:wehave10 = 4 \pmod{6}.Dividingbothsidesby2givestheincorrectequation5 = 2 \pmod{6}.Unknown character/pUnknown characterUnknown character/divUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterThuswehavetochangewhatdivisionmeans.Intuitively,divisionshouldundomultiplication,thatistodividexbyymeanstofindanumberzsuchthatytimeszisx.Theproblemaboveisthattherearedifferentcandidatesforz:in\mathbb{Z}_6both5 and2 give4 whenmultipliedby2 .Unknown character/pUnknown characterUnknown character/divUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterWhichanswershouldwechoosefor4 / 2,5or2?Withrealnumbers,althoughtherearealwaystwosquarerootsofapositivereal,wecanstilldefinethesquarerootsymbolbecausewestipulatethatitreferstothepositivesquareroot.Butwithoutanotionofsize,wecannotsaysomethinglikechoosethesmallestanswer.Therearewaysofpickingauniqueanswer(e.g.wecanchoosethesmallestanswerwhenconsideringtheleastresidueasaninteger),butthendivisionwillbehavestrangely.Unknown character/pUnknown characterUnknown character/divUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterHencewerequireuniqueness,thatisxdividedbyymodulonisonlydefinedwhenthereisauniquez \in \mathbb{Z}_nsuchthatx = y z.Unknown character/pUnknown characterUnknown character/divUnknown characterUnknown characterdivclass=Unknown characterparagraphUnknown characterUnknown characterUnknown characterpUnknown characterWecanobtainaconditiononyasfollows.Supposez_1 y = z_2 y \pmod {n}.Thenbydefinition,thismeansforsomekwehavey(z_1 - z_2) = k n.Letdbethegreatestcommondivisorofnandy.Thenn/ddividesz_1 - z_2sinceitcannotdividey$, thus we have

z 1 y=z 2 y(modn)

if and only if

z 1 =z 2 (modn/d).

Thus a unique z exists modulo n only if the greatest common divisor of y and n is 1.

Inverses

We shall see that a unique z exists if and only if it is possible to find a w n such that yw=1 (modn). If such a w exists, it must be unique: suppose yw is also 1. Then multiplying both sides of yw=yw by w gives wyw=wyw, which implies w=w since wy=1 . When it exists, we call this unique w the inverse of y and denote it by y 1 .

How do we know if y 1 exists, and if it does, how do we find it? Since there are only n elements in n, we can multiply each element in turn by y and see if we get 1. If none of them work then we know y does not have an inverse. In some sense, modular arithmetic is easier than integer artihmetic because there are only finitely many elements, so to find a solution to a problem you can always try every possbility.

We now have a good definition for division: x divided by y, is x multiplied by y 1 if the inverse of y exists, otherwise the answer is undefined.

To avoid confusion with integer division, many authors avoid the / symbol completely in modulo arithmetic and if they need to divide x by y, they write xy 1 . Also some approaches to number theory start with inversion, and define division using inversion without discussing how it relates to integer division, which is another reason / is often avoided. We will follow convention, and reserve the / symbol for integer division.

Example: 2 ×3 +4 (5 1 )=2 (mod6 ).