Order of Operations with Variables

Apply PEMDAS to expressions that contain variables.

beginneralgebrapemdasexpressionsUpdated 2026-02-02

For Elementary Students

What Is Order of Operations?

Order of operations is the set of rules that tell you WHICH operation to do FIRST when you have multiple operations!

Think about it like this: It's like following a recipe! You can't bake the cake before mixing the ingredients. There's an ORDER!

Expression: 3 + 4 × 2

Wrong order: 3 + 4 = 7, then 7 × 2 = 14 ✗
Right order: 4 × 2 = 8, then 3 + 8 = 11 ✓

PEMDAS: The Magic Word!

PEMDAS tells you the order to follow:

P - Parentheses      ( )
E - Exponents        x²
M - Multiplication   ×
D - Division         ÷
A - Addition         +
S - Subtraction      −

Memory trick: "Please Excuse My Dear Aunt Sally"

When There Are Variables

Good news: PEMDAS works THE SAME WAY even when there are letters (variables)!

With numbers: 3 + 4 × 2 = 3 + 8 = 11

With variables: 3 + 4 × x
(Still multiply first, then add!)

Example 1: Evaluating an Expression

Problem: Evaluate 3x + 5 when x = 4

Step 1: Replace x with 4

3x + 5
3(4) + 5

Step 2: Follow PEMDAS (multiply first!)

3(4) + 5
= 12 + 5
= 17

Answer: 17!

Example 2: With Exponents

Problem: Evaluate 2x² + 3 when x = 5

What's happening?

x² means x × x (exponent!)
2x² means 2 × (x²)

Step 1: Replace x with 5

2x² + 3
2(5)² + 3

Step 2: Do exponents first (E in PEMDAS)

2(5)² + 3
= 2(25) + 3

Step 3: Then multiply (M in PEMDAS)

= 2(25) + 3
= 50 + 3

Step 4: Finally add (A in PEMDAS)

= 50 + 3
= 53

Answer: 53!

BIG Warning: Squaring vs. Multiplying Then Squaring

Be VERY careful with exponents and what they apply to!

Example: 2x² vs (2x)² when x = 3

Version 1: 2x² (exponent on x only)

2x² = 2(x²) = 2(3²) = 2(9) = 18

Version 2: (2x)² (exponent on everything in parentheses)

(2x)² = (2 × 3)² = (6)² = 36

They're different! Parentheses matter!

2x² = 18
(2x)² = 36

VERY different answers!

Example 3: More Complex Expression

Problem: Evaluate 3x² + 2x − 5 when x = 3

Step 1: Substitute x = 3

3(3)² + 2(3) − 5

Step 2: Exponents first (E)

= 3(9) + 2(3) − 5

Step 3: Multiply (M)

= 27 + 6 − 5

Step 4: Add and subtract left to right (A and S)

= 27 + 6 − 5
= 33 − 5
= 28

Answer: 28!

Example 4: With Parentheses

Problem: Evaluate 4(x + 3) − 2x when x = 5

Step 1: Substitute x = 5

4(5 + 3) − 2(5)

Step 2: Parentheses first (P)

= 4(8) − 2(5)

Step 3: Multiply (M)

= 32 − 10

Step 4: Subtract

= 22

Answer: 22!

Simplifying Before Evaluating

Sometimes it's easier to simplify the expression FIRST, then plug in the number!

Problem: Simplify 4(x + 3) − 2x, THEN evaluate when x = 5

Step 1: Simplify using distributive property

4(x + 3) − 2x
= 4x + 12 − 2x    (distribute the 4)
= 2x + 12         (combine like terms: 4x − 2x = 2x)

Step 2: Now evaluate when x = 5

2x + 12
= 2(5) + 12
= 10 + 12
= 22

Same answer!

The Distributive Property

The distributive property lets you "distribute" (spread out) multiplication over addition or subtraction.

Rule: a(b + c) = ab + ac

3(x + 4)
= 3·x + 3·4
= 3x + 12

More examples:

5(2y − 1)
= 5·2y − 5·1
= 10y − 5

−2(x + 6)
= −2·x + (−2)·6
= −2x − 12

Important: When you distribute a negative, the signs flip!

−3(x − 4)
= −3·x − (−3)·4
= −3x + 12

Visual: PEMDAS Ladder

Think of PEMDAS as climbing DOWN a ladder:

