### The Order of Operations and Precedence, Explained in a Brainteaser

### In my personal Facebook feed a few days ago, I saw this gem:

If you can’t see the image, the brainteaser asks the following question: ‘What’s 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 – 1 + 1 + 1 + 1 + 1 + 1 + 1 x 0 equal to?’, and provide four multiple choice options: 0, 14, 16, or 17 (thanks to the folks at FunCage.com for this blog topic fodder).

A quick look at this might yield ‘0’ as an answer (‘anything times zero is zero, Alan!’ I can hear, in chorus). But look again – that’s not what’s really being asked. See, you need to harken back to your Algebra I days and recall your Order of Operations. Or, just remember the line you used to utter when family members embarrassed you: “Please Excuse My Dear Aunt Sally.”

You see, with the 1 x 0 at the end, that part gets evaluated first. That nets out to zero (of course). The *remainder* of the expression is the just added together (minus that one slick “-1” in the middle) to net out to 14. Let’s take a look at how Mathcad evaluates this.

No surprise here, since a professional engineering calculation software package should, indeed, generate this result. Try evaluating that in a spreadsheet program and it gets tricky. Not impossible, but tricky.

With a little expression manipulation in Mathcad Prime, we can explore it a little, and help us (or a confused friend who answered ‘0’) understand a bit more.

When examined this way, I think most would say, “well of course the answer is 14.” And that’s the lesson here: the order of operations indeed matters when evaluating complex expressions in your product design, or answering silly brainteasers on Facebook. Just think of the bar bets you could win with your less-than-math-savvy friends.

**A Few Words on Implicit Multiplication**

This one is a bit trickier. I saw this on a reddit Math thread the other day.

