# Order of Operations (PEMDAS)

## Related Calculator: Order of Operations Calculator

**Order of Operations (PEMDAS):**

**Parentheses****Exponent****Multiplication****Division****Addition****Subtraction**

Note, that multiplication and division rank equally. Also addition and subtraction rank equally.

Operations, that rank equally, can be performed from left to right.

These are the rules, that allows us to simplify number expressions, because there are situationss, when we don't know what operation to perform first.

Instead of parentheses `(\ )`, square brackets `[\ ]` can be used. They are often used to make expression look nicer.

We used term "order of operations"? But what is an operation?

**Operation** means action (you need to do something). Addition, subtraction, multiplication, division, raising to power are examples of operations.

For example, in expression `2+3`, `+` is operation, because you need to add two numbers to get the result.

**Number expression** is a bunch of numbers and operations.

For example, `9+3*(7-5)^2+8/2` is a number expression.

To simplify expression means to perform operations (where it is possible).

**Example 1**. Simplify `4+5*6`.

How do we simplify this?

From left to right? `4+5*6=9*6=54`.

No, we need to use PEMDAS: multiplication ranks higher, so we perform it first: `4+5*6=4+30=34`.

**Thus, correct answer is 34**.

But, if we slightly modify our expression, like `(4+5)*6`, then addition is performed first, because parentheses have the highest rank:

`color(red)((4+5)*6=9*6=54)`

`color(purple)(4+5*6=4+30=34)`

In most cases, you will need to evaluate expression inside parenthesis, using same rules.

**Example 2**. Simplify the following: `(6^2-8)-:7*3^2`.

Paretheses first, but inside parentheses there is complex expression, that can be evaluated, using order of operations.

`color(red)((6^2-8))-:7*3^2` | (parentheses first) |

`color(red)((36-8))-:7*3^2` | (exponent) |

`color(red)(28)-:7*3^2` | (subtraction) |

We are done with parentheses, so apply PEMDAS to the obtained result.

`28-:7*9` | (exponent) |

`4*9` | (division) |

`36` | (multiplication and done) |

**So, answer is 36**.

Sometimes, in the expression there can be a fraction, like `m/n`. But each numerator and denominator can be expression itself. In this case, since `m/n=(m)-:(n)`, we separately evaluate numerator and denominator, and then divide the result.

**Example 3**. Simplify the following: `(5+7)/(3^2-5)*(18+8)/(9+4)`.

Here we have two fractions, so we evaluate them from left to right.

`12/(3^2-5)*(18+8)/(9+4)` | (numerator of the first fraction) |

`12/(9-5)*(18+8)/(9+4)` | (denominator of the first fraction: exponent) |

`12/4*(18+8)/(9+4)` | (denominator of the first fraction: subtraction) |

`12/4*26/(9+4)` | (numerator of the second fraction) |

`12/4*26/13` | (denominator of the second fraction) |

`3*26/13` | (division and multiplication from left to right) |

`78/13` | (division and multiplication from left to right) |

`6` | (division and done) |

**So, answer is 6**.

As you could notice, operations that rank equally, can be performed simultaneously.

For example, `3*6-12/4` can be rewritten as `18-3` (we perform multiplication and division simultaneously, because they have equal rank).

No need to say, that parentheses can be nested, as well as other operations.

For example, in `(2+(5-4)*3)*3` we have nested parentheses and in `3^(2+5*4^3)` exponent is expression, that also contains exponent.

No need to panic! Such expressions are simplified as always. We start from outer, but, in fact, to evaluate outer, we need to simplify inner.

**Example 4**. Simplify the following: `(2+(5-4)*3)*3^(325-5*4^3)`.

We start from outer parentheses, but to simplify it, we need to evaluate inner expression: `color(red)((2+(5-4)*3))*3^(325-5*4^3)`.

`color(red)((2+1*3))*3^(325-5*4^3)` | (parentheses inside parentheses) |

`color(red)((2+3))*3^(325-5*4^3)` | (multiplication inside parentheses) |

`5*3^(325-5*4^3)` | (addition inside parentheses) |

Now, we need to evaluate exponent, but exponent is a complex expression, so we simplify it, using PEMDAS.

`5*3^(color(red)(325-5*64))` | (exponent inside the exponent) |

`5*3^(color(red)(325-320))` | (multiplication inside the exponent) |

`5*3^5` | (subtraction inside the exponent) |

`5*243` | (exponent) |

`1215` | (multiplication and done) |

**So, answer is 1215**.

Finally, let's solve the last example, that has all features, that we've discussed.

**Example 5**. Simplify the following: `(70-4*(5-1)^2)/(2*3)*(3^(11-3^(3^2-2^2-3))*3-5)/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)`.

