Skip to content
ihateDesmos

How to graph a rational function

6 min read · Updated 6 November 2026

A rational function is one polynomial divided by another. To graph it, find what it can’t do first, the holes and asymptotes, then plot intercepts and a few points in each region it is split into.

The method

  1. Factor the top and bottom.
  2. Find holes: a factor that cancels leaves a hole at that x.
  3. Find vertical asymptotes: where the reduced bottom is zero.
  4. Find the horizontal or slant asymptote by comparing degrees.
  5. Find intercepts: the top equals zero for x-intercepts, and x = 0 for the y-intercept.
  6. Test a point in each region between vertical asymptotes, to see if the graph is above or below the axis.
  7. Sketch a smooth curve in each region, following the asymptotes.

A worked example

Graph f(x) = (x² − x − 2)/(x² − 1).

  1. Factor: (x − 2)(x + 1) / ((x − 1)(x + 1)).
  2. Hole: x + 1 cancels. The reduced form is (x − 2)/(x − 1), which at x = −1 gives 3/2, so there is a hole at (−1, 3/2).
  3. Vertical asymptote: x = 1.
  4. Horizontal asymptote: the degrees match, and the leading coefficients are both 1, so y = 1.
  5. Intercepts: the x-intercept is x = 2, and the y-intercept is f(0) = 2.
  6. Test points: f(3) = 1/2, and f(1.5) = −1, so right of the asymptote the graph comes up from below. f(0) = 2 and f(−3) = 5/4 show it is above y = 1 on the left.
−4−224650
Open in calculator
The result, with asymptotes x = 1 and y = 1. There is also a hole at (−1, 3/2), too small to see at this scale.

When there is a slant asymptote

If the top’s degree is one more than the bottom’s, divide to get a slant asymptote. y = (x² + 1)/x equals x + 1/x, so the graph follows the line y = x for large x. The asymptote calculator finds all of these from your function, and the asymptotes guide explains the rules.

−6−4−2246−550
Open in calculator
y=x2+1x
approaches the slant asymptote
y=x
.

What happens near a vertical asymptote

The sign of the function tells you whether it heads to +∞ or −∞. A factor with an odd power, like (x − 1), flips the sign across the asymptote, so the curve goes up on one side and down on the other, as 1/x does. A factor with an even power, like (x − 1)², keeps the same sign on both sides, as 1/x² does.

Frequently asked questions

What is a rational function?
A fraction with a polynomial on the top and bottom, such as (x + 1)/(x² − 4).
How do you find the holes in a rational function?
Factor the top and bottom. Any factor that cancels leaves a hole at the x-value that makes it zero.
How do you find the domain of a rational function?
All real numbers, except where the original denominator is zero. That includes both holes and vertical asymptotes.
Can a rational function cross its horizontal asymptote?
Yes. Horizontal asymptotes describe only what happens far to the left and right. It can never cross a vertical asymptote.

Keep going

Try it in the calculator

Every figure on this page opens in ihateDesmos, where you can drag sliders and watch the graph respond.

Open the calculator