# Order of operations

In arithmetic and elementary algebra, certain rules are used for the order in which the operations in algebraic expressions are to be evaluated. These precedence rules (which are mere notational conventions, not mathematical facts) are also used in many programming languages and by most modern calculators. In computing, the standard algebraic notation is known as infix notation. This article assumes the reader is familiar with addition, division, exponential powers, multiplication, and subtraction.

## Contents

## The standard order of operations

- 1. Evaluate subexpressions contained within parentheses, starting with the innermost expressions. (Brackets [ ] are used here to indicate what is evaluated next.)

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle (4+10/2)/9=(4+[10/2])/9=[4+5]/9=1 \,}**

- 2. Evaluate exponential powers; for iterated powers, start from the right:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 2^{3^2}=2^{[3^2]}=[2^9]=512 \,}**

- 3. Evaluate multiplications and divisions, starting from the left:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 8/2\times3=[8/2]\times3=[4\times3]=12 \,}**

- 4. Evaluate additions and subtractions, starting from the left:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 7-2-4+1=[7-2]-4+1=[5-4]+1=[1+1]=2 \,}**

The expression: 2 + 3 × 4 is evaluated to 14, and not 20, because multiplication precedes addition. If the intention is to perform the addition first, parentheses must be used: (2 + 3) × 4 = 20.

In Australia and Canada, an acronym *BEDMAS* is often used as a mnemonic for *B*rackets, *E*xponents, *D*ivision, *M*ultiplication, *A*ddition, and *S*ubtraction.

In the UK and New Zealand, the acronym *BODMAS* is used for *B*rackets, *O*rders, *D*ivision, *M*ultiplication, *A*ddition, *S*ubtraction. This is sometimes written as *BOMDAS*, *BIDMAS* or *BIMDAS* where *I* stands for *I*ndices.

In the US, the acronym *PEMDAS* (for *P*arentheses, *E*xponentiation, *M*ultiplication/*D*ivision, *A*ddition/*S*ubtraction) is used instead, sometimes expressed as the mnemonic "*P*lease *E*xcuse *M*y *D*ear *A*unt *S*ally".

### Example

- Given:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 3-(5-(7+1))^2\times(-5)+2 \,}**

- Evaluate the innermost subexpression (7 + 1):

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 3-(5-8)^2\times(-5)+2 \,}**

- Evaluate the subexpression within the remaining parentheses (5 − 8):

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 3-(-3)^2\times(-5)+2 \,}**

- Evaluate the power of (−3)
^{2}:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 3-9\times(-5)+2 \,}**

- Evaluate the multiplication 9 × (−5):

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 3-(-45)+2 \,}**

- Evaluate the subtraction 3 − (−45):

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 48+2 \,}**

- Evaluate the addition 48 + 2:

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 48+2=50 \,}**

## Proper use of parentheses and other grouping symbols

When you are restricted to using a straight text editor, parentheses (or more generally "grouping symbols") must be used generously to make up for the lack of graphics, like square root symbols. Here are some rules for doing so:

1) Whenever there is a fraction formed with a slash, put the numerator (the numbers on top of the fraction) in one set of parentheses, and the denominator (the numbers on the bottom of the fraction) in another set of parentheses. This is not required for fractions formed with underlines:

*y*= (*x*+1)/(*x*+2)

2) Whenever there is an exponent using the caret (^) symbol, put the base in one set of parentheses, and the exponent in another set of parentheses:

*y*= (*x*+1)^(*x*+2)

3) Whenever there is a trig function, you may put the argument of the function, typically shown in bold and/or italics, in parentheses:

*y*= sin(*x*+1)

4) The rule for trig functions also applies to any other function, such as "sqrt". That is, the argument of the function should be contained in parentheses:

*y*= sqrt(*x*+1)

5) An exception to the rules requiring parentheses applies when only one item is present. While correct either way, it is more readable if these parentheses are omitted:

*y*= (3)/(*x*) or*y*= 3/*x*

*y*= (3)/(2*x*) or*y*= 3/(2*x*)

*y*= (*x*)^(5) or*y*=*x*^5

*y*= (2*x*)^(5) or*y*= (2*x*)^5

*y*= (*x*)^(5*z*) or*y*=*x*^(5*z*)

Note that this exception does not apply to trig functions or any other function, which should use parentheses even if only one value is present:

*y*= sqrt(2)

*y*= tan(30)

6) Whenever anything can be interpreted multiple ways, put the part to be done first in parentheses, to make it clear.

7) You may alternate use of the different grouping symbols (parentheses, brackets, and braces) to make it more readable. For example:

*y*= { 2 / [ 3 / ( 4 / 5 ) ] }

is more readable than:

*y*= ( 2 / ( 3 / ( 4 / 5 ) ) )

Note that certain applications, like computer programming, will restrict you to certain grouping symbols.

## Special cases

In the case that a factorial is in an expression, it is evaluated after parentheses or other grouping symbols, but before everything else (the common mnemonics would be B*F*EDMAS, B*F*ODMAS, B*F*IMDAS, and P*F*EMDAS, if an *F* were included for factorials).

When new operations are defined they are generally presumed to take precedence over other operations unless defined otherwise. In the case where repeated operators of the same type are used, such as in

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle a/b/c}**

the expression is evaluated from left to right, as

**Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle ((a/b)/c)}**

## See also

- Common operator notation (for a more formal description)
- associativity
- commutativity
- distributivity

## External links

- Order of operations on PlanetMath.
- For a rationale behind the use of the order of operations, see MathandText.