Wow! There is a lot of work to do!

We start from the numerator of first fraction: `(color(red)(70-4*(5-1)^2))/(2*3)*(3^(11-3^(3^2-2^2-3))*3-5)/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)`.

`(color(red)(70-4*4^2))/(2*3)*(3^(11-3^(3^2-2^2-3))*3-5)/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (evaluate base of the exponent)

`(color(red)(70-4*16))/(2*3)*(3^(11-3^(3^2-2^2-3))*3-5)/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (exponent)

`(color(red)(70-64))/(2*3)*(3^(11-3^(3^2-2^2-3))*3-5)/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (multiplication)

`6/(2*3)*(3^(11-3^(3^2-2^2-3))*3-5)/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (subtraction)

Now, evaluate denominator of the first fraction:

`6/6*(3^(11-3^(3^2-2^2-3))*3-5)/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (subtraction)

Since fraction means division, we can simplify the fraction and then perform other operations. Alternatively, we can perform division from left to right:

`1*(3^(11-3^(3^2-2^2-3))*3-5)/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (subtraction)

Now, simplify numerator of the second fraction: `1*(color(red)(3^(11-3^(3^2-2^2-3))*3-5))/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)`.

`1*(color(red)(3^(11-3^(9-4-3))*3-5))/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (first operation is exponent, but we need to simplify it, so start from the inner exponent; inner exponent `3^(3^2-2^2-5)` also has exponents, so we simplify them first; here, as you can see, we have deep nesting)

`1*(color(red)(3^(11-3^2)*3-5))/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (subtraction; simultaneously 2 times)

`1*(color(red)(3^(11-9)*3-5))/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (inner exponent)

`1*(color(red)(3^2*3-5))/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (subtraction)

`1*(color(red)(9*3-5))/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (at last, outer exponent)

`1*(color(red)(27-5))/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (multiplication)

`1*22/(200-(4+3)*[2+(3+(12-6)-:3)*5])-:(5+7*1)` (subtraction)

Now, handle the denominator of fraction: `1*22/(color(red)(200-(4+3)*[2+(3+(12-6)-:3)*5]))-:(5+7*1)`.

Remember that square brackets play the same role as parentheses.

We start from parentheses (from left to right):

`1*22/(color(red)(200-7*[2+(3+(12-6)-:3)*5]))-:(5+7*1)` (subtraction)

To simplify next parentheses, we need to simplify expression between them. This expression also contains parentheses, so we need to simplify the innermost parentheses:

`1*22/(color(red)(200-7*[2+(3+color(green)(6)-:3)*5]))-:(5+7*1)` | (subtraction) |

`1*22/(color(red)(200-7*[2+(3+color(green)(2))*5]))-:(5+7*1)` | (division) |

`1*22/(color(red)(200-7*[2+5*5]))-:(5+7*1)` | (addition) |

`1*22/(color(red)(200-7*[2+25]))-:(5+7*1)` | (multiplication) |

`1*22/(color(red)(200-7*27))-:(5+7*1)` | (addition) |

`1*22/(color(red)(200-189))-:(5+7*1)` | (multiplication) |

`1*22/11-:(5+7*1)` | (subtraction) |

`1*2-:(5+7*1)` | (division) |

`1*2-:(5+7)` | (parentheses: multiplication inside them) |

`1*2-:12` | (parentheses) |

`2-:12` | (multiplication) |

`1/6` | (division and done) |

**So, answer is `1/6`**.

**Things to remember**:

- Don't be afraid of complex expressions. Just use order of operations and simplify expressions, using PEMDAS, step by step.
- Nested expressions can be simplified, starting from the innermost one (to allow simplification of outer expression)
- Simplification of expressions can be performed in a number of ways. For example, in expression `3*4-:6`, we can first perform multiplication, then division. From another side, we can perform division and then multiplication. This can be done, because they have equal rank. You are free to choose the way you like, as long as it follows PEMDAS.
- Operations, that rank equally, can be performed simultaneously. For example, `4+5-7=2`.

Now, it is time to exercise.

**Exercise 1**. Simplify the following: `4+6-:2`.

**Answer**: `7`.

**Exercise 2**. Simplify the following: `(3^2-5)*(2^2+5)^2-35-:(5+2)`.

**Answer**: `319`.

**Exercise 3**. Simplify the following: `(4^3-3*7)/(4*5-12)*2^(2+1)`.

**Answer**: `43`.

**Exercise 4**. Simplify the following: `(2*(5+(3*7+2)*4))-3^(5*7*2^2-135)`.

**Answer**: `-49`.

**Exercise 5**. Simplify the following: `2+(3*(1+3^2)/(2^3-3))/(34-(5*(2+(3*2))))`.

**Answer**: `1`.