Step 1: Parentheses  ( )      TOP
Step 2: Exponents    x²       ↓
Step 3: Multiply/Divide ×÷    ↓
Step 4: Add/Subtract  +-      BOTTOM

Go from TOP to BOTTOM!

Quick Tips

Tip 1: Write out each step—don't skip!

Tip 2: Do exponents BEFORE multiplying!

Tip 3: Watch out for parentheses—they change everything!

Tip 4: 2x²(2x)² — parentheses matter!

Tip 5: When in doubt, follow PEMDAS!

For Junior High Students

Order of Operations in Algebraic Expressions

Order of operations (PEMDAS/BODMAS) is a convention that specifies the sequence in which operations should be performed to ensure consistent interpretation of mathematical expressions.

Definition: PEMDAS establishes operator precedence:

  1. Parentheses (or brackets)
  2. Exponents (powers, roots)
  3. Multiplication and Division (left to right)
  4. Addition and Subtraction (left to right)

Importance: Without this convention, 3 + 4 × 2 could be interpreted as either 11 or 14.

With variables: The same rules apply regardless of whether operands are numerical constants or algebraic variables.

Evaluating Algebraic Expressions

Process: To evaluate an expression containing variables:

  1. Substitute given values for variables
  2. Apply order of operations to compute the result

Example 1: Evaluate 3x² + 2x − 5 when x = 4

Step 1: Substitute

3(4)² + 2(4) − 5

Step 2: Apply PEMDAS

Exponents:      3(16) + 2(4) − 5
Multiplication: 48 + 8 − 5
Left to right:  56 − 5 = 51

Result: 51

Critical Distinction: 2x² vs (2x)²

Understanding exponent scope:

Expression 2x²: Exponent applies only to x

2x² = 2 · (x²)

When x = 3:

2x² = 2 · (3²) = 2 · 9 = 18

Expression (2x)²: Exponent applies to entire product

(2x)² = (2x) · (2x) = 4x²

When x = 3:

(2x)² = (2 · 3)² = 6² = 36

Algebraic difference:

2x² = 2x²
(2x)² = 4x²

Generalization: (ab)ⁿ = aⁿbⁿ but ab ⁿ = a · bⁿ

Operator Precedence in Detail

Level 1: Parentheses

Evaluate innermost parentheses first, working outward.

Example: 2[(3 + x) − 4] when x = 5

= 2[(3 + 5) − 4]
= 2[8 − 4]
= 2[4]
= 8

Level 2: Exponents

Evaluate powers and roots.

Example: x³ − 2x² when x = 3

= (3)³ − 2(3)²
= 27 − 2(9)
= 27 − 18
= 9

Level 3: Multiplication and Division

Perform from left to right.

Example: 12x ÷ 3 × 2 when x = 4

= 12(4) ÷ 3 × 2
= 48 ÷ 3 × 2
= 16 × 2
= 32

Level 4: Addition and Subtraction

Perform from left to right.

Example: x + 2x − x when x = 5

= 5 + 2(5) − 5
= 5 + 10 − 5
= 15 − 5
= 10

The Distributive Property

Definition: For any real numbers a, b, c:

a(b + c) = ab + ac
a(b − c) = ab − ac

Purpose: Removes parentheses by "distributing" multiplication over addition/subtraction.

Example 1: Expand 3(2x + 5)

= 3 · 2x + 3 · 5
= 6x + 15

Example 2: Expand −4(x − 3)

= −4 · x − (−4) · 3
= −4x + 12

Note: Distributing a negative flips signs inside parentheses.

Example 3: Expand 5(2y − 1) + 3y

= 10y − 5 + 3y
= 13y − 5    (combining like terms)

Simplifying Before Evaluating

Strategy: Algebraic simplification before substitution can reduce computational complexity.

Example: Simplify 4(x + 3) − 2x then evaluate when x = 5

Method 1: Evaluate directly

4(5 + 3) − 2(5)
= 4(8) − 10
= 32 − 10
= 22

Method 2: Simplify first

4(x + 3) − 2x
= 4x + 12 − 2x
= 2x + 12

When x = 5:
2(5) + 12 = 10 + 12 = 22

Advantage of Method 2: Simpler arithmetic, especially with larger values or multiple evaluations.

Combining Like Terms

Definition: Like terms have identical variable parts (same variables raised to same powers).

Examples:

  • 3x and 5x are like terms
  • 2x² and 7x² are like terms
  • 3x and 3x² are NOT like terms
  • 2xy and 5xy are like terms

