See How Things Work

Expressions with several operations

Unit
Order of Operations
Part
1. Order of Operations
Lesson
1.1

An expression such as 2 + 3 × 4 contains more than one operation. Each operation acts on two numbers at a time, so such an expression is worked out in steps, one operation per step. This lesson shows that different orders of the steps can give different numbers, counts the possible orders, and proves when the order makes a difference and when it does not.

One operation, two numbers

The unit Addition called a combination of numbers and operations, such as 3 + 4, an expression (“What addition means”).⁠[1] The four operations met so far are addition (Addition), subtraction (Subtraction), multiplication (Multiplication) and division (Division). Each of them is performed on two numbers.⁠[2] For this reason each of them is called a binary operation: it can act on only two numbers at a time.⁠[3]

An expression with one operation, such as 9 − 4, is worked out in one step: 9 − 4 = 5. An expression may contain several operations, such as 2 + 3 × 4, which has an addition and a multiplication. Since each operation acts on just two numbers, such an expression cannot be worked out all at once. It is worked out in steps.

Definition (Step).

In an expression written as a row of numbers with an operation sign between each two neighbors, a step chooses one operation sign, carries out that operation on the two numbers on either side of it, and writes the result in place of those two numbers and the sign.

Carrying out all the operations of an expression in this way is called evaluating it, or simplifying it: doing all the arithmetic possible.⁠[4][5] The number that remains at the end is the value of the expression for that order of the steps. A step that has no whole-number result, such as 3 − 5 or 7 ÷ 2, cannot be carried out among the whole numbers (Subtraction 1.4, Division 1.2); an order of steps that needs one gives no whole-number value.

Proposition .

If every step has a whole-number result, an expression with k operation signs is worked out in exactly k steps, and a single number remains at the end.

Proof.

Each step removes one operation sign and replaces two numbers by one, so the row loses one sign and one number. A row with k signs has k + 1 numbers. After k steps no sign is left and k + 1 − k = 1 number remains. The process cannot stop earlier: while a sign is left, a next step can be taken, since every step has a result. (If some step has no whole-number result, the work stops there, with signs still left.)

Example (Two steps).

Work out 2 + 3 × 4 by doing the multiplication first.

  1. The expression has two signs, + and ×, so it takes two steps.
  2. Step 1, the multiplication: 3 × 4 = 12. The row becomes 2 + 12.
  3. Step 2, the addition: 2 + 12 = 14.

Answer: in this order, the value is 14. One number remains after two steps, as the Proposition says.

Different orders, different values

The steps can be taken in a different order. In 2 + 3 × 4 the addition can come first: 2 + 3 = 5, then 5 × 4 = 20. The same expression has given 14 in one order and 20 in the other.

2 + 3 × 4+ first× first5 × 42 + 12then ×then +2014
Figure. The expression 2 + 3 × 4 has two operations, so it is worked out in two steps. Doing the addition first gives 5 × 4 = 20; doing the multiplication first gives 2 + 12 = 14. The same symbols, read in two orders, give two different numbers.

This is not a peculiarity of one example. The order in which an expression is evaluated can be ambiguous:⁠[4] 5 + 4 × 3 gives 27 if the addition is done first and 17 if the multiplication is done first. An expression whose order is not fixed may have different meanings and different values.⁠[6] A row of numbers and signs therefore does not yet name one number. Something must say which step comes first. Lesson 1.2, “Parentheses and grouping symbols”, gives one answer: write the grouping into the expression. Lesson 1.3, “The order of operations as a convention”, gives the other: agree on a rule for reading rows that have no grouping symbols.

The parentheses already met in the units Addition, Subtraction and Division show the order in this lesson too: (2 + 3) × 4 means that 2 + 3 is worked out first, and 2 + (3 × 4) that 3 × 4 is.

Example (A subtraction and a multiplication).

Work out 20 − 2 × 5 in both orders.

  1. Subtraction first: 20 − 2 = 18, then 18 × 5 = 90. This is (20 − 2) × 5.
  2. Multiplication first: 2 × 5 = 10, then 20 − 10 = 10. This is 20 − (2 × 5).

