Wednesday, December 15, 2021

Order of Operations: PEMDAS

 I've seen too many social media posts with incorrect responses, and it's making me twitchy, so I'm writing this blog post mostly to try to make myself feel better.  The posts pose a math question and ask what the correct answer is.  It forms the math in such a way that there's a part that confuses some people.  Here's an example...

20 / 4(2 + 3) = ?

The correct answer is 25, but if you do it the common wrong way, you can think the answer is 1.  And there are people on these posts arguing for the wrong way.  So, to remind anyone reading this...

Wikipedia Order of Operations

Another source

The memory helper I learned is PEMDAS, though there are others that break down to the same thing...

  1. P = Parentheses (or brackets)
  2. E = Exponents (which includes roots which are exponents between 0 and 1 essentially)
  3. MD = Multiplication and Division (They are the same priority, so you do left to right when there are several of these near each other)
  4. AS = Addition and Subtraction (They are the same priority, so you do left to right when there are several of these near each other)

The confusing part of the example is the "4(2".  What that is, is a shorthand for multiplication.  So, we can re-write the example equation as...

20 / 4 * (2 + 3) = ?

Then it's really easy.  We do the stuff in the parentheses first, then from left to right we handle the division and multiplication...

20 / 4 * 5 = 

5 * 5 = 

25

What the people who are doing it wrong assert is that because the number is right up against the parentheses, it falls into the umbrella of the parentheses and you have to do that before the division.  Of course, they're entirely incorrect.  If you treat "4(2+3)" as being before you do the "20 / something", you'd get the answer 1.  It's just flat out incorrect to do it that way though.  Order of operations is insanely clear.  You can even go to math solving websites to get the correct answer...

https://quickmath.com/

And, to add my credentials: I'm a software engineer of more than 20 years.  I had to learn how computers do math to make computers do the right thing.  And order of operations is strictly followed.  If you put "20 / 4(2 +3)" into any computer language that can understand the multiplication short hand, you will get the correct answer of 25 every single time.

As a bonus piece of information, fractions can add another bit of confusion.  I'm sorry for the text formatting...

4 + 16

----------

4 + 1

Since a fraction is essentially division, you might think you could re-write this as...

4 + 16 / 4 + 1 =

4 + 4 + 1 = 

9

But fractions are special.  The top and bottom are separate things called the numerator and denominator respectively.  That notation implies that the things on top are all meant to be done together and the things on the bottom are to be done together and that big bar for division of the numerator by the denominator is done last.  If we're trying to change a fraction to single line notation...

(4 + 16) / (4 + 1) = 

20 / 5 = 

4

So, the correct answer to my fraction example is 4.