 Welcome back to our lecture series Math 3120, Transition to Advanced Mathematics for Students at Southern Utah University. As usual, I'll be your professor today, Dr. Angel Misseldine. In this video, we're going to continue our discussion of modular arithmetic and actually justify why we refer to it as modular arithmetic. In order to do so, let me remind you of a few facts. Imagine we have some elements a and b, where a and b are themselves integers, and we have some other element n which is a natural number. Then we define a relation a is congruent to b modulo n, and this symbol right here means that n divides the difference of a and b. We've talked about last time how this forms an equivalence relation. We use the symbol bracket, a number bracket here to represent the equivalence class. This would be the collection of all numbers of the form a plus kn, where k is honestly any integer whatsoever. This gives us the equivalence class with regard to this equivalence relation. We call this a congruence class. In fact, you can always choose this number a, so that it sits between 0, inclusive and n, exclusive there. We get all the numbers 0, 1, 2, 3, 4 up to n minus 1, because the idea we also discovered that two numbers are equivalent, they're congruent mod n, if and only if they have the same remainder if you divide by n. By the division algorithm, these are the options you have for remainders. Given a positive integer, zn, we then define to be the set of all congruence classes, and this is going to be a set that contains exactly n elements. Then what we want to talk about right now is how this set zn actually defines a finite arithmetic that in many ways resembles the arithmetic of the integers. Also, in many ways, the arithmetic of the rational numbers, but let's first define what I mean here by arithmetic. What we're going to do is for this set zn, we're going to define two operations on that set. The first one we're going to call modular addition, and the second one we're going to call it modular multiplication. Again, let n be a natural number. Then we define addition modulo n to be an operation on the set zn such that we can define the sum of two congruence classes to be the congruence class of their sum. Sometimes you'll see this symbol out here, where people use this O plus. That's actually the latex symbol there, O plus. It sounds like a streaming service there. Come check out the new math videos on O plus. That's totally what I should name this channel here. Anyways, if you take the sum of two congruence classes, you then define that to be the class that contains the sum of the two things. We do the same thing for multiplication. We can multiply together two congruence classes to produce the congruence class of their product. Some people don't bother introducing a new symbol for these modular operations. That's fine and hunky-dory if you want to, but for us, this is what we're going to do here. Whenever you add together a congruence class, we'll use this O plus, and this represents then the class of the sum, and O times here represents the class of the product. So we come up with these two operations. So we're taking, and by an operation, what I mean here is we take two objects and then combine them into a new object of that same set. So the congruence class containing A and B belong to ZN, and the congruence class containing A plus B also produces an object of ZN. So you combine two objects inside of a set to produce a third element of that set. Same thing with multiplication happening right here. Now with an operation, it's customary, especially with finite operations, to actually arrange all the symbols in a table format. So I want to explain what this means right here. So look at this addition table with respect to modulo five. So we see on the left here, the modular addition table for Z five. What this means is we're going to add together numbers, modulo five. And so how you read this is the rows right here represent the sum and on the left. And then these elements right here that denote the columns, this represents the second operand. And so if you were to look at a specific place in the table, like take this number right here, this number, if you look at the row, if you look at the column, what this tells us is that two plus three is equal to zero. And we're thinking of these as congruence classes. All right, so the congruence class of two plus the congruence class of three is equal to the congruence class of zero. But of course, this notation can get awkward really quickly. So most likely how we would write it would be is two plus three is congruent to zero, mod five. And so that's what that statement means right there. Cause after all, two plus three is equal to five and five has this, well, five is congruent to zero. We always want to reduce things modulo five. So we always have a number between zero and four as we work through these. Give you another example here. If you take this one and this one right here, the way you want to read this is that three plus four is congruent to two, mod five. And again, if the modulus is clear, we don't write it out every single time there, but two plus, our three plus four is congruent to two, mod five. We can do another one here, zero, for example. Zero plus zero is congruent to zero. If you take zero plus one, that gives you one. If you take zero plus two, that gives you two. If you take zero plus three, that gives you three and zero plus four gives you four. So something to notice here is that zero has the property that if you add zero to any, any number M, you always get back M, mod whatever, right? And so modular arithmetic does in fact have an additive identity element. We'll say some more about this in a second. We also have the property that if you switch the order, it doesn't matter. Like if I take two and three, which adds up to be zero, this is the same thing as three plus two, which is equal to zero. This operation of addition turns out to be commutative. You can actually see this from the table here, because after all, we take three plus two versus two plus three, you get the exact same number. Like if you reflect across the diagonal, you always end up with the same number, things like that. There's other properties here. We'll talk about those in a moment. The other properties are a little bit less obvious when it comes to the table here. But again, if you take something like two plus one, this is congruent to three. But if you take something like four plus three, that's congruent to two. And the idea there is four plus three is equal to seven. If you reduce seven, mod five, you get a remainder, which is then two. And that's how these calculations are. You just compute the number as a regular integer, four plus four is equal to eight. When you reduce eight, mod five, you end up with three. Because three is the same thing as eight, mod five, because eight is actually equal to five plus three. And you ignore multiples of five when you work mod five. Let's look at multiplication for a little bit here. This time we're gonna switch to be mod eight. So we're looking at the multiplication tables in Z eight. So there's eight objects here. And so I'm just gonna write the remainders here, because these are congruence classes, but I'm just gonna write the remainders zero through seven. So we have zero, one, two, three, four, five, six, seven, like so. Again, the rows are gonna be the first operand. The columns will be the second operand. And you see the labels right there. I indicate the operation here. So you know this is a multiplication table. And not shockingly, we see that zero times anything is equal to zero. This happens with integers. It'll happen with integers mod eight as well. We also can see that one acts like a multiplicative identity. Notice how you look at the index row right here. It tells you which column you're in. That's identical to this row right here. One times anything. So one times M is gonna be congruent to M mod N. And so one acts like a multiplicative identity for modular multiplication, much in the same way that it does for integers as well. And so some other things we could see here. If I take three times six, three times six is equal to two. Or I should say three times six is congruent to two, mod eight. If we did another one, six times two. Well, as an integer, six times two is 12. But if we reduce 12 mod eight, we end up with four. And so that's been the product. Six times two is congruent to four here. Now, some curious things to note here. Again, this thing is symmetric across the diagonal. Therefore, it is a commutative operation. Again, we'll talk about some of the properties more in a little bit. But one thing that's kind of curious is the following. Take, for example, four times two, mod eight. This product is equal to zero. And I want you to think about that for a moment. Four is not congruent to zero, mod eight. And likewise, two is not congruent to zero, mod eight. But four times two is congruent to zero, mod eight. Because four times two is actually equal to eight. As an integer, as you reduce that mod eight, you get back a zero here. And so this is a curious property because in algebra classes, when you're working with real numbers, complex numbers, you often have something called the zero product property. The zero product property is very useful because you're using this assumption that any product of real numbers, if it equals to zero, it was because one of the factors was already equal to zero. That's the only way you can get a zero product is that one of the factors is zero. But with regard to modular multiplication, this table does seem to suggest there is a possibility where you can have a product of two non-zero quantities that become zero. So things like the zero product property can fail in that situation. Another curious thing to note here, I want you to notice again when you look at four here, four times two is equal to zero. Four times four is equal to zero. Four times six is equal to zero. Notice how there's more than one product that if you take the factor four, for example, fixed on the left-hand side, if you take the second factor, you can vary that, but you can still get the same product over and over and over again. Similar here, if you look at four times one, that's equal to four. If you take, for example, four times three, that's also equal to four. And so this is a curious thing here that you have multiple things that multiply by four that give you back four. You can't cancel them out. I'll give you another example of this, for example. Take two, two times three is equal to six, but likewise, two times seven is equal to six. So for example, if you had an equation, two x is congruent to six mod eight here. There's actually two solutions here. One solution is three and one solution is seven, which is curious because isn't this a linear equation? Right? This looks like a linear equation. Two x is congruent to six, but how does a linear equation have two solutions? That's kind of a weird thing. And that's the thing that I'm trying to emphasize here that the arithmetic you get when you work with modular arithmetic in many aspects, it behaves just like you would expect with the integers, but in many aspects, things can get weird and has entirely to do with the modulus itself. What we're talking about right now is very much at the beginning of topics like number theory and abstract algebra. Number theory is very obsessed with this modular arithmetic and abstract algebra is very obsessed with just arithmetic in general. That is abstract algebra loves studying binary operations. So things like O plus and O times are very much an interest in a situation like that. So while there are some anomalies that seem to happen with modular arithmetic, let me give you some properties that are absolutely true that you can use when you're working with modular arithmetic of any kind. So let N be a natural number and that does include zero and one, let ABC be any integers, then the following properties hold. So first, the associative property for addition holds, that is if you take A plus B plus C, this is congruence to A plus B plus C mod N. And I am using the O plus right here, even though I don't have congruence classes to really emphasize this is modular addition that has this associative property. It doesn't matter how you do parentheses. Same thing with modular multiplication, it is also associative. A times B times C is congruence to A times B times C mod any N whatsoever. Modular addition and multiplication is also commutative. A plus B is congruent to B plus A and A times B is congruent to B times A. With regard to addition and multiplication together, the distributive laws hold. It does hold that A times B plus C is congruent to A times B plus B times, sorry, A times B plus C is congruent to A times B plus A times C. So this is the left distributive law. You also have the right distributive law. A plus B times C is the same thing as A times C plus B times C. We have identities here. There is an additive identity. We talked about that earlier. There is a number, in this case it's zero and this is true for any modulus whatsoever that A plus zero is congruent to zero plus A which is congruent to A. And for multiplication one acts like the multiplicative identity. A times one is congruent to one times A which is congruent to A. And then lastly, we have a property about inverses that with regard to modular addition, there are inverses that if you take the element A and you add to it N minus A, this always gives you zero, right? And that's a very simple calculation to do here. And we write N minus A because we like to represent these numbers using the possible remainders, zero through N minus one, right? So if we were working mod five, for example, then if I talk about what is negative two, negative two is the same thing as three, where three of course, we got that as five minus two. Five minus two is three. So you always get an additive number, an additive inverse here. So even though we keep our numbers in the non-negative representations, we can actually think of modular arithmetic includes negative numbers as well. Negative two is the same thing as positive three when you work mod five. Now, how does one prove these properties here? How would you prove a property about modular arithmetic? And it comes honestly down to just the definition. If you want to prove that these two things are congruent to each other, it's like, well, congruence is an equivalence relation. So to show the additive principle here, the additive associativity, you would have to show that the difference of these two numbers, this number minus that number is divisible by N. All right, so here's the proof of modular associativity of addition. So consider the number A plus B plus C minus A plus B plus C. Well, because integer addition is associative, these two numbers are one and the same thing as in the whole number is this whole number as well. And thus their difference is equal to zero. And zero is equal to zero times N. So N does divide the difference of these two numbers. And so then that tells us, with regard to the congruence relation here, that these two numbers are congruent. So A plus B plus C is congruent to A plus B plus C, right? In particular, if two numbers are equal as integers, then they will be congruent with respect to modular operations as well. And that's honestly how the proof of all of these things happen. Pretty much all of these ones, because these are equal as integers, they're gonna be equal with respect to these modular integers as well. And that's where the first eight properties follow. And so I'm gonna leave it as a proof to the viewer here to prove the remaining properties here. The one exception to this would be property, well, the inverse property here. We're not saying, because this property does not hold, this property does not hold for regular integers. Like if you take A plus N minus A, you could back N, which is not usually zero. But of course, when you're working with modular arithmetic, you just wanna find a multiple of N. The key thing about modular arithmetic is that multiples of N are considered zeros. And so we can get away with that here. What about the gap right here? Why wasn't there a multiplicative inverse property here? Well, it turns out there are some problems when it comes to modular division. Now I should say there does exist such a thing as modular subtraction. We can do an O minus, right? So what does it mean to take the congruence class of A and minus from it, the congruence class of B? Well, clearly you see that this should be defined to just to be A minus B, right? But this could be problematic, right? Is this number A minus B gonna be a number that's within the range zero through A minus one? Well, maybe, maybe not. It doesn't matter though. This congruence relation is defined for any integers. So we can define modular subtraction no big deal. But if you were concerned whatsoever, the key thing here is modular subtraction is really just modular addition. But we're looking at the inverse, right? So what does it mean to subtract? Well, subtraction is just adding a negative, which is really adding inverses. If you have additive inverses, then you have subtraction. Okay, but what about division? Division can be problematic because if I'm trying to define something like, we're gonna take A divided O divide by B, you would want that to be like A divided by B, but the thing is A divided by B itself is likely not an integer. And therefore, this is nonsense. Like that symbol doesn't necessarily mean anything. But it turns out there are situations through which we can divide integers in a modular fashion. It turns out that we do get multiplicative inverses exactly when the number A and the modulus N are relatively prime with each other. So the number A has a multiplicative inverse inside of ZN if and only if the GCD of the numbers A and N is equal to one. And the reason for that basically comes down to the Euclidean algorithm, okay? If the GCD of A and N is equal to one, that means there exist integers R and S such that AR plus NS is equal to one. This is given to us by the Euclidean algorithm. But if I take this one is equal to AR plus NS, this second number AR plus NS is clearly congruent to AR when you look at mod N here because you can kill off the multiple of N. Therefore, we have a number R, which when times by A gives you back the multiplicative identity. This is exactly what one means by a multiplicative inverse. And these directions go in both directions if and only if. And so therefore, integers that which have a GCD equal to one to the module. So that is those integers which are co-prime to the modulus, they have inverses. And in fact, the Euclidean algorithm tells you what that inverse is gonna be. The inverse, the multiplicative inverse is the coefficient that you connect to A with this linear combination. If you can find a linear combination of A and the modules that equals one, you then have the inverse. And I wanna show you how you can use this and then solve modular equations. So consider the equation 2X plus one is congruent to five, mod seven. How would you solve this for X? And so we're gonna go back to some fundamental algebraic observations here. If I wanted to solve the equation 2X plus one equals five, the first thing I would do is I would add negative one to both sides. Why am I adding negative one? Because negative one is the inverse of one. So we're gonna add negative one to both sides, okay? On the right-hand side, you're gonna take one plus, sorry, five plus negative one, which gives you four, mod seven. On the left-hand side, we use the associative property to redo parentheses so that 2X plus one plus negative one becomes 2X plus one plus negative one. Now, one and negative one are additive inverses. They simplify to be zero. And zero is the additive identity. So if I add zero to 2X, I just get back 2X. So now we have the simplified equation 2X is congruent to four, mod seven. Those properties we used beforehand, the inverse axiom, the identity axiom, the associativity axiom, they allow us to get rid of the one on the left-hand side to help us solve for this. Now, if we wanna get rid of the two, we have, when I say get rid of the two, we wanna move the two to the other side of the equation, much like how we move the one to the other side of the equation, and in order to do that, we need to have inverses, associativity and identities. Now, for multiplication, we do have associativity. We do have identities, but do we have inverses? Sometimes, sometimes not. But you'll notice that two is co-prime to seven. The GCD of two and seven is equal to one. So by the Euclidean algorithm, there does exist a number, there exists a linear combination of two and seven that gives you one. And you can either run the Euclidean algorithm or a little bit of guess and check, you can see here, that four times two, which is eight, minus one times seven will give you one. Eight minus seven is equal to one here. And so this tells us that the multiplicative inverse of two, mod seven, is four. Two to the negative one power is congruent to four here. So if I multiply both sides of the equation by four, this is gonna cancel out the two. And let's see the details of this thing here. So I'm gonna times both sides by four. On the right hand side, you're gonna get 16, four times four is 16. 16, of course, is the same thing as, well, 16 is the same thing as two plus 14, is a multiple of seven. So 16 and two are congruent to each other, all right? On the left hand side though, we're gonna take four times two X by associativity, you get four times two times X, four times two is eight, but eight is congruent to one, mod seven, because again, eight is equal to one plus seven, ignoring multiples of seven, we end up with just a one there. And so we were able to solve this linear equation because we had a multiplicative inverse. That example we were looking at earlier, when we were working mod eight, we had a problem with two X is congruent to, what was, with three, something like that, or six was what it was, working mod eight. There was a problem there because there was two solutions. X could equal three, right? And then X could also equal seven. Two times seven is 14. If you subtract eight from that, you get back six. You had multiple solutions. The issue had to do with the fact that our coefficient was not co-prime with the modulus, the GCD of two and eight is equal to two. And that does cause some issues with regard to modular arithmetic. So in many ways, it does behave like the integer arithmetic we're used to, but in many ways it also behaves a little bit differently. And that's about as far as we're gonna get in this lecture series with regard to modular arithmetic. I want to introduce it so we can use this as a toy to prove some facts about, but in the end, the deeper studies of modular arithmetic belongs to undergraduate mathematics classes like number theory and abstract algebra, for which there are some abstract algebra videos on this YouTube channel. So feel free to watch those if you wanna learn some more about modular arithmetic.