# Order of Operations

#### TheJason

##### New member
$$\displaystyle \dfrac{2(3)^{2}}{2}$$

Is the top 36 or 18?

Staff member

#### topsquark

##### Full Member
$$\displaystyle 2(3)^2 = 2 \cdot (3)^2$$ vs. $$\displaystyle (2(3))^2$$. Do you see why the second expression can't be what the problem is talking about?

Do the parenthesis first: $$\displaystyle 3^2 = 9$$

So
$$\displaystyle 2(3)^2 = 2 \cdot 9 = 18$$

-Dan

#### TheJason

##### New member
Yeah, I was thinking PEMDAS (parenthesis, exponents, multiply, divide, add, subtract).

#### Otis

##### Elite Member
Do the parenthesis (sic) first …
Side note: If one cancels the common factor of 2 first, then …

#### Jomo

##### Elite Member
I agree with Otis that you should cancel out the 2s but if you don't...

You need to know that 2(3)2 means 2*(3)2. Now obviously before you multiply you need to know what you are multiplying. The quantities which you are multiplying are to the left and right of the multiplication symbol. To the left of the multiplication symbol is 2 which of course equals 2. What is the right of the multiplication symbol is (3)2 which is 9. Now armed with the two numbers you can multiply and get 2*9=18

#### pka

##### Elite Member
You all know why this sort of question is nothing more than a joke.
WHY: well there is absolutely no way to force: authors of computer languages, makers of calculators, members of the MathEd hierarchy and/or publishers of mathematics textbooks to agree on any one standard. For the last fifty years I have been in that mix.
I see no way to declare one correct answer.
For what it is worth I vote for 9 as a final answer.

#### Mr. Bland

##### Junior Member
The "PEMDAS" mnemonic is helpful in most situations, including this one. Evaluating the expression $$\displaystyle 2(3)^2$$ performs the exponentiation first, followed by the multiplication. To put it another way, it is evaluated as $$\displaystyle 2(3^2)$$. Careful positioning of parentheses, and even use of redundant parentheses that are not strictly necessary, can help to eliminate ambiguity and promote correct interpretation in other readers.

PEMDAS does not cover every operation, however. My favorite example is $$\displaystyle -3^2$$. Is this interpreted as $$\displaystyle (-3)^2 = 9$$, or $$\displaystyle -(3^2) = -9$$? It can be reasoned that it should be interpreted as $$\displaystyle 0 - 3^2 = -9$$, as there is an implicit leading zero. However, in applied fields such as computer programming, it can instead be reasoned that the $$\displaystyle -$$ symbol denotes negation, not subtraction, which is a unary operation and therefore has a higher priority than the binary operation of exponentiation.

Wikipedia uses the same example and suggests that there is no universal rule in this situation--the context determines its meaning. Once again, parentheses help to circumvent the possibility of misinterpretation in the event the reader doesn't happen to know the intent of the $$\displaystyle -$$ symbol.

As an aside...

In computer lingo, the order of operations is called operator precedence, which has its foundations in mathematics and is unambiguously defined for all operations (in before someone brings up compound assignments). In most (all?) programming languages, the negation operation has higher priority than multiplication, even in languages (such as C in the link above) that don't have an operator for exponentiation.

Because operator precedence is completely unambiguous, parentheses are only needed when the order of operations needs to be modified. My go-to example (pun intended) for this is the expression a & b >> c, which shares the same precedence relationship as the expression a + b * c. People have adamantly argued with me about how they believe it should be written as a & (b >> c) to avoid confusion, "in case the reader doesn't know the precedence rules", yet they take no issue with a + b * c being written without parentheses, "since the reader should already know that". The way I see it, if you know that multiplication happens before addition, you should also know that right shift happens before bitwise AND. If you don't know that, you need to review your operator precedence!

Ultimately, those people get the last laugh: gcc has a warning for those cases "whose precedence people often get confused about". If I want my code to compile without warnings in all cases (enabling all warnings is considered good form), I have to use those redundant, unnecessary, condescending, space-wasting parentheses. *grumble*

#### Otis

##### Elite Member
… 2(3)2 means 2*(3)2 … before you multiply you need to know what you are multiplying …
Agree. When we teach order of operations and grouping symbols, we ought to include how to parse factors.

$$\;$$

#### Otis

##### Elite Member
… PEMDAS does not cover every operation … My favorite example is $$\displaystyle -3^2$$ …
When I look at that example, I see (-1)(32).

$$\;$$

#### Jomo

##### Elite Member
My favorite example is $$\displaystyle -3^2$$. Is this interpreted as $$\displaystyle (-3)^2 = 9$$, or $$\displaystyle -(3^2) = -9$$? It can be reasoned that it should be interpreted as $$\displaystyle 0 - 3^2 = -9$$, as there is an implicit leading zero.
That is just how I think of it.

#### toponlinetool

##### New member
$$\displaystyle \dfrac{2(3)^{2}}{2}$$

Is the top 36 or 18?
solve parenthesis first. so, you will get 18 as the numerator.

#### Dr.Peterson

##### Elite Member
solve parenthesis first. so, you will get 18 as the numerator.
Actually, "parentheses first" doesn't help here; all that says is that you evaluate (not "solve") the 3 before doing anything else. What matters here is "exponents first" (before multiplication).