Sub topic 8
Rational functions and their domain
A rational function is a function whose formula is a ratio of two polynomials. This chapter assumes you can factor polynomials, solve linear and quadratic equations, use function notation, and simplify rational expressions by cancelling common factors. It covers how to read the domain from the formula, why the domain belongs to the original formula and not the simplified one, and the mistakes that follow from mixing the two up.
Definition
A function f is rational if it can be written as
f(x) = p(x) / q(x)
where p and q are polynomials and q is not the zero polynomial. These are all rational functions:
- f(x) = (x + 1)/(x² − 4)
- g(x) = 1/x
- h(x) = x² + 3x, because the denominator can be 1
- k(x) = 5, a constant
Every polynomial is a rational function. The reverse is false. A function such as √x/(x + 1) is not rational, because its numerator is not a polynomial.
The domain
The domain of a function is the set of inputs for which the formula gives a real output. Division by zero is the only way a rational function can fail to give one. So:
The domain of p(x)/q(x) is all real numbers except the real zeros of q(x).
Follow these steps:
- Write the function in the form given, without simplifying first.
- Set the denominator equal to zero.
- Solve. Only real solutions matter.
- Exclude those values from the domain.
Worked example
Find the domain of f(x) = (x + 1)/(x² − 4).
Set x² − 4 = 0. Then (x − 2)(x + 2) = 0, so x = 2 or x = −2. The domain is all real numbers except −2 and 2. In interval notation:
(−∞, −2) ∪ (−2, 2) ∪ (2, ∞)
The numerator plays no part. Even though x = −1 makes the numerator zero, it is a perfectly good input. It gives f(−1) = 0.
You can check the exclusions with SymPy:
from sympy import symbols, fraction, solveset, S
x = symbols('x')
f = (x + 1) / (x**2 - 4)
num, den = fraction(f)
excluded = solveset(den, x, domain=S.Reals)
print(excluded) # {-2, 2}A denominator with no real zeros
Take g(x) = x/(x² + 1). The equation x² + 1 = 0 has no real solutions, since x² is never negative. Nothing is excluded, and the domain is all real numbers.
from sympy import symbols, fraction, solveset, S
x = symbols('x')
g = x / (x**2 + 1)
num, den = fraction(g)
print(solveset(den, x, domain=S.Reals)) # EmptySetThe domain depends on the number system. If complex inputs were allowed, x = i and x = −i would be excluded. In this tutorial the domain means real inputs.
Common mistakes and edge cases
Finding the domain after simplifying
This is the most frequent error. Consider
f(x) = (x² − 9)/(x² − 5x + 6) = (x − 3)(x + 3) / ((x − 2)(x − 3))
The denominator is zero at x = 2 and x = 3, so the domain of f excludes both. Cancelling the common factor gives
g(x) = (x + 3)/(x − 2)
which excludes only x = 2. The two formulas agree everywhere except x = 3. There f is undefined and g(3) = 6.
from sympy import symbols, cancel
x = symbols('x')
f = (x**2 - 9) / (x**2 - 5*x + 6)
g = cancel(f)
print(g) # (x + 3)/(x - 2)
print(f.subs(x, 3)) # nan (0/0, undefined)
print(g.subs(x, 3)) # 6Two functions are equal only if they have the same domain and the same output at every input in it. So f and g are different functions, even though their formulas differ by one cancelled factor. The domain must be read from the original formula. The next chapters show that the missing point at x = 3 is a hole in the graph.
A zero in the numerator does not exclude a value
Excluded values come only from the denominator. If both the numerator and the denominator are zero at an input, that input is still excluded.
Higher-degree and non-factorable denominators
If the denominator is a quadratic that does not factor over the integers, use the quadratic formula or the discriminant. For x² − 2x − 1 = 0, the solutions are x = 1 ± √2, so both irrational values are excluded. If the denominator is a cubic or higher, look for rational roots and factor by grouping. When no exact method works, a numerical solver can approximate the real zeros.
Restrictions from other parts of the formula
If the formula includes other operations, such as a square root or a nested fraction, each one adds its own restrictions. For a nested fraction like 1/(1 + 1/x), x = 0 is excluded from the inner fraction, and x = −1 is excluded because the outer denominator then becomes 0. Check every denominator, including the ones inside other fractions.
Writing domains clearly
Three equivalent notations are common:
| Notation | Example for f(x) = (x + 1)/(x² − 4) |
|---|---|
| Set-builder | {x in R : x ≠ −2 and x ≠ 2} |
| Interval | (−∞, −2) ∪ (−2, 2) ∪ (2, ∞) |
| Words | All real numbers except −2 and 2 |
Use "and" between the conditions in set-builder form. Writing "x ≠ −2 or x ≠ 2" is true for every number, so it excludes nothing. The intervals must be joined with the union symbol, because the domain consists of separate pieces.
Why the domain matters
The excluded values mark the places where the graph is broken. At each one, the graph has either a vertical asymptote or a hole. The rest of this tutorial depends on telling these two cases apart, and the first step is always to list the excluded values from the original formula. The next chapters then use the numerator to find zeros and intercepts, and the factors in common between numerator and denominator to find holes.
Exercise
Find the domain of f(x) = (x² − 1)/(x² − x − 6). Then simplify f, and say what input the simplified form wrongly appears to allow, if any.
Show answer
Factor the denominator: x² − x − 6 = (x − 3)(x + 2). It is zero at x = 3 and x = −2, so the domain is all real numbers except −2 and 3. The numerator factors as (x − 1)(x + 1), which shares no factor with the denominator, so f cannot be simplified. The simplified form allows no extra inputs.
Exercise
Let f(x) = (x² − 4)/(x² − 3x + 2). Find its domain, simplify it to g(x), and state the input where f and g differ.
Show answer
Factor: f(x) = (x − 2)(x + 2)/((x − 1)(x − 2)). The denominator is zero at x = 1 and x = 2, so the domain is all real numbers except 1 and 2. Cancelling x − 2 gives g(x) = (x + 2)/(x − 1), which excludes only x = 1. The functions differ at x = 2: f(2) is undefined, but g(2) = 4.
Exercise
Why is the domain of h(x) = (x + 5)/(x² + 4) all real numbers?
Show answer
The denominator x² + 4 is at least 4 for every real x, so it is never zero. No real input is excluded.