TExcelTAD
Home › Algebra › Removing Parentheses

Removing Parentheses

Parentheses group terms together, and before you can combine like terms across them you usually have to remove them. The rule is the distributive property: multiply everything inside by whatever is outside, paying special attention to a minus sign in front. This lesson covers single brackets, a minus sign, nested brackets and two brackets multiplied together.

A number or term in front

Multiply every term inside by the factor outside:

3(x+4)=3x+12−2(5y−1)=−10y+2x(x−6)=x2−6x4a(2a+3b−1)=8a2+12ab−4a\begin{aligned} 3(x + 4) &= 3x + 12 \\ -2(5y - 1) &= -10y + 2 \\ x(x - 6) &= x^2 - 6x \\ 4a(2a + 3b - 1) &= 8a^2 + 12ab - 4a \end{aligned}

The most common mistake is to multiply only the first term: 3(x+4)3(x + 4) is not 3x+43x + 4.

A plus or minus sign in front

  • A plus sign in front: just drop the brackets. 7+(x−3)=7+x−3=x+47 + (x - 3) = 7 + x - 3 = x + 4.
  • A minus sign in front means multiplying by −1, so every sign inside flips:
10−(x−3)=10−x+3=13−x5y−(2y+7−y)=5y−2y−7+y=4y−7\begin{aligned} 10 - (x - 3) &= 10 - x + 3 = 13 - x \\ 5y - (2y + 7 - y) &= 5y - 2y - 7 + y = 4y - 7 \end{aligned}

Tip: Read a minus in front of a bracket as "−1 times". Then there is only one rule to remember, the distributive property, and the sign changes follow from it.

python · try it yourself
from sympy import symbols, expand

x, y = symbols("x y")
print(expand(10 - (x - 3)))
print(expand(5*y - (2*y + 7 - y)))
print(expand(-2*(5*y - 1)))
print(expand(3*(x + 4) - 2*(x - 5)))
13 - x
4*y - 7
2 - 10*y
x + 22

The last line combines both steps: 3x+12−2x+10=x+223x + 12 - 2x + 10 = x + 22. Note that −2 times −5 is +10.

Nested brackets

When brackets sit inside other brackets, remove them from the inside out, simplifying as you go:

2[x−3(x+1)]+4=2[x−3x−3]+4inner bracket first=2[−2x−3]+4combine like terms inside=−4x−6+4=−4x−2\begin{aligned} &2[x - 3(x + 1)] + 4 \\ &= 2[x - 3x - 3] + 4 && \text{inner bracket first} \\ &= 2[-2x - 3] + 4 && \text{combine like terms inside} \\ &= -4x - 6 + 4 \\ &= -4x - 2 \end{aligned}

Working inside out keeps each step small; brackets in code are evaluated the same way.

Two brackets multiplied

To multiply (a+b)(c+d)(a + b)(c + d), distribute each term of the first bracket over the whole second bracket. Every term meets every term, giving 2×2=42 \times 2 = 4 products:

(x+5)(x−2)=x⋅x+x⋅(−2)+5⋅x+5⋅(−2)=x2−2x+5x−10=x2+3x−10\begin{aligned} (x + 5)(x - 2) &= x \cdot x + x \cdot (-2) + 5 \cdot x + 5 \cdot (-2) \\ &= x^2 - 2x + 5x - 10 \\ &= x^2 + 3x - 10 \end{aligned}

A grid makes sure no product is forgotten, and it generalises to longer brackets:

python · try it yourself
first = [("x", 1), ("", 5)]      # x + 5  as (variable part, coefficient)
second = [("x", 1), ("", -2)]    # x - 2

for v1, c1 in first:
    row = []
    for v2, c2 in second:
        mono = {"xx": "x²"}.get(v1 + v2, v1 + v2)   # x·x is x²
        row.append(f"{c1 * c2:+d}{mono}")
    print("  ".join(row))
+1x²  -2x
+5x  -10

The four cells are x2x^2, −2x-2x, 5x5x and −10-10, which combine to x2+3x−10x^2 + 3x - 10. The full method for longer polynomials is in Multiplying Polynomials.

In software

Removing brackets is what an optimiser does when it rewrites total - (discount - fee) as total - discount + fee, and it is where hand-written refactors go wrong. A bug that looks like price - discount + tax where the spec said price - (discount + tax) is exactly the "forgot to flip the sign" slip. When you change brackets in code, test the old and new expressions on a few values, as the exercise below does.

Exercises

Exercise 1: Distribute

Remove the parentheses and simplify: 6(2x−3)−4(x−5)6(2x - 3) - 4(x - 5).

Answer

8x+28x + 2

Solution
12x−18−4x+20=8x+212x - 18 - 4x + 20 = 8x + 2

The −4 multiplies −5 to give +20.

Exercise 2: Minus in front

Simplify 9a−(4a−2b+3)+(b−1)9a - (4a - 2b + 3) + (b - 1).

Answer

5a+3b−45a + 3b - 4

Solution
9a−4a+2b−3+b−1=5a+3b−4\begin{aligned} &9a - 4a + 2b - 3 + b - 1 \\ &= 5a + 3b - 4 \end{aligned}

Exercise 3: Nested

Simplify 3[2(x−4)−(x+1)]3[2(x - 4) - (x + 1)].

Answer

3x−273x - 27

Solution
3[2x−8−x−1]=3[x−9]=3x−27\begin{aligned} &3[2x - 8 - x - 1] \\ &= 3[x - 9] \\ &= 3x - 27 \end{aligned}
python · try it yourself
from sympy import symbols, expand
x = symbols("x")
print(expand(3*(2*(x - 4) - (x + 1))))
3*x - 27

Exercise 4: Two brackets

Expand (2x−3)(x+4)(2x - 3)(x + 4).

Answer

2x2+5x−122x^2 + 5x - 12

Solution
2x⋅x+2x⋅4−3⋅x−3⋅4=2x2+8x−3x−12=2x2+5x−122x \cdot x + 2x \cdot 4 - 3 \cdot x - 3 \cdot 4 = 2x^2 + 8x - 3x - 12 = 2x^2 + 5x - 12

Exercise 5: Test a refactor

A colleague rewrote price - (discount + tax) as price - discount + tax. Write code that compares both for price = 100, discount = 15, tax = 8, and give the correct removal of the brackets.

Answer

77 versus 93; the correct version is price - discount - tax.

Solution

The minus sign in front of the bracket flips both signs inside: −(discount+tax)=−discount−tax-(\text{discount} + \text{tax}) = -\text{discount} - \text{tax}.

python · try it yourself
price, discount, tax = 100, 15, 8
print(price - (discount + tax), price - discount + tax, price - discount - tax)
77 93 77

Test yourself

Simplify 8−(x−5)8 - (x - 5).

  1. 3−x3 - x
  2. 13−x13 - x
  3. 3+x3 + x
  4. 13+x13 + x

Expand −3(2a−4)-3(2a - 4).

  1. −6a−12-6a - 12
  2. −6a+12-6a + 12
  3. 6a−126a - 12
  4. −6a−4-6a - 4

When brackets are nested, which do you remove first?

  1. The outermost
  2. The innermost
  3. Any order gives fewer steps
  4. The one with the minus sign