Algebra
Rational Functions
Ratios of polynomials — vertical asymptotes at zeros of denominator, horizontal at infinity
A rational function is the ratio of two polynomials, f(x) = p(x)/q(x). Their characteristic features — vertical asymptotes at zeros of q, horizontal asymptotes determined by leading-coefficient ratios at infinity, and "holes" where p and q share factors — make them a rich playground for analysis. Foundational in control theory (transfer functions), partial fraction decomposition, complex analysis, and approximation theory (Padé approximants).
- Definitionf(x) = p(x)/q(x) — both polynomials, q(x) ≠ 0
- Vertical asymptoteAt x = a where q(a) = 0 and p(a) ≠ 0
- Horizontal asymptotey = 0 if deg p < deg q; y = leading ratio if deg p = deg q; none if deg p > deg q
- Removable holeAt x = a where p(a) = q(a) = 0 (common factor)
- Partial fractionsDecompose into sum of simpler rational functions
- Padé approximantBest rational approximation matching Taylor series to high order
Interactive visualization
Press play, or step through manually. The visualization is yours to drive — try it before reading on.
Watch the 60-second explainer
A condensed visual walkthrough — narrated, captioned, under a minute.
Definition
A rational function is the ratio of two polynomials:
f(x) = p(x) / q(x)
where p and q are polynomials, and q is not the zero polynomial. The function is defined wherever q(x) ≠ 0.
Examples:
- 1/x (simplest non-trivial rational function).
- (x² + 1)/(x − 2).
- (x³ − 3x + 2)/(x² + 1).
Asymptotes — vertical and horizontal
Vertical asymptotes
At x = a where q(a) = 0 and p(a) ≠ 0, the function has a vertical asymptote. f(x) → ±∞ as x → a (sign depending on direction and sign of p(a)).
For f(x) = 1/(x − 3), there's a vertical asymptote at x = 3.
Horizontal asymptotes
The behavior as x → ±∞ depends on the relative degrees of p and q:
| Comparison | Horizontal asymptote |
|---|---|
| deg p < deg q | y = 0 |
| deg p = deg q | y = a_p / a_q (leading coefficient ratio) |
| deg p = deg q + 1 | Oblique (slant) asymptote y = mx + b (perform polynomial division) |
| deg p > deg q + 1 | None — function grows without bound |
For (3x² + 5)/(2x² − 1), horizontal asymptote y = 3/2.
Holes — removable discontinuities
If p(x) and q(x) share a common factor (x − a), the function has a hole at x = a — undefined there, but cancellation gives a finite limit.
Example — f(x) = (x² − 1) / (x − 1) = (x − 1)(x + 1) / (x − 1) = x + 1 for x ≠ 1.
The graph looks like the line y = x + 1, but with a missing point at (1, 2). The discontinuity is "removable" — by defining f(1) = 2, the function becomes continuous.
Partial fractions decomposition
Any proper rational function (deg p < deg q) can be written as a sum of simpler rational functions. The simpler pieces are determined by the factorization of q.
For q(x) factored into distinct linear factors:
p(x) / [(x − r₁)(x − r₂)(x − r₃)] = A₁/(x − r₁) + A₂/(x − r₂) + A₃/(x − r₃)
For repeated factors:
p(x) / (x − r)² = A/(x − r) + B/(x − r)²
For irreducible quadratic factors:
p(x) / [(x − r)(x² + bx + c)] = A/(x − r) + (Bx + C)/(x² + bx + c)
Solve A, B, C, ... by matching coefficients or substituting values.
Integrating rational functions
Partial fractions reduces integration of rational functions to integrating simpler pieces, all of which have closed forms:
| Form | Integral |
|---|---|
| 1 / (x − a) | ln|x − a| + C |
| 1 / (x − a)² | −1 / (x − a) + C |
| 1 / (x² + a²) | (1/a) arctan(x/a) + C |
| x / (x² + a²) | (1/2) ln(x² + a²) + C |
Any rational function can be integrated using these pieces. This is one reason partial fractions is foundational.
Transfer functions in control theory
A linear time-invariant system has a transfer function:
H(s) = Y(s) / X(s) = B(s) / A(s)
where X is input and Y is output (in Laplace transform), and B and A are polynomials.
Key features:
- Poles — roots of A(s). Determine system stability — system stable iff all poles in left-half plane (negative real part).
- Zeros — roots of B(s). Don't affect stability but shape the response.
- DC gain — H(0). Steady-state output for a constant input.
Engineers analyze and design systems by manipulating the rational transfer function — adding poles/zeros via controllers, doing pole placement, etc.
JavaScript — rational function tools
// Evaluate a rational function p(x)/q(x), with polynomials as arrays
// pCoeffs = [a0, a1, a2, ...] for a0 + a1*x + a2*x² + ...
function evalPoly(coeffs, x) {
return coeffs.reduce((acc, c, i) => acc + c * Math.pow(x, i), 0);
}
function rational(pCoeffs, qCoeffs, x) {
return evalPoly(pCoeffs, x) / evalPoly(qCoeffs, x);
}
// Example: (x² + 1) / (x - 2) at x = 5
console.log(rational([1, 0, 1], [-2, 1], 5)); // 26/3 ≈ 8.667
// Find vertical asymptotes (zeros of q where p is nonzero)
function verticalAsymptotes(pCoeffs, qCoeffs, candidates) {
return candidates.filter(x => {
const qVal = evalPoly(qCoeffs, x);
const pVal = evalPoly(pCoeffs, x);
return Math.abs(qVal) < 1e-9 && Math.abs(pVal) > 1e-9;
});
}
console.log(verticalAsymptotes([1, 0, 1], [-2, 1], [-1, 0, 1, 2])); // [2]
// Horizontal asymptote based on degrees
function horizontalAsymptote(pCoeffs, qCoeffs) {
// Strip trailing zeros to get true degrees
const pDeg = pCoeffs.length - 1;
const qDeg = qCoeffs.length - 1;
if (pDeg < qDeg) return 0;
if (pDeg === qDeg) return pCoeffs[pDeg] / qCoeffs[qDeg];
return null; // no horizontal asymptote
}
console.log(horizontalAsymptote([1, 0, 3], [1, 0, 2])); // 3/2 = 1.5
console.log(horizontalAsymptote([1, 0], [1, 0, 1])); // 0
console.log(horizontalAsymptote([1, 0, 0, 1], [1, 0, 1])); // null
// Partial fractions for (px + q) / ((x - a)(x - b))
// = A/(x - a) + B/(x - b)
function partialFractions2(p, q, a, b) {
// A = (p*a + q) / (a - b)
// B = (p*b + q) / (b - a)
return {
A: (p * a + q) / (a - b),
B: (p * b + q) / (b - a)
};
}
// (3x + 5) / ((x - 1)(x + 2)) = ?/(x - 1) + ?/(x + 2)
console.log(partialFractions2(3, 5, 1, -2));
// A = (3 + 5) / (1 - (-2)) = 8/3
// B = (-6 + 5) / (-3) = 1/3
Where rational functions show up
- Calculus. Integration via partial fractions. Foundation for solving ODEs with rational coefficients (Frobenius method, etc.).
- Control theory. Transfer functions are rational. PID controllers, lead-lag compensators, all manipulate rational H(s).
- Signal processing. z-transform of digital filters gives rational H(z). IIR (infinite impulse response) filters are pole-zero designs.
- Numerical analysis. Padé approximants — best rational approximation matching Taylor series. Converges faster than polynomial truncation, handles poles.
- Complex analysis. Meromorphic functions have rational local structure. Riemann sphere — rational functions are exactly meromorphic functions.
- Algebra and number theory. Rational functions over a field form a field (the field of fractions). Used in algebraic geometry, function fields.
- Physics — perturbation theory. Energy levels, scattering amplitudes often expand as rational functions of coupling constants.
Common mistakes
- Confusing holes with vertical asymptotes. Hole — both p(a) = 0 and q(a) = 0; cancellation yields finite limit. Vertical asymptote — q(a) = 0 but p(a) ≠ 0; function blows up. Always check both.
- Forgetting to check for common factors first. Always factor and simplify before declaring a "vertical asymptote." (x − 1)/(x − 1) is the constant 1 with a hole at x = 1, not a vertical asymptote.
- Wrong horizontal asymptote when degrees match. deg p = deg q gives y = ratio of LEADING coefficients (highest-degree). Not the constant terms or random others.
- Missing oblique asymptotes. If deg p = deg q + 1, the function approaches a line (not a constant) at infinity. Polynomial-divide to find it.
- Partial fractions with wrong template. For repeated factors (x − a)^k — need terms A/(x−a), B/(x−a)², ..., up to degree k. For irreducible quadratics — need (Bx+C)/(quadratic). Wrong template gives unsolvable system.
- Treating rational functions as just "fractions." They're algebraically richer — they form a field, support partial fractions, have meromorphic structure in ℂ. The "fraction" view misses the geometry.
Frequently asked questions
What's the difference between a vertical and horizontal asymptote?
Vertical asymptote at x = a — function blows up to ±∞ as x → a. Occurs at zeros of denominator (where p(a) ≠ 0). Horizontal asymptote at y = L — function approaches L as x → ±∞. Determined by leading-coefficient ratios. Vertical asymptote is "near a specific x"; horizontal is "as x grows."
When does a rational function have a "hole"?
When p(x) and q(x) share a common factor (x − a). Then both numerator and denominator are zero at x = a, and the function is undefined there but the limit exists (after cancellation). This is a "removable discontinuity" — graph looks continuous except for a single missing point. Example — (x² − 1)/(x − 1) = x + 1 for x ≠ 1, but undefined at x = 1.
How do you find horizontal asymptotes?
Compare degrees of p and q. (1) deg p < deg q — horizontal asymptote y = 0 (function dies at infinity). (2) deg p = deg q — asymptote y = a_p/a_q (ratio of leading coefficients). (3) deg p > deg q — no horizontal asymptote (function grows). For deg p = deg q + 1, you get a "slant" or "oblique" asymptote (linear).
What is partial fraction decomposition?
Express a rational function as a sum of simpler ones. (3x + 5)/((x − 1)(x + 2)) = A/(x − 1) + B/(x + 2). Solve A and B by matching coefficients or plugging x values. Used to integrate rational functions (each simple piece integrates easily), invert Laplace transforms, simplify control-theory transfer functions. Key technique in calculus.
How are rational functions used in control systems?
Transfer functions in control theory are rational — H(s) = B(s)/A(s), where s is a complex frequency. Poles (roots of A) determine stability — left-half plane = stable. Zeros (roots of B) determine response shape. Bode plots, root locus, and Nyquist analyses all manipulate rational transfer functions. Signal processing's z-transform analogously uses rational H(z).
What's a Padé approximant?
The Padé approximant of order [m/n] for a function f(x) is a rational function P_m(x)/Q_n(x) (degrees m and n) whose Taylor series matches f's to order m + n. Better than truncating Taylor series — converges faster, can extrapolate beyond the radius of convergence, captures poles. Used in numerical analysis, perturbation theory in physics.
How are rational functions related to complex analysis?
Meromorphic functions on ℂ — functions analytic except for isolated poles — have local rational structure. Near each pole, behavior matches a rational function. Globally, rational functions on the Riemann sphere are precisely the meromorphic functions there. The poles and zeros (with multiplicity) determine the function up to scalar.