TExcelTAD
Home › Algebra › Adding and Subtracting Algebraic Fractions

Adding and Subtracting Algebraic Fractions

To add or subtract fractions you need a common denominator, and algebraic fractions are no different. The least common denominator (LCD) comes from factoring each denominator, just as the least common multiple of numbers comes from their prime factors. This lesson builds the LCD, combines the fractions, and handles the sign trap in subtraction.

Same denominator

Add or subtract the numerators and keep the denominator:

3x+1x−2−x+5x−2=3x+1−(x+5)x−2=2x−4x−2=2(x−2)x−2=2,x≠2\begin{aligned} \frac{3x + 1}{x - 2} - \frac{x + 5}{x - 2} &= \frac{3x + 1 - (x + 5)}{x - 2} \\ &= \frac{2x - 4}{x - 2} \\ &= \frac{2(x - 2)}{x - 2} = 2, \qquad x \ne 2 \end{aligned}

Note: When subtracting, put the whole second numerator in parentheses. 3x+1−x+53x + 1 - x + 5 (no parentheses) would give 2x+62x + 6, which is wrong. This is the same sign trap as in subtracting polynomials.

Always try to reduce the result at the end, as in the last step above.

Different denominators: the LCD

  1. Factor each denominator.
  2. The LCD takes every factor that appears, each to the highest power it appears with.
  3. Build up each fraction: multiply its top and bottom by the factors of the LCD it is missing.
  4. Add or subtract the numerators, then simplify.

With numbers, 112+118\frac{1}{12} + \frac{1}{18}: 12=22⋅312 = 2^2 \cdot 3, 18=2⋅3218 = 2 \cdot 3^2, LCD=22⋅32=36\text{LCD} = 2^2 \cdot 3^2 = 36 (Adding Fractions). With polynomials:

5x2−4+2x2+2x1.x2−4=(x−2)(x+2);x2+2x=x(x+2)2.LCD=x(x−2)(x+2)3.5(x−2)(x+2)⋅xx=5xLCD3.2x(x+2)⋅x−2x−2=2(x−2)LCD4.5x+2x−4LCD=7x−4x(x−2)(x+2)\begin{aligned} &\frac{5}{x^2 - 4} + \frac{2}{x^2 + 2x} \\[1ex] &\text{1.}\quad x^2 - 4 = (x - 2)(x + 2); \quad x^2 + 2x = x(x + 2) \\ &\text{2.}\quad \text{LCD} = x(x - 2)(x + 2) \\ &\text{3.}\quad \frac{5}{(x - 2)(x + 2)} \cdot \frac{x}{x} = \frac{5x}{\text{LCD}} \\ &\phantom{\text{3.}}\quad \frac{2}{x(x + 2)} \cdot \frac{x - 2}{x - 2} = \frac{2(x - 2)}{\text{LCD}} \\ &\text{4.}\quad \frac{5x + 2x - 4}{\text{LCD}} = \frac{7x - 4}{x(x - 2)(x + 2)} \end{aligned}

7x−47x - 4 has no factor in common with the denominator, so this is the final answer (excluded: x=0,2,−2x = 0, 2, -2).

Tip: Leave the LCD in factored form while you work. Multiplying it out only makes the final "can anything cancel?" check harder.

A subtraction example

xx−3−6x2−9LCD=(x−3)(x+3)=x(x+3)LCD−6LCD=x2+3x−6(x−3)(x+3)\begin{aligned} &\frac{x}{x - 3} - \frac{6}{x^2 - 9} \\[1ex] &\text{LCD} = (x - 3)(x + 3) \\ &= \frac{x(x + 3)}{\text{LCD}} - \frac{6}{\text{LCD}} \\ &= \frac{x^2 + 3x - 6}{(x - 3)(x + 3)} \end{aligned}

x2+3x−6x^2 + 3x - 6 does not factor over the integers, so nothing cancels. Compare with xx−3−3x−3=x−3x−3=1\frac{x}{x - 3} - \frac{3}{x - 3} = \frac{x - 3}{x - 3} = 1: sometimes the final reduction removes everything.

In Python

SymPy's together combines fractions over a common denominator, factor shows the factored form, and apart goes the other way (partial fractions, used heavily in calculus: Partial Fractions):

python · try it yourself
import sympy as sp

x = sp.symbols("x")
s = 5/(x**2 - 4) + 2/(x**2 + 2*x)
print(sp.factor(sp.together(s)))

d = x/(x - 3) - 6/(x**2 - 9)
print(sp.factor(sp.together(d)))

print(sp.apart((7*x - 4) / (x*(x - 2)*(x + 2))))
(7*x - 4)/(x*(x - 2)*(x + 2))
(x**2 + 3*x - 6)/((x - 3)*(x + 3))
-9/(4*(x + 2)) + 5/(4*(x - 2)) + 1/x

