A rational function is a function \(f\) that can be described by

\[f(x) = \frac{P(x)}{Q(x)}\] where \(P(x)\) and \(Q(x)\) are polynomials, with \(Q(x)\) not the zero polynomial. Rational functions can generate graphs with asymptotes.

import matplotlib.pyplot as plt
import numpy as np

def rational(x):
  return x**2 - 4 / x - 1

y_values = [rational(x) for x in np.linspace(-5, 5)]

plt.scatter(np.linspace(-5, 5), y_values)
plt.axvline(0, linestyle="--", color="gray")

The line \(x = a\) is a vertical asymptote if any of the following limit statements is true:

  • \(\lim_{x \to a^-} f(x) = \infty\)
  • \(\lim_{x \to a^-} f(x) = -\infty\)
  • \(\lim_{x \to a^+} f(x) = \infty\)
  • \(\lim_{x \to a^+} f(x) = -\infty\)

If the limit of the vertical line is approaching infinity from any direction, then line is an asymptote. The graph of a rational function never crosses the asymptote.

The line \(y = b\) is a horizontal asymptote if either or both of the following limit statement is true:

  • \(\lim_{x \to -\infty} f(x) = b\)
  • \(\lim_{x \to \infty} f(x) = b\)

The graph of rational function may or may not cross a horizontal asymptote.

A linear asymptote that is neither vertical nor horizontal is called a slant asymptote, or an oblique asymptote.