Order of operations

Order of operations is the order in which we perform addition, subtraction, multiplication, division, and other operations in a mathematical expression.

There is a mnemonic PEMDAS--Please Excuse My Dear Aunt Sally--which may help you remember the order in which to perform the mathematical operations:
 * 1) P = Parentheses
 * 2) E = Exponents
 * 3) MD = Multiplication and Division--working from left to right
 * 4) AS = Addition and Subtraction--working from left to right

Let's look at some examples of how this works. For each example below, the mathematical expression is listed fist, followed by a new version of the equation which shows the results of the individual operations (e.g., simplification of exponent or multiplying two numbers). The operations completed for each step are described next to the step. The first example shows only one operation completed in each step. Examples 2 and 3 show more than one operation completed in some steps.

Example 1:
$$(2+1)^3+10-8*5/2$$

$$\begin{align} & =3^3+10-8*5/2 \qquad \text{Parentheses}\\ & =27+10-8*5/2 \qquad \text{Exponent}\\ & =27+10-40/2 \qquad \text{Multiplication, because it is leftmost}\\ & =27+10-20 \qquad \text{Division, because it is next when working from left to right}\\ & =37 - 20  \qquad \text{Addition, because it is leftmost}\\ & =17  \qquad \text{Subtraction, because it is next when working from left to right}\\ \end{align}$$

Example 2:
$$(5 + 3) / 2 + -8 / 4 + 2 * 3$$

$$\begin{align} & = 8 / 2 + -8 / 4 + 2 * 3  \qquad \text{Parentheses}\\ & = 4 + -2 + 6  \qquad \text{Division, as they appear working from left to right}\\ & = 8      \qquad \text{Addition (including addition of negative number), as they appear working from left to right}\\ \end{align}$$

Example 3:
$$4^3 * 2 + 2^4 / 4 - (4 + 1)^2$$

$$\begin{align} & = 4^3 * 2 + 2^4 / 4 - 5^2 \qquad \text{Parentheses}\\ & = 64 * 2 + 16 / 4 - 25  \qquad \text{Exponents}\\ & = 128 + 4 - 25       \qquad \text{Multiplication and Division, as they appear working from left to right}\\ & = 107      \qquad \text{Addition and Subtraction, as they appear working from left to right}\\ \end{align}$$