Sub topic 2
Simplifying complex fractions
Prerequisites
This chapter assumes you can factor polynomials (common factors, difference of squares, trinomials), add fractions, solve linear and quadratic equations, and use function notation on a coordinate plane.
Simplifying complex fractions
A complex fraction is a fraction whose numerator, denominator, or both contain fractions. Multiply the top and bottom by the least common denominator (LCD) of all the inner fractions. This clears every inner fraction at once.
For (1/x + 1)/(1 - 1/x^2), the inner LCD is x^2. Multiplying top and bottom by x^2 gives (x^2 + x)/(x^2 - 1), which factors to x(x + 1)/((x - 1)(x + 1)). Cancelling x + 1 leaves x/(x - 1).
from sympy import symbols, cancel
x = symbols('x')
expr = (1/x + 1) / (1 - 1/x**2)
print(cancel(expr)) # x/(x - 1)Solving rational equations and checking for extraneous solutions
Multiply both sides of a rational equation by the LCD. The result is a polynomial equation, but its solutions may include values that make an original denominator zero. These are extraneous solutions, and you must reject them.
Solve x^2/(x - 2) = 4/(x - 2). Multiplying by x - 2 gives x^2 = 4, so x = 2 or x = -2. Substituting x = 2 makes the denominator zero, so x = 2 is extraneous. The only solution is x = -2.
from sympy import symbols, Eq, solve
x = symbols('x')
candidates = solve(Eq(x**2, 4), x) # [-2, 2]
valid = [c for c in candidates if (x - 2).subs(x, c) != 0]
print(valid) # [-2]Rational functions and their domain
A rational function has the form f(x) = P(x)/Q(x), where P and Q are polynomials and Q is not the zero polynomial. Its domain is every real number except the zeros of Q. For f(x) = (x + 1)/(x^2 - 4), the denominator factors as (x - 2)(x + 2), so the domain excludes 2 and -2.
Finding zeros and intercepts
The x-intercepts are the zeros of the numerator, provided those values lie in the domain. The y-intercept is f(0), if 0 is in the domain.
Let f(x) = (x - 3)/((x + 1)(x - 2)). The numerator is zero at x = 3, which is in the domain, so the x-intercept is (3, 0). Since 0 is in the domain, f(0) = (-3)/((1)(-2)) = 3/2, so the y-intercept is (0, 3/2).
from sympy import symbols, numer, denom, solve
x = symbols('x')
f = (x - 3) / ((x + 1) * (x - 2))
print(solve(numer(f), x)) # [3]
print(f.subs(x, 0)) # 3/2Vertical asymptotes
A vertical asymptote is a line x = a that the graph approaches but never reaches. It occurs at a zero of the denominator where the numerator is not also zero. If the numerator and denominator share a zero, that factor cancels and produces a hole instead.
For f above, the denominator is zero at x = -1 and x = 2. The numerator equals -4 at x = -1 and -1 at x = 2, so both lines are vertical asymptotes.
Exercise
Find the domain and the y-intercept of f(x) = (x + 4)/(x^2 - 9).
Show answer
The denominator is zero at x = 3 and x = -3, so the domain excludes both values. Since f(0) = 4/(-9) = -4/9, the y-intercept is (0, -4/9).