Answer: 90 in one order, 10 in the other. The two values are far apart.

Example (Three operations).

Find every value that 18 − 6 ÷ 3 + 1 can have, depending on the order of the steps.

  1. There are three signs, so three steps. The first step can be any of the 3 signs, the second either of the 2 that remain, and the third is the one left: 3 × 2 × 1 = 6 orders.
  2. −, then ÷, then +: 18 − 6 = 12, 12 ÷ 3 = 4, 4 + 1 = 5. This is ((18 − 6) ÷ 3) + 1.
  3. ÷, then −, then +: 6 ÷ 3 = 2, 18 − 2 = 16, 16 + 1 = 17. This is (18 − (6 ÷ 3)) + 1.
  4. ÷, then +, then −: 6 ÷ 3 = 2, 2 + 1 = 3, 18 − 3 = 15. This is 18 − ((6 ÷ 3) + 1).
  5. − and + first, in either order, then ÷: 18 − 6 = 12 and 3 + 1 = 4, then 12 ÷ 4 = 3. This is (18 − 6) ÷ (3 + 1). The two orders −, +, ÷ and +, −, ÷ do the same three calculations, only the first two in a different sequence.
  6. +, then ÷, then −: 3 + 1 = 4, then 6 ÷ 4, which has no whole-number result. This is 18 − (6 ÷ (3 + 1)).

Answer: the six orders give five different groupings. Four of them have the values 5, 17, 15 and 3; the fifth has no whole-number value.

Looking ahead.

For a row of four numbers the five groupings above are all there are; for the product of four numbers a source lists the same five, and their number for longer rows is a Catalan number.⁠[7] Catalan numbers are studied in the unit Recurrences & Generating Functions.

Example (A common mistake: “the” answer).

One person says that 2 + 3 × 4 is 20, another that it is 14. Each says the other made an arithmetic mistake. Who is right?

  1. The first person added first: 2 + 3 = 5 and 5 × 4 = 20. Both steps are correct.
  2. The second multiplied first: 3 × 4 = 12 and 2 + 12 = 14. Both steps are correct.
  3. Neither made an arithmetic mistake. They worked out two different groupings, (2 + 3) × 4 and 2 + (3 × 4).

Answer: the disagreement is about the order of the steps, not about arithmetic. The row 2 + 3 × 4 by itself does not decide it; lesson 1.3 gives the rule that does, and by that rule the value is 14.

Game

Choose the order

Round
1
Score
0
Streak
0

Carry out the operations of 5 × 4 × 5 + 4 one at a time, in any order you like, so that the result is 120. Tap an operation sign to carry it out on the two numbers beside it.

5454

When the order does not matter

For some expressions every order gives the same value. Changing the grouping of three numbers that are added does not change the result: this is the associative property of addition (Addition 1.6).⁠[8] The same holds for three numbers that are multiplied, by the associative property of multiplication (Multiplication 1.6).⁠[9] In both cases, adding or multiplying three numbers gives the same result whatever the order of the operations.⁠[10] Addition 1.6 extends this to any number of addends, in any order and with any grouping, and Multiplication 1.6 does the same for factors.

Proposition .

An expression in which every operation is an addition has the same value in every order of the steps. The same is true when every operation is a multiplication.

Proof.

Every order of the steps adds the numbers of the row two at a time, each number being used once. By the theorem “any order, any grouping” of Addition 1.6, every such calculation gives the same result. For multiplications, the same argument uses the corresponding theorem of Multiplication 1.6.

Example (An edge case: only additions).

Work out 5 + 7 + 8 in both orders.

  1. Left addition first: 5 + 7 = 12, then 12 + 8 = 20.
  2. Right addition first: 7 + 8 = 15, then 5 + 15 = 20.

Answer: 20 in both orders, as the Proposition guarantees. In the same way, 2 × 3 × 5 is 6 × 5 = 30 or 2 × 15 = 30.

As soon as different operations meet, or a subtraction or a division is involved, the order usually matters. Subtraction 1.6 proved that (a − b) − c and a − (b − c) differ unless c = 0 (Subtraction 1.6), and Division 1.2 showed that (24 ÷ 4) ÷ 2 = 3 while 24 ÷ (4 ÷ 2) = 12 (Division 1.2). For an addition and a multiplication, the exact condition is the following.

