# Order and precedence

## Conventional order

Mathematical expressions and operations are generally read and executed from left to right. By convention, the order of operations in an arithmetic expression is: Everything in brackets ("()") belongs together and represents a number as such. In a chain of different operations without brackets, multiplication and division have higher precedence than addition and subtraction. For the rest it is just execution from left to right. In specific fields of application, in older books or in some parts of the world other conventions may be used.

Execution from left to right:

 3 − 2 + 4 = (3 − 2) + 4 = 1 + 4 = 5

 3 − 2 + 4 = 3 + −2 + 4 = −2 + 3 + 4 = 4 + −2 + 3 = ... = 5
 3 − 2 + 4 ≠ 3 − (2 + 4) ≠ 3 − 6 ≠ −3

Execution from left to right, but first the multiplication:

 3 − 2 × 4 + 5 = 3 − (2 × 4) + 5 = 3 − 8 + 5 = 0

Execution from left to right, but first multiplication and division:

 3 × 5 − 3 ÷ 3 + 6 = (3 × 5) − (3 ÷ 3) + 6 = 15 − 1 + 6 = 20

By the way, this kind of chains of operations with "in-line" division (using an operator "÷", or similar) are highly unusual in mathematics. When division is involved, notations with fraction bars instead are far more common (and accessible). In a later chapter more about this.

### Mnemonics

Students are often taught mnemonics to help them remember the order of operations. PEMDAS for Parentheses, Exponents, Multiplication/Division, Addition/Subtraction, is often used, among a lot of others. However, they are not really necessary and they are ineffective. Rather than being useful mnemonics, they are often misleading and a source of confusion.

## Commutativity and associativity

Mathematical expressions and operations are generally read and executed from left to right. We have seen that in some cases direction is not relevant. Addition and multiplication are commutative, meaning that the order of operands has no effect on the result. Subtraction and division are non-commutative and they are also non-associative.

Commutativity:

3 + 2 = 2 + 3

3 × 2 = 2 × 3

3 − 2 ≠ 2 − 3

3 ÷ 2 ≠ 2 ÷ 3

Associativity:

4 + (3 + 2) = (4 + 3) + 2

4 × (3 × 2) = (4 × 3) × 2

4 − (3 − 2) ≠ (4 − 3) − 2

4 ÷ (3 ÷ 2) ≠ (4 ÷ 3) ÷ 2

 110 − 100 − 10 = (110 − 100) − 10 = 10 − 10 = 0

This is simply an execution from left to right. But it was also stated that this is the same as adding all the numbers, except the first one, and subtract the result from the first number:

 110 − 100 − 10 = 110 − (100 + 10) = 110 − 110 = 0

Now we know about negation and the distributive rule, we can "proof" this:

 110 − 100 − 10 = 110 + −1 × (100 + 10) = 110 + −(100 + 10)) = 110 + −(110) = 110 − 110 = 0

Subtraction in combination with the "disguised" distributive property is often a source of errors:

 110 − 100 + 10 = 110 + −1 × (100 − 10) = 110 − (100 − 10)
 100 − (23 − 7) = 100 − 23 + 7 100 − (23 + 7) = 100 − 23 − 7

In the chapter about subtraction we learned that we subtract the ones, the tens, the hundreds etc. of both numbers:

 29 − 17 = (20 + 9) − (10 + 7) = 20 + 9 − 10 − 7 = 20 + 9 + −10 + −7 = 20 − 10 + 9 − 7 = (20 − 10) + (9 − 7)