# Order of operations

https://arbital.com/p/order_of_operations

by Joe Zeng Jul 6 2016 updated Jul 6 2016

Conventions used for disambiguating infix notation.

The order of operations is a notational convention employed in arithmetical expressions to disambiguate the order in which operations should be performed.

It is also referred to PEMDAS, BEDMAS, BODMAS, or other such acronyms depending on where you live. The acronym is always 6 letters, and refers to the following things in order:

1. [parentheses] (or Brackets), in order of inside-most parentheses first
2. [exponent Exponents] (or Orders or Indices), in order of inside-most (or rightmost) exponents first
3. [multiplication] and [division], in order from left to right
4. [addition] and [subtraction], in order from left to right

## Motivation

The infix notation we use to write expressions of mathematical operators is inherently ambiguous. Only in some very special examples where the expression consists of only a single associative operation do all possible orders of evaluation evaluate to the same thing. When considering the expression $2 - 4 + 3$, do we do the $2 - 4$ first or the $4 + 3$ first? The result is either $1$ or $-5$ depending on which you choose. When considering the expression $7 + 8 \times 9 - 6$, which operation do we do first? The result could be anywhere from $31$ to $129$ depending on the order you do them in.

Therefore, to relieve mathematicians of placing brackets around every expression, there are some standard, intuitive conventions put in place.

## Example expressions

Consider the expression $3 + 7 \times 2^{(6 + 8)}$. We do parentheses first: $$3 + 7 \times 2^{14}$$ Then exponents: $$3 + 7 \times 16384$$ Then multiplication and division: $$3 + 114688$$ And finally addition and subtraction: $$114691$$

## Notable ambiguous cases

The expression $48 \div 2 (9 + 3)$ is a controversial ambiguity in the order of operations that results from an ambiguity in multiplication by juxtaposition — which is, the convention that numbers next to each other in brackets should be multiplied together. For example, $2(3+5)$ is equal to $2 \times (3 + 5)$ or $16$.

If multiplication by juxtaposition is taken as a parenthetical operation due to the parentheses in the operands, then the result is 2:

\begin{align*} 48 \div 2 (9 + 3) &= 48 \div 2 (12) \\ &= 48 \div 24 \\ &= 2 \end{align*}

However, if multiplication by juxtaposition is taken as simply a regular multiplication operation, the result is 288:

\begin{align*} 48 \div 2 (9 + 3) &= 48 \div 2 \times 12 \\ &= 24 \times 12 \\ &= 288 \end{align*}

The second step is different because the 48 and 2 are operated on first, as the left most division or multiplication operation in the expression.