Theorem .

Let a, b and c be whole numbers.

  1. (a + b) × c = a + (b × c) exactly when a = 0 or c = 1.
  2. (a × b) + c = a × (b + c) exactly when c = 0 or a = 1.
Proof.

(1) Multiplication distributes over addition (Multiplication 1.7),⁠[11] so (a + b) × c = a × c + b × c, where both products are worked out first. The two sides of (1) are therefore a × c + b × c and a + b × c. Both end by adding b × c. Two sums with the same second addend are equal exactly when their first addends are equal, because subtracting b × c from each gives back the first addend (Subtraction 1.2). So (1) holds exactly when a × c = a.

If a = 0, then a × c = 0 = a; if c = 1, then a × c = a (Multiplication 1.4). If a ≠ 0 and c ≠ 1, then either c = 0, and a × c = 0 is not a; or c ≥ 2, and a × c is the total of a groups of c (Multiplication 1.1). Each group then has at least 2, so the total is at least a groups of 2, which is a + a, more than a since a ≥ 1. So a × c = a exactly when a = 0 or c = 1.

(2) In the same way, a × (b + c) = a × b + a × c, and the two sides of (2) are a × b + c and a × b + a × c. They are equal exactly when c = a × c. If c = 0, both are 0; if a = 1, then a × c = c. If c ≠ 0 and a ≠ 1, then either a = 0, and a × c = 0 is not c; or a ≥ 2, and a × c, the total of a groups of c, is at least c + c, which is more than c since c ≥ 1. So c = a × c exactly when c = 0 or a = 1.

Example (The edge cases 0 and 1).

Work out 0 + 6 × 9 and 7 + 5 × 1 in both orders.

  1. (0 + 6) × 9 = 6 × 9 = 54, and 0 + (6 × 9) = 0 + 54 = 54. Here a = 0.
  2. (7 + 5) × 1 = 12 × 1 = 12, and 7 + (5 × 1) = 7 + 5 = 12. Here c = 1.
  3. For comparison, (7 + 5) × 2 = 24 but 7 + (5 × 2) = 17: with a = 7 and c = 2 neither condition holds.

Answer: 54 and 12 in both orders, exactly as the Theorem predicts; changing 1 to 2 makes the orders differ.

Caution.

“The order does not matter” is a property of particular expressions, never a rule to assume. A single example in which two orders agree, such as 0 + 6 × 9, says nothing about 2 + 6 × 9, where they give 72 and 56.

Exercises

Exercise .

Work out 6 + 4 × 5 in both possible orders.

▸ Show solution

Addition first: 6 + 4 = 10, then 10 × 5 = 50. Multiplication first: 4 × 5 = 20, then 6 + 20 = 26. The two values are 50 and 26.

Exercise .

Find both values of 12 ÷ 2 × 3, and write each order with parentheses.

▸ Show solution

Division first: 12 ÷ 2 = 6, then 6 × 3 = 18; this is (12 ÷ 2) × 3. Multiplication first: 2 × 3 = 6, then 12 ÷ 6 = 2; this is 12 ÷ (2 × 3). The values are 18 and 2.

Exercise .

An expression has six numbers and five operation signs. How many steps does working it out take, and in how many orders can the steps be taken?

▸ Show solution

Five signs give 5 choices for the first step, 4 for the second, 3 for the third, 2 for the fourth and 1 for the last: 5 × 4 × 3 × 2 × 1 = 120 orders. By the Proposition of Section 1, each order has exactly five steps.

Exercise .

For which whole numbers c is (5 + 3) × c equal to 5 + (3 × c)?

▸ Show solution

By part (1) of the Theorem with a = 5 and b = 3: since a ≠ 0, the two sides are equal exactly when c = 1. Check: for c = 1, (5 + 3) × 1 = 8 and 5 + 3 × 1 = 8. For c = 0 they are 0 and 5; for c = 2 they are 16 and 11.

Exercise .