Combining: Add or subtract coefficients of like terms.

Example: Simplify 5x² + 3x − 2x² + 7x

= (5x² − 2x²) + (3x + 7x)
= 3x² + 10x

Complex Evaluation Example

Problem: Evaluate 2x² − 3(x + 1) + 4 when x = 3

Solution:

Step 1: Substitute

2(3)² − 3(3 + 1) + 4

Step 2: Parentheses

= 2(3)² − 3(4) + 4

Step 3: Exponents

= 2(9) − 3(4) + 4

Step 4: Multiplication

= 18 − 12 + 4

Step 5: Addition/Subtraction (left to right)

= 6 + 4
= 10

Result: 10

Nested Parentheses

Rule: Evaluate innermost parentheses first, working outward.

Example: Evaluate 2[3(x − 1) + 5] when x = 4

= 2[3(4 − 1) + 5]      (innermost: x − 1)
= 2[3(3) + 5]          (multiply inside brackets)
= 2[9 + 5]             (add inside brackets)
= 2[14]                (multiply)
= 28

Fractions and Division

Important: Division has same precedence as multiplication.

Example: Evaluate x/2 + 3x when x = 8

= 8/2 + 3(8)
= 4 + 24
= 28

With complex numerators/denominators: Treat fraction bar as grouping symbol.

Example: Evaluate (2x + 4)/6 when x = 7

= (2(7) + 4)/6
= (14 + 4)/6
= 18/6
= 3

The numerator 2x + 4 is evaluated completely before dividing by 6.

Common Errors

Error 1: Incorrect exponent scope

2x² when x = 3 → (2 · 3)² = 362x² when x = 3 → 2 · (3²) = 18

Error 2: Not following left-to-right for same precedence

20 − 8 + 3 = 20 − 11 = 920 − 8 + 3 = 12 + 3 = 15 (left to right)

Error 3: Distributing incorrectly

3(x + 4) = 3x + 43(x + 4) = 3x + 12

Error 4: Forgetting sign when distributing negative

−2(x − 5) = −2x − 5−2(x − 5) = −2x + 10

Error 5: Adding/subtracting non-like terms

3x + 2x² = 5x³3x + 2x² (cannot be combined)

Tips for Success

Tip 1: Write each step explicitly—mental math increases error risk

Tip 2: When substituting, use parentheses around substituted values

If x = −3 in expression 2x²:
Write: 2(−3)² not 2−3²

Tip 3: Verify exponent scope using parentheses

Tip 4: For distributive property, multiply EVERY term inside parentheses

Tip 5: Combine like terms only (same variable, same exponent)

Tip 6: Remember multiplication/division are same precedence (left to right)

Tip 7: Addition/subtraction are same precedence (left to right)

Extensions: Function Notation

Function notation is a formalized way to express variable evaluation.

Notation: f(x) = expression

Example: f(x) = 3x² + 2x − 5

To find f(4):

f(4) = 3(4)² + 2(4) − 5
     = 3(16) + 8 − 5
     = 48 + 8 − 5
     = 51

This is equivalent to evaluating the expression when x = 4.

Applications

Physics: Kinematic equation d = vt + ½at²

Example: Find distance when v = 10 m/s, t = 3 s, a = 2 m/s²

d = vt + ½at²
  = (10)(3) + ½(2)(3)²
  = 30 + ½(2)(9)
  = 30 + ½(18)
  = 30 + 9
  = 39 meters

Economics: Cost function C(x) = 5x + 100

Example: Find cost for x = 20 units

C(20) = 5(20) + 100
      = 100 + 100
      = $200

Summary

Key principles:

  • Order of operations applies universally to numerical and algebraic expressions
  • PEMDAS: Parentheses, Exponents, Multiplication/Division (L→R), Addition/Subtraction (L→R)
  • Exponent scope determined by parentheses: 2x²(2x)²
  • Distributive property: a(b + c) = ab + ac
  • Simplify algebraically before evaluating when appropriate
  • Combine only like terms

Evaluation process:

  1. Substitute values for variables (use parentheses)
  2. Apply PEMDAS systematically
  3. Simplify step by step
  4. Verify result when possible

Practice

Evaluate 2x² − 3x + 1 when x = 3.

Simplify: 5(x − 2) + 3

What is the value of (2x)² when x = 5?

Evaluate 3x² + 4x when x = 2.