*(source: http://www.reddit.com/r/math/comments/m6118/6212/)*

If you can’t see the image, it’s the expression 6 ÷ 2(1+2) and the author is asking if it evaluates to 1 or 9.

Upon first glance, you might think it evaluates to 1: one plus two is three, times two is six, and six divided by itself is one. But if you read the section above, you might say “Hey, wait a second… The order of operations (or ‘operator precedence’, if you were channeling Mrs. Alves, my Algebra I teacher) *matters. *So, I should evaluate the (1+2) first, net it to 3, and then proceed left-to-right, since multiplication and division (“My Dear”) are of equal precedence”. This also assumes that you recall that no explicit operator between the first ‘2’ and the open parenthesis implies multiplication (this is important later). So, 6 divided by 2 (net 3), times 3, equals 9.

This is how I would have interpreted this expression. Again, to further illustrate the order of operations, and how parentheses supersede (or is it supercede?) everything, let’s looks at the same expression in Mathcad with *no* parentheses.

Let’s now look at it when the parenthetical expression is evaluated first, and then the remainder of the expression is evaluated *right to left* – a common trap when the parenthetical expression is at the end.

This might be how some people arrive at ‘1’ as a solution.

But the underlying issue in *this* brainteaser is the implicit multiplication. I traded some messages with Mathcad’s Director of Software Development, Jakov Kucan about this topic. The reason I dug a little was because of this:

Examining this might elicit a response of “Wait a minute – didn’t you say above that the answer should net out to ‘9’? Why is Mathcad saying ‘1’ here?” The answer lies in how Mathcad delicately handles *implicit multiplication*. Says Jakov: “[As you know,] Mathcad has ‘implicit’ multiplication a.k.a. scaling. [From an operator precedence perspective, that] binds tighter than division.” In other words, Mathcad parses the expression a bit differently, and assigns a higher order of precedence to implicit multiplication than explicit multiplication or division. And that’s OK, as long as you know that’s how it works. But, to be safe, recall the order of operations processes parentheses first, so one could always re-write the expression with parentheses first to group out a term.

Note here that the multiplication is now *explicit* and not *implicit*, thus clearly denoting not only to Mathcad *but also to the human reader* which terms should be processed in which order.

Jakov agrees: “[By the way], this is a good example why in-line division as in 6/2*3 [isn’t the best] way to write an equation. Mathcad supports in-line division, but it’s a much better practice to use fractions, as in

He closes with: “Or, of course, **use parentheses**.” Oh, Aunt Sally….

The answer to the last problem is “one”. Two reasons. The Distibutive Law takes prexcedence. & the Order of Operations states that “specific groupings” are done FIRST. the term 2(1 +2) is a textbook exxample of a specific grouping. The 2 is a part of the parentetical term itself and and 2(1 + 2) is treated as one number, following that, the Distributive Law and the Specific Grouping reference in the order of operations is completed firrst …

6 “/” 2(1+2) = 6 “”/” [2(1) + 2(2)] = 6 “/” 6 – 1

_ ^ No “divided by” sign on my keyboard.

If you have trouble seeing this, then just replace the first 2 with an exponent, “x” for instance. The answer should then be apparent to you.

x(1 + 2) would be treated as one number, if it helps to clarify it then place the exponent at the rear of the parenthesis … (1 + 2)x This is one number.

2(1 + 2) means “two of these …” it does not mean “two times this …”

Mathcad is correct.

Charlie

Charlie: I’m glad you agree, and I think you explain it quite well. This is precisely why we have the so called “implicit multiplication” in Mathcad.

–Jakov

I would like to thanks for this math basics …Its solved my many problems for math…I really like it very much ..Thanks for this blogs…

I am in complete agreement with Charlie and Mathcad. In order of precedence the implied multiplication of the 2(2+1) or 2(3) is evaluated first and then the division is evaluated. The implied multiplication is a tighter binding between the elements than an explicit multiplication thus 6/2(2+1) is not equal to 6/2*(2+1) but is rather equal to 6/[2*(2+1)] or 1.

Umm… Implied multiplication is an abstract principal(that only exists to keep large amounts of multiplication signs out of algebraic expressions) that has no place in a problem with no unknown variables. It’s a horrible exception to the order of operations that isn’t even recognized by most.

The only time there are discrepancies with it are with problems that have in-line division anyways.

Wolframalpha. NEVER uses implicit multiplication.

the googles, NEVER uses implicit multiplication.

Why? because it’s an antiquated principal that is outside the standard laws of mathematics.

and distribution doesn’t hold precedence over the order of operations, nor is it its own law. the distributive property is simply a property of multiplication its self that is complimentary to the order of operations. Much like the associative property and the commutative property. That being said. I can think of 0 reasons why you would ever distribute in a problem that has no unknown variables. There is simply no reason. however if you were to distribute you would distribute the entire “(6÷2)” into the (1+2)

Also calling the “÷” obelus a “divided by” sign makes me cringe.

And your logic is flawed charlie

when you say x(1+2) is one number you could just as easily make an assignment “y=(1+2)” and “z=6″

then you would have z÷xy which would be the same as z÷x*y or (z)÷(x)(y) or many other things that all mean the same.

then you would simply solve left to right as the order of operations states.

hell, (((((((((z)))))))))÷(((x)))((((((y)))))) is even the same thing!

as is 1÷(6÷2(1+2)^(-1))

saying that 2 is part of the parenthetic term(1+2) is wrong(other than the obvious 2 inside). the only thing that parentheses denote is “(this is a single entity in and of its self)”

6÷2(1+2)

6÷2(3) or 6÷2*3 or (6)÷(2)(3) ||they are all the same.

^^ at this point you solve, Left to right.

and also in reality

“6÷2(1+2)” is in fact one number. 9.

“I can think of 0 reasons why you would ever distribute in a problem that has no unknown variables. There is simply no reason.”

I am not trying to be insulting, but your mathematical background is very limited if you think like this. Do you understand what the property is even saying? : a(b + c) = (ab + ac) ?

Do you know what the variables stand for? All mathematical properties and axioms use them. My dear, I could write a few pages of all the things wrong with your post, simply based on mathematical inaccuracies within.

^ edit to my “1÷(6÷2(1+2)^(-1))”

it should be 1÷((6÷2(1+2))^(-1))

Useful info. Fortunate me I found your web site accidentally, and I am surprised why this coincidence didn’t took place earlier! I bookmarked it.

Pingback: Happy 4th Birthday to the PTC Mathcad Blog! | PTC

A simple equation to help someone believes this answer is 9:

a ÷ a = 1

1a ÷ 1a = 1

1a ÷ 1a is NOT equal to 1 * a ÷ 1 * a = a^2. This is ludicrous.

Any variable (or base) has a coefficient of 1. a is always 1a, whether we write it or not. Therefore a ÷ a = 1a ÷ 1a and we all know this is 1. So what is a ÷ 2a ? It is (1/2)

It is great to see that you are providing basic math lessons in such an efficient manner. I am also into teaching and work as a math tutor in Sunnyvale. Your blog is extremely helpful for people like me.