apart splits the combined fraction back into one simple fraction per factor of the denominator (in SymPy's own order); adding those pieces gives the combined fraction again. A numeric check with exact fractions confirms the hand result:

python · try it yourself
from fractions import Fraction as F

for x in [1, 3, -5, 7]:
    left = F(5, x**2 - 4) + F(2, x**2 + 2*x)
    right = F(7*x - 4, x * (x - 2) * (x + 2))
    print(x, left, right, left == right)
1 -1 -1 True
3 17/15 17/15 True
-5 13/35 13/35 True
7 1/7 1/7 True

In software

  • Parallel resistors and combined rates. Two resistors in parallel have 1R=1R1+1R2\frac{1}{R} = \frac{1}{R_1} + \frac{1}{R_2}, so R=R1R2R1+R2R = \frac{R_1 R_2}{R_1 + R_2}: adding two algebraic fractions. The same formula combines two workers' rates, two pipes filling a tank, or two servers sharing requests (Rational Equations).
  • Lens and camera formulas. The thin-lens equation 1f=1d0+1di\frac{1}{f} = \frac{1}{d_0} + \frac{1}{d_i} is used in rendering depth of field; solving for did_i means combining fractions.
  • Average speed. Driving a distance dd at speed uu and back at vv takes du+dv\frac{d}{u} + \frac{d}{v}, so the average speed is 2uvu+v\frac{2uv}{u + v} (the harmonic mean), not u+v2\frac{u + v}{2}. The same harmonic mean appears in ML as the F1 score.
python · try it yourself
def parallel(r1, r2):
    return r1 * r2 / (r1 + r2)

def harmonic_mean(u, v):
    return 2 * u * v / (u + v)

print("100 Ω ‖ 300 Ω =", parallel(100, 300), "Ω")
print("60 km/h there, 40 km/h back: average", harmonic_mean(60, 40), "km/h")
print("F1 with precision 0.9, recall 0.6:", round(harmonic_mean(0.9, 0.6), 4))
100 Ω ‖ 300 Ω = 75.0 Ω
60 km/h there, 40 km/h back: average 48.0 km/h
F1 with precision 0.9, recall 0.6: 0.72

Exercises

Exercise 1: Same denominator

Simplify x2+1x+1−2x+1\frac{x^2 + 1}{x + 1} - \frac{2}{x + 1}.

Answer

x−1x - 1, with x≠−1x \ne -1.

Solution
x2+1−2x+1=x2−1x+1=(x−1)(x+1)x+1=x−1\frac{x^2 + 1 - 2}{x + 1} = \frac{x^2 - 1}{x + 1} = \frac{(x - 1)(x + 1)}{x + 1} = x - 1

Exercise 2: Monomial denominators

Simplify 34x+56x2\frac{3}{4x} + \frac{5}{6x^2}.

Answer

9x+1012x2\frac{9x + 10}{12x^2}

Solution
LCD=12x234x=9x12x2;56x2=1012x2sum=9x+1012x2\begin{aligned} &\text{LCD} = 12x^2 \\ &\frac{3}{4x} = \frac{9x}{12x^2}; \quad \frac{5}{6x^2} = \frac{10}{12x^2} \\ &\text{sum} = \frac{9x + 10}{12x^2} \end{aligned}

Exercise 3: Binomial denominators

Simplify 2x−1−3x+2\frac{2}{x - 1} - \frac{3}{x + 2}.

Answer

7−x(x−1)(x+2)\frac{7 - x}{(x - 1)(x + 2)}

Solution
LCD=(x−1)(x+2)2(x+2)−3(x−1)=2x+4−3x+3=−x+7\begin{aligned} &\text{LCD} = (x - 1)(x + 2) \\ &2(x + 2) - 3(x - 1) = 2x + 4 - 3x + 3 = -x + 7 \end{aligned}

Exercise 4: Factor first

Simplify xx2−x−2+1x2−4\frac{x}{x^2 - x - 2} + \frac{1}{x^2 - 4}.

Answer

x2+3x+1(x−2)(x+1)(x+2)\frac{x^2 + 3x + 1}{(x - 2)(x + 1)(x + 2)}

Solution
x2−x−2=(x−2)(x+1);x2−4=(x−2)(x+2)LCD=(x−2)(x+1)(x+2)x(x+2)+1(x+1)=x2+2x+x+1=x2+3x+1\begin{aligned} &x^2 - x - 2 = (x - 2)(x + 1); \quad x^2 - 4 = (x - 2)(x + 2) \\ &\text{LCD} = (x - 2)(x + 1)(x + 2) \\ &x(x + 2) + 1(x + 1) = x^2 + 2x + x + 1 = x^2 + 3x + 1 \end{aligned}
python · try it yourself
import sympy as sp

x = sp.symbols("x")
print(sp.factor(sp.together(x/(x**2 - x - 2) + 1/(x**2 - 4))))
(x**2 + 3*x + 1)/((x - 2)*(x + 1)*(x + 2))

Exercise 5: Three resistors

Write a function for three resistors in parallel (1R=1R1+1R2+1R3\frac{1}{R} = \frac{1}{R_1} + \frac{1}{R_2} + \frac{1}{R_3}) using Fraction, and compute RR for 6 Ω6\ \Omega, 3 Ω3\ \Omega and 2 Ω2\ \Omega.

Answer

1 Ω1\ \Omega

Solution

16+13+12=16+26+36=1\frac{1}{6} + \frac{1}{3} + \frac{1}{2} = \frac{1}{6} + \frac{2}{6} + \frac{3}{6} = 1, so R=1R = 1.

python · try it yourself
from fractions import Fraction as F

def parallel(*rs):
    return 1 / sum(F(1, r) for r in rs)

print(parallel(6, 3, 2))
print(parallel(100, 300))
1
75

Test yourself

What is the LCD of 1x2−9\frac{1}{x^2 - 9} and 1(x+3)2\frac{1}{(x + 3)^2}?

  1. (x2−9)(x+3)2(x^2 - 9)(x + 3)^2
  2. (x−3)(x+3)2(x - 3)(x + 3)^2
  3. (x−3)(x+3)(x - 3)(x + 3)
  4. x+3x + 3

Simplify 1x+1y\frac{1}{x} + \frac{1}{y}.

  1. 2x+y\frac{2}{x + y}
  2. 1x+y\frac{1}{x + y}
  3. x+yxy\frac{x + y}{xy}
  4. 2xy\frac{2}{xy}

A car goes 30 km/h one way and 60 km/h back over the same road. What is its average speed?

  1. 45 km/h
  2. 40 km/h
  3. 50 km/h
  4. 35 km/h