Modular Arithmetic
Context: FIT1058_MOC Β· remainder operation + congruence Β· an Equivalence Relation partitioning into Β· basis of the Euclidean Algorithm, Modular Inverse and Modular Exponentiation
Quick Revision
- π― Objective: , β remainder operation βΉ congruence relation βΉ arithmetic on residue classes.
- π¦ Core Components: (operation) β (relation) β on .
- β‘ Key Constraint: negative rounds the quotient down (, so ); division needs a Modular Inverse.
π Core
1. The Modulo Operation (Division Algorithm)
- Division Algorithm β unique with , ; .
- Notation β is an infix operation (); zero remainder βΊ .
- Negative β floor keeps : (largest multiple is ).
- Programming caveat β
%agrees for non-negatives; for negatives some languages return β%β mathematical mod.
2. Congruence (the Relation)
- Three definitions β .
- Equivalence structure β reflexive/symmetric/transitive (Equivalence Relation) βΉ partitions into classes .
- Operation vs relation β returns a value; and are true/false; link: .
3. Class Arithmetic on
- Representative rule β , , β pick one member each, combine, reduce.
- Worked micro-example β in : , .
- Division β does not transfer in general; needs a Modular Inverse, which exists iff the element is coprime to .
- Everyday instances β weekdays (mod 7), clocks (mod 24), parity toggle (mod 2), last digit (mod 10).
When It Flips: for fixed the pair is unique, making well-defined; replacing repeated subtraction with one is exactly the speed-up from naΓ―ve gcd to the Euclidean Algorithm.
β οΈ Common Mistakes
- π‘ , not β the floor convention forces ; a languageβs
%might return but mathematical mod never does. - π‘ equation β congruence β β in β is an equation (the only value there); "" is a congruence (also ); but β in β is wrong ().
π§ Active Recall
Give three equivalent definitions of and explain why the classes partition .
- Hint: Congruence is an equivalence.
Answer
- Short answer: βΊ βΊ .
- Why: Equivalence relation β reflexive/symmetric/transitive βΉ disjoint residue classes .
Why can class arithmetic use single representatives, and how do " in " and "" differ?
- Hint: Well-defined operations.
Answer
- Short answer: depends only on the classes; one representative each suffices.
- Why: Equation vs congruence β has only ; a congruence allows any class member (), an equation does not.
Compute and justify via the Division Algorithm.
- Hint: Floor the quotient.
Answer
- Short answer: βΉ .
- Why: Round down β is the largest integer with , guaranteeing .