3 Frequently Asked Questions About Modular Arithmetic
How should you think about subtraction and negative numbers in modular arithmetic? How does the modulo operator work in terms of the order of operations? Keep on reading to learn the answers to these questions and more!
Jason Marshall, PhD
Listen
3 Frequently Asked Questions About Modular Arithmetic
There are several topics in math that show up over and over again in questions from math fans. One of these topics is modular arithmetic. We’ve talked about the meaning of modular arithmetic before, how it’s related to clocks, and how to perform multiplication and division in modular arithmetic, but there are a few questions we haven’t yet addressed.
Which is precisely why the topic of modular arithmetic is today’s addition to our “frequently asked questions” series. How do subtraction and negative numbers work in modular arithmetic? And where does the modulo operator fit in the order of operations? Stay tuned to find out!.
Addition, Subtraction, and Modular Arithmetic
Our first frequently asked question about modular arithmetic comes from math fan Claire. She writes:
“What’s the inverse of addition for numbers on the 12-hour clock?”
When it comes to numbers on the regular old number line, the inverse of addition is subtraction. In other words, if you start at some number—let’s say 10—on the number line, then add 4 (meaning you take 4 steps in the positive direction), and finally subtract 4 (meaning you take 4 steps back in the negative direction), you end up right back where you started from. Which means that subtraction is addition’s inverse operation.
The same is true for numbers on the 12-hour clock. As we learned before, performing addition and subtraction around a 12-hour clock is what’s known mathematically as arithmetic modulo 12. In other words, something like 11 + 3 (mod 12) is the same as 2 (not 14!) since we circle around the clock and start our counting over when we get back to 12.
Just as we did on the number line, we can now subtract 3 (mod 12) from this result to get back where we started from. In other words, 11 + 3 (mod 12) – 3 (mod 12) is the same as 11 + 3 – 3 (mod 12), which is just 11. So subtraction is addition’s inverse operation in modular arithmetic, too.
Negative Numbers in Modular Arithmetic
Our next modular arithmetic question comes from math fan Ginette. She asks:
“Using a demo from clock arithmetic, I need to provide examples for modular addition using positive integers and then negative integers. Can you help?”
As we learned way back in the day when we first talked about adding positive and negative integers on the number line, the process of adding a negative integer to another number gives exactly the same result as subtracting the magnitude of that integer. For example, something like 11 + (-12) has exactly the same answer as 11 – 12—both are equal to -1.
The general idea here also works in modular arithmetic. In other words, in modular 12 arithmetic, a problem like 11 + (-12) (mod 12) has the exact same answer as 11 – 12 (mod 12). Of course, in modular arithmetic this is the same as 11 (not -1!).
Order of Operations for Modular Arithmetic
Our third and final frequently asked question about modular arithmetic comes from math fan Pablo. He writes:
“I ran into one problem in modular arithmetic that I just can’t wrap my head around: 100 – 25 x 3 (mod 4) = 97. I don’t understand how that’s equal to 97. What am I missing here?”
As with all problems of this type, the tricky thing here is figuring out the order in which the operations should be performed. This is, of course, where the order of operations—aka PEMDAS—comes to the rescue. PEMDAS tells us that we first perform anything in parenthesis, then we exponentiate, then comes multiplication and division, and finally we do any addition and subtraction.
But what about the modulo operator—where does it fit in? In truth, I’m not sure there’s a correct answer to this question. After all, the order of operations is just a convention that we all agree to follow. And the PEMDAS convention doesn’t mention the modulo operator. But there is another convention that does: the order of operations followed by just about every programming language I know of. And those programming conventions all give the modulo operator the same precedence as multiplication and division.
Which, according to this convention, means that 100 – 25 x 3 (mod 4) = 100 – [25 x 3 (mod 4)] = 100 – [75 (mod 4)] = 100 – 3 = 97.
You Are (Still) NOT Bad at Math
In a previous episode, You Are NOT Bad at Math, we talked about a wonderful article that argues that math ability is not entirely genetic, but is instead largely determined by a person’s willingness to work hard. I have to say that the response to that episode has been heartwarming. I’ve received a number of notes from people who found comfort and encouragement in knowing that there’s nothing wrong with them—that the process of learning math is supposed to be hard.
They can say they can’t do it, but they must add ‘yet.’
I recently received a note from math fan Susan saying:
“When working math problems with students, I like to be sure they use positive self talk….they can say they can’t do it, but they must add ‘yet’—I can’t do this…yet.”
I think that’s great advice!
Puzzle: How Many Games?
Finally, I want to leave you with a puzzle to think about from math fan Raleigh. He writes:
“The manager at a country club had the job of scheduling a single-elimination tennis championship for 100 players. When asked, ‘How many games will they play?’ the manager dutifully started a list of pairs, available courts, winners, losers, etc., and got hopelessly bogged down. BUT, the answer is easy if you approach it properly.”
And the best thing about this “easy approach” is that it will tell you the number of games in any tournament—no matter how many teams or players there are. In particular, it can be used to easily figure out the numer of games in the NCAA basketball tournament tipping-off this month. So, can you figure out what this easy approach to the solution is and use it to calculate the number of games that will be played in this year’s 68 team tournament?
Think about it and we’ll talk about the answer next time.
Wrap Up
Okay, that’s all the math we have time for today.
Please be sure to check out my book The Math Dude’s Quick and Dirty Guide to Algebra. And remember to become a fan of the Math Dude on Facebook where you’ll find lots of great math posted throughout the week. If you’re on Twitter, please follow me there, too.
Until next time, this is Jason Marshall with The Math Dude’s Quick and Dirty Tips to Make Math Easier. Thanks for reading, math fans!
Betterment LLC is an SEC Registered Investment Advisor. Brokerage services are offered by Betterment Securities, an SEC registered broker-dealer and member FINRA/SIPC. Investments are not FDIC Insured. No Bank Guarantee. May Lose Value. Investing in securities involves risks, and there is always the potential of losing money when you invest in securities. Before investing, consider your investment objectives and Betterment’s charges and expenses. Not an offer, solicitation of an offer, or advice to buy or sell securities in jurisdictions where Betterment and Betterment Securities are not registered.