Find every value that 20 − 8 ÷ 4 + 2 can have, depending on the order of the steps.

▸ Show solution

The six orders give five groupings:

  1. ((20 − 8) ÷ 4) + 2 = (12 ÷ 4) + 2 = 3 + 2 = 5;
  2. (20 − (8 ÷ 4)) + 2 = (20 − 2) + 2 = 18 + 2 = 20;
  3. (20 − 8) ÷ (4 + 2) = 12 ÷ 6 = 2;
  4. 20 − ((8 ÷ 4) + 2) = 20 − (2 + 2) = 20 − 4 = 16;
  5. 20 − (8 ÷ (4 + 2)): 8 ÷ 6 has no whole-number result.

The values are 5, 20, 2 and 16; one grouping has no whole-number value.

Exercise .

Someone claims that the order of the steps never matters when an expression has only additions and multiplications. Disprove the claim.

▸ Show solution

Take a = 2, b = 3 and c = 4: (2 + 3) × 4 = 20 but 2 + (3 × 4) = 14. One counterexample is enough to show that the statement “(a + b) × c = a + (b × c) for all whole numbers” is false. By the Theorem, it is true only when a = 0 or c = 1.

Exercise .

Prove part (2) of the Theorem in detail, and give an example with a = 1.

▸ Show solution

Both sides are worked out with the distributive property: (a × b) + c and a × (b + c) = a × b + a × c. They end by adding to a × b, so they are equal exactly when c = a × c. If c = 0, both are 0. If a = 1, a × c = c. If c ≠ 0 and a ≠ 1, then a = 0 gives a × c = 0 ≠ c, and a ≥ 2 gives a × c ≥ c + c > c, since a × c is the total of a groups of c. So the two sides are equal exactly when c = 0 or a = 1, which is part (2) of the Theorem. Example: (1 × 6) + 4 = 10 = 1 × (6 + 4).

Summary

  1. Each of the four operations acts on two numbers at a time, so an expression with several operations is worked out in steps, one operation per step; k operation signs take k steps.
  2. Different orders of the steps can give different values: 2 + 3 × 4 is 20 if the addition comes first and 14 if the multiplication comes first.
  3. With three signs there are 6 orders of the steps but only 5 different groupings, because two independent steps can be taken in either sequence.
  4. When every operation is an addition, or every operation is a multiplication, every order gives the same value.
  5. (a + b) × c = a + (b × c) only when a = 0 or c = 1. In general a row of numbers and signs needs grouping symbols (lesson 1.2) or an agreed rule (lesson 1.3) to have one value.

