As $$x$$ approaches some number $$a$$, the limit of $$f(x)$$ is $$L$$.

$\lim_{x \to\ a} f(x) = L$

A limit is a rigorous mathematical way of saying almost. A limit represents the output value that a function “approaches” as the input of the function closes in on some value.

The value of $$f(x)$$ at the input value is irrelevant, sometimes it doesn’t even exist, sometimes even the limit itself doesn’t exist. What’s of interest with limits is to look at the behavior of the function around that input value. The limit $$L$$ must always be a unique real number.

As $$x$$ approaches $$a$$, the limit of $$f(x)$$ is $$L$$ if the limit from the left exists and the limit from the right exists and both limits are $$L$$. That is,

$\text{if} \lim_{x \to\ a^+} f(x) = \lim_{x \to\ a^-} f(x) = L, \text{then} \lim_{x \to\ a} f(x) = L$

Limits fail to exist when:

• the one-sided limits are not equal (the outputs we’re approaching are different)
• the function doesn’t approach a finite value (values get infinitesimally large or small)
• the function doesn’t approach a specific value (the function wildly oscillates as we get close to $$x$$)
• the $$x$$ value is approaching the endpoint of a closed interval (it’s not possible to approach $$x$$ from one side)

In Python, the sympy library has an implementation of limits for functions and sequences.

import matplotlib.pyplot as plt
import numpy as np
from sympy import *

x = symbols("x")
f = 2 * x + 3

limit(f, x, 4)
## 11
def f(x):
return 2 * x + 3

x_values = range(1, 10)
y_values = [f(x) for x in range(1, 10)]
color = ["red" if y == 11 else "blue" for y in y_values]

fig, ax = plt.subplots()
ax.scatter(x_values, y_values, c=color)
plt.show()