A function limit, roughly speaking, describes the behavior of a function around a specific value. Limits play a role in the definition of the derivative and function continuity and are also used in the convergent sequences.
Before getting to the precise definition of a limit, we can investigate limit of a function by plotting it and examining the area around the limit value.
For example, consider the limit (taken from James Stewart's Calculus Early Transcendentals, Exercise 11, page 107)
We can plot this limit using the matplotlib.pylot
module. The numpy library is also imported for some convenience functions.
import numpy as np
import matplotlib.pyplot as plt
def f(x):
return (x ** 2 + x - 6) / (x - 2)
Get a set of values for $x$ using the linspace
function.
xvals = np.linspace(0, 2, 100, False)
Then plot the function using matplotlib
.
plt.plot(xvals, f(xvals))
plt.show()
The plot shows that as $x$ gets closer to $2$, the function gets close to $5$. One way to verify this is to look closer at the values of the function around the limit.
xvals2 = np.linspace(1.90, 2, 100, False)
f(xvals2)
We can also use SymPy's limit
function to calculate the limit.
from sympy import symbols, limit, sin, cos, init_printing
x = symbols('x')
init_printing()
limit((x ** 2 + x - 6) / (x - 2), x, 2)
Using this information, we can construct a more precise definition of a limit.
Definition of a Limit¶
Limits are typically denoted as:
Or, alternatively:
In plain language, we can state the limit as, "the limit of the a function $f(x)$ as $x$ approaches $a$ is equal to $L$. For example, if we were considering the limit:
We can state it as, "the limit of the function $f(x)$ as $x$ approaches $2$ is equal to $5$.
One-Sided Limits¶
One-sided limits are used to express a limit as it approaches $a$ from a particular direction. The notation is similar to the limit seen above but with a slight change to indicate which direction $x$ is headed.
The notation $x \to a^+$ states we are only interested in values of $x$ that are greater than $a$. Similarly, the notation $x \to a^-$ denotes our desire to investigate values of $x$ less than $a$. These one-sided limits are also referred to as the "right-hand limit" and "left-hand limit", respectively.
For example, consider the function:
The $-3^+$ notation tells us we are only interested values greater than -3; thus the limit is a right-hand limit.
The function is not defined for $x = 3$; therefore we are dealing with an infinite limit. We can see the behavior of the function as $x$ approaches $-3$ by plotting.
def f2(x):
return (x + 2) / (x + 3)
xvals2 = np.linspace(-2, -3, 100, False)
xvals3 = np.linspace(-2.5, -3, 3000, False)
plt.figure(1, figsize=(14,3))
plt.subplot(121)
plt.plot(xvals2, f2(xvals2))
plt.subplot(122)
plt.plot(xvals3, f2(xvals3))
plt.xlim((-3.005, -2.99))
plt.show()
Both graphs approach $x = -3$ from the right and we can see the function quickly drop off as it gets closer to its limit. The graph on the right is a magnified representation of the graph on the left to better illustrate the infinite limit. Therefore, the limit of the function is $-\infty$, which we can confirm with SymPy.
limit((x + 2) / (x + 3), x, -3)