Sources

  1. 1.
    Lynn Marecek, MaryAnne Anthony-Smith and Andrea Honeycutt Mathis, Prealgebra (2nd ed., OpenStax, Rice University, 2020).
    Chapter 1, “Whole Numbers”, section 1.2, “Add Whole Numbers” (“Use Addition Notation”), p. 23 (the whole topic: pp. 23–24).
    “A math statement that includes numbers and operations is called an expression.”
    Used for: a combination of numbers and operations, such as 3 + 4, is called an expression.
  2. 2.
    Lynn Marecek, MaryAnne Anthony-Smith and Andrea Honeycutt Mathis, Prealgebra (2nd ed., OpenStax, Rice University, 2020).
    Chapter 2, “The Language of Algebra”, section 2.1, “Use the Language of Algebra” (“Use Variables and Algebraic Symbols”), p. 96 (the whole topic: pp. 95–97).
    “We perform these operations on two numbers.”
    Used for: each of the four operations (addition, subtraction, multiplication and division) is performed on two numbers.
  3. 3.
    H. Wu, ““Order of operations” and other oddities in school mathematics”, Department of Mathematics, University of California, Berkeley (2007).
    Section “Why Not in Arithmetic?”. math.berkeley.edu/~wu/order5.pdf · open at the quoted passage.
    “the idea of each arithmetic operation being binary (i.e., each can operate on only two numbers at a time)”
    Used for: each arithmetic operation is binary: it can act on only two numbers at a time.
  4. 4.
    David Arnold, “Prealgebra, 1.5 “Order of Operations””, Mathematics LibreTexts (College of the Redwoods, CC BY-NC-SA).
    “The order in which we evaluate expressions can be ambiguous.”
    Used for: working out an expression is called evaluating it; the order of evaluation can be ambiguous (the source shows this with an example of its own, an addition and a multiplication worked out in both orders).
  5. 5.
    Lynn Marecek, MaryAnne Anthony-Smith and Andrea Honeycutt Mathis, Prealgebra (2nd ed., OpenStax, Rice University, 2020).
    Chapter 2, “The Language of Algebra”, section 2.1, “Use the Language of Algebra” (“Simplify Expressions with Exponents”), p. 103 (the whole topic: pp. 103–105).
    “To simplify a numerical expression means to do all the math possible.”
    Used for: evaluating an expression is also called simplifying it: doing all the arithmetic possible.
  6. 6.
    Lynn Marecek, MaryAnne Anthony-Smith and Andrea Honeycutt Mathis, Prealgebra (2nd ed., OpenStax, Rice University, 2020).
    Chapter 2, “The Language of Algebra”, section 2.1, “Use the Language of Algebra” (“Simplify Expressions Using the Order of Operations”), p. 105 (the whole topic: pp. 105–106).
    “Otherwise, expressions may have different meanings, and they may result in different values.”
    Used for: without an agreed order, an expression may have different meanings and different values.
  7. 7.
    Kenneth H. Rosen, Discrete Mathematics and Its Applications (8th ed., McGraw-Hill, 2019).
    Chapter 8, “Advanced Counting Techniques”, section 8.1, “Applications of Recurrence Relations” (8.1.2, “Modeling With Recurrence Relations”), Example 5, p. 532 (the whole topic: pp. 532–533).
    “there are five ways to parenthesize”
    Used for: a product of four numbers can be parenthesized in five ways (the source’s full sentence: C₃ = 5 because there are five ways to parenthesize x₀ · x₁ · x₂ · x₃); the number of ways for longer rows is a Catalan number.
  8. 8.
    Lynn Marecek, MaryAnne Anthony-Smith and Andrea Honeycutt Mathis, Prealgebra (2nd ed., OpenStax, Rice University, 2020).
    Chapter 7, “The Properties of Real Numbers”, section 7.2, “Commutative and Associative Properties” (“Use the Commutative and Associative Properties”), p. 548 (the whole topic: pp. 547–548).
    “When adding three numbers, changing the grouping of the numbers does not change the result. This is known as the Associative Property of Addition.”
    Used for: changing the grouping of three numbers that are added does not change the result (the associative property of addition).
  9. 9.
    Lynn Marecek, MaryAnne Anthony-Smith and Andrea Honeycutt Mathis, Prealgebra (2nd ed., OpenStax, Rice University, 2020).
    Chapter 7, “The Properties of Real Numbers”, section 7.2, “Commutative and Associative Properties” (“Use the Commutative and Associative Properties”), p. 548 (the whole topic: pp. 547–548).
    “When multiplying three numbers, changing the grouping of the numbers does not change the result. This is known as the Associative Property of Multiplication.”
    Used for: changing the grouping of three numbers that are multiplied does not change the result (the associative property of multiplication).
  10. 10.
    Kenneth H. Rosen, Discrete Mathematics and Its Applications (8th ed., McGraw-Hill, 2019).
    Chapter Appendix 1, “Axioms for the Real Numbers and the Positive Integers”, section A1.1, “Axioms for Real Numbers” (“The Field Axioms”), pp. A-1 (the whole topic: pp. A-1–A-2).
    “The next two axioms tell us that when we add or multiply three real numbers, we get the same result regardless of the order of operations; these are the associative laws.”
    Used for: adding or multiplying three numbers gives the same result whatever the order of the operations (the associative laws).
  11. 11.
    Michelle Manes, “Properties of Operations”, Mathematics for Elementary Teachers, University of Hawaiʻi (Pressbooks) (2018).
    “Multiplication distributes over addition.”
    Used for: multiplication distributes over addition (the source writes x · (y + z) = x · y + x · z; with the commutative property this is (a + b) × c = a × c + b × c), used in the proof of the Theorem.