1 Introduction: What Happens as You Approach a Point?
Suppose an autonomous car is speeding toward a speed-trap sensor. Even without knowing the exact millisecond the vehicle crosses the threshold line, we can track and analyze its trajectory as it gets closer and closer to that destination with arbitrary precision.
In mathematics, this fundamental concept is called a Limit. A limit investigates what value a function's output $f(x)$ approaches as its input $x$ approaches a target value $a$.
Why Limits and Continuity Form the Core of AI
In real-world mathematical modeling, functions often encounter points of division by zero ($\frac{0}{0}$ indeterminate forms). Limits enable us to bypass undefined arithmetic points by studying the "local neighborhood behavior". Meanwhile, Continuity guarantees that a function has no sudden tears, jumps, or missing values—a requirement for smooth loss landscapes in gradient descent and backpropagation.
2 What is a Limit?
Let $f(x)$ be a function. If the values of $f(x)$ can be made arbitrarily close to a real number $L$ by taking $x$ sufficiently close to $a$ (on either side of $a$, but where $x \ne a$), we say that the limit of $f(x)$ as $x$ approaches $a$ is $L$.
Pronounced: "The limit of $f(x)$ as $x$ approaches $a$ equals $L$"
Anatomy of the Limit Notation:
- $x$: The independent variable (Input).
- $a$: The specific constant value that the input approaches ($x \to a$).
- $f(x)$: The function being investigated (Output).
- $L$: The target value the output converges toward (Limiting Value).
- Critical Principle: $x$ never needs to actually equal $a$! The limit is strictly concerned with how $f(x)$ behaves in the immediate vicinity of $a$, not at $x = a$ itself.
Numerical Inspection: $f(x) = x + 2$ as $x \to 3$
Observe how $f(x)$ behaves as $x$ approaches $3$ from values smaller than $3$ (left) and larger than $3$ (right):
| Input $x$ (Approaching from Left) | Output $f(x) = x + 2$ | Input $x$ (Approaching from Right) | Output $f(x) = x + 2$ |
|---|---|---|---|
| 2.9 | 4.9 | 3.1 | 5.1 |
| 2.99 | 4.99 | 3.01 | 5.01 |
| 2.999 | 4.999 | 3.001 | 5.001 |
From both directions, as $x$ gets closer to $3$, $f(x)$ unmistakably converges toward $5$:
3 Difference Between Limit and Function Value
A universal trap in introductory calculus is assuming that finding a limit simply means evaluating the function at $x = a$. The function's actual value $f(a)$ and its limit $\lim_{x \to a} f(x)$ are distinct mathematical concepts!
Consider the classic rational function:
Direct substitution of $x = 2$ fails catastrophically:
At $x = 2$, $f(2)$ does not exist in standard arithmetic. Does that mean we know nothing about the function's trajectory near $x = 2$?
No! Under the definition of a limit, $x \ne 2$. Because $x - 2 \ne 0$, we are mathematically justified in factoring the numerator and canceling the common factor:
The exact output produced when inputting $a$. At $x=2$, this function produces no output ($f(2) = \text{Undefined}$).
The target height that surrounding points converge toward. As $x \to 2$, the limit cleanly exists and equals 4 ($\lim = 4$).
4 Graphical Interpretation: The Geometry of Limits
Visually, evaluating a limit corresponds to following the curve from both the left and right toward the coordinate $x = a$. Even if a hollow circle (hole) exists at $(2, 4)$, the two curve branches aim directly at the same height:
5 One-Sided Limits: Left-Hand and Right-Hand Limits
Along the real line, an input can approach target $a$ from two distinct directions: from numbers smaller than $a$, or from numbers larger than $a$.
As $x$ approaches $a$ from values strictly smaller than $a$ ($x \to a^-$):
The minus superscript ($a^-$) signifies approach from the negative/left side.
As $x$ approaches $a$ from values strictly greater than $a$ ($x \to a^+$):
The plus superscript ($a^+$) signifies approach from the positive/right side.
A general two-sided limit exists if and only if both one-sided limits exist, are finite, and equal the exact same value!
Counter-Example: When a Limit Fails to Exist (DNE)
Consider the piecewise function:
Left-Hand Limit: $\lim_{x \to 2^-} (x + 1) = 2 + 1 = 3$.
Right-Hand Limit: $\lim_{x \to 2^+} (x + 3) = 2 + 3 = 5$.
Because $3 \ne 5$, the curves do not meet. Therefore:
6 Fundamental Limit Laws
Assuming that $\lim_{x \to a} f(x) = L$ and $\lim_{x \to a} g(x) = M$ exist as finite real numbers:
| Limit Law | Formula | Condition / Remarks |
|---|---|---|
| Constant Rule | $\lim_{x \to a} c = c$ | The limit of a constant is the constant itself |
| Sum & Difference | $\lim [f(x) \pm g(x)] = L \pm M$ | Limits distribute over addition and subtraction |
| Constant Multiple | $\lim [c \cdot f(x)] = c \cdot L$ | Constant factors factor out of limits |
| Product Rule | $\lim [f(x) \cdot g(x)] = L \cdot M$ | The limit of a product is the product of limits |
| Quotient Rule | $\lim \frac{f(x)}{g(x)} = \frac{L}{M}$ | Strictly requires $M \ne 0$ |
| Power & Root Rule | $\lim [f(x)]^n = L^n, \quad \lim \sqrt[n]{f(x)} = \sqrt[n]{L}$ | Requires $L \gt 0$ for even roots ($n=2, 4\dots$) |
Direct Substitution for Polynomials:
Because polynomials are continuous everywhere across $\mathbb{R}$, their limit is evaluated by direct evaluation:
7 Indeterminate Forms: What to Do with $0/0$?
When direct substitution yields $\frac{0}{0}$ or $\frac{\infty}{\infty}$, this is known as an Indeterminate Form. It is not an answer—it indicates that a common factor $(x - a)$ is causing simultaneous vanishing in numerator and denominator:
Example: $\lim_{x \to 3} \frac{x^2 - 9}{x - 3}$
Cancels the vanishing $(x - 3)$ term cleanly.
Example: $\lim_{x \to 0} \frac{\sqrt{x + 1} - 1}{x}$
Eliminates radicals using $(a-b)(a+b) = a^2 - b^2$.
8 Infinite Limits and Limits at Infinity
Infinity ($\infty$) manifests in two distinct calculus contexts:
As input $x$ approaches a finite value, the output blows up to $\pm\infty$:
The line $x = 0$ is a Vertical Asymptote.
As input $x$ grows arbitrarily large ($x \to \infty$), the output stabilizes onto a finite value:
The line $y = 2$ is a Horizontal Asymptote.
9 Continuity: The Unbroken Function
Intuitively, a function is continuous if its graph can be traced without lifting your pencil from the paper.
Rigorous mathematical analysis establishes three mandatory conditions for a function $f(x)$ to be Continuous at a point $x = a$:
10 Classification of Discontinuities
If any of the three continuity tests fails, the function exhibits a Discontinuity. There are three primary types:
The limit exists, but $f(a)$ is undefined or differs from the limit.
Can be "repaired" by redefining $f(1) = 2$.
Left and right limits exist and are finite, but are unequal ($\text{LHL} \ne \text{RHL}$).
Common in Heaviside step functions and threshold gates.
The function blows up to positive or negative infinity as $x \to a$.
A vertical asymptote occurs at $x = 2$.
11 Testing Continuity in Piecewise Functions
In engineering and algorithmic modeling, piecewise equations must often be tuned to guarantee smooth transitions:
Problem: For what value of constant $k$ is the following function continuous at $x = 2$?
With $k=2$, $f(2) = 2(2) - 1 = 3$, matching both one-sided limits.
12 Real-World Applications in Computer Science and AI
Limits and continuity drive foundational algorithms in engineering, machine learning, and computer graphics:
1. Physics & Instantaneous Velocity
Average velocity across an interval is $\frac{\Delta s}{\Delta t}$. Taking the limit as time interval $\Delta t \to 0$ yields instantaneous velocity—the exact foundational limit that defines derivatives in physics engines and robotics.
2. Machine Learning & Gradient Descent
Gradient descent relies on continuous differentiability. If loss surfaces exhibit jump discontinuities, gradient updates oscillate violently or explode. Smooth activation functions (GELU, Swish) preserve continuous derivative flows through deep neural networks.
3. Computer Graphics & Parametric Splines
In 3D CAD modeling and animation, curves joined together must maintain $C^0$ continuity (connected positions), $C^1$ continuity (matching tangents), and $C^2$ continuity (matching curvature) to prevent visible seams or jarring camera movement.
4. Digital Signal Processing & Sampling
Converting continuous analog audio into discrete digital samples requires continuous low-pass filtering. Discontinuities in signals create high-frequency Gibbs ringing artifacts that distort audio reconstruction.
13 Python & SymPy Implementation: Limits and Continuity
The Python symbolic mathematics library sympy evaluates exact algebraic limits and directional one-sided limits effortlessly:
import sympy as sp
x = sp.Symbol('x')
# 1. Resolving Indeterminate 0/0 Form: (x^2 - 4)/(x - 2) as x -> 2
f1 = (x**2 - 4) / (x - 2)
limit1 = sp.limit(f1, x, 2)
print("Limit of (x^2 - 4)/(x - 2) as x -> 2:", limit1) # Output: 4
# 2. Classic Trigonometric Limit: sin(x)/x as x -> 0
f2 = sp.sin(x) / x
limit2 = sp.limit(f2, x, 0)
print("Limit of sin(x)/x as x -> 0:", limit2) # Output: 1
# 3. One-Sided Limits (Directional): 1/x as x -> 0
f3 = 1 / x
lhl = sp.limit(f3, x, 0, dir='-') # Left-hand
rhl = sp.limit(f3, x, 0, dir='+') # Right-hand
print(f"1/x as x->0: LHL = {lhl}, RHL = {rhl}") # -oo and +oo
# 4. Limits at Infinity: (2x + 1)/(x + 3) as x -> oo
f4 = (2*x + 1) / (x + 3)
limit_inf = sp.limit(f4, x, sp.oo)
print("Limit as x -> oo:", limit_inf) # Output: 2
14 8 Common Pitfalls and Traps
Avoid these classic stumbling blocks encountered when first navigating calculus:
A function can have a perfectly defined finite limit at a point where it is completely undefined.
A two-sided limit exists if and only if both left and right limits agree ($\text{LHL} = \text{RHL}$).
$0/0$ is an indeterminate form—a call for algebraic simplification, not a finished mathematical answer.
$\pm\infty$ represents unbounded divergence, not a point in the real number system $\mathbb{R}$.
Continuity requires all three conditions: $f(a)$ exists, $\lim f(x)$ exists, and both values are equal.
Always select $x \lt a$ formulas for left-hand limits and $x \gt a$ formulas for right-hand limits.
Canceling terms like $(x - 2)/(x - 2) = 1$ is valid under limits solely because $x$ approaches but never equals $2$.
In numerical algorithms, setting step size $h \lt 10^{-15}$ causes machine epsilon subtraction cancellation, yielding severe numeric noise.
Calculus Laboratory: Limits & Continuity Workbench
Experiment with approaching holes, tuning piecewise continuity, and secant-to-tangent convergence (No quiz)
Slide left toward $\delta \to 0$ to observe left and right markers converge onto the hole/limit!
Key Takeaways
The value that output $f(x)$ approaches as input $x$ approaches $a$. The input never needs to equal $a$.
A function can possess a valid finite limit at a point where the function value itself is undefined ($0/0$).
A general two-sided limit exists if and only if both left-hand and right-hand limits agree ($\text{LHL} = \text{RHL}$).
$0/0$ is an algebraic signal that factoring, rationalizing, or simplification will unveil the hidden limit.
Output divergence produces vertical asymptotes; long-term behavior ($x \to \infty$) produces horizontal asymptotes.
$f(a)$ must be defined, $\lim_{x \to a} f(x)$ must exist, and the limit must equal the value ($\lim = f(a)$).
Removable (hole in curve), Jump (step difference), and Infinite (vertical asymptote) discontinuities.
Instantaneous rates of change are defined by the difference quotient limit $\lim_{h \to 0} \frac{f(x+h)-f(x)}{h}$.
Continuous activation functions ensure smooth gradient updates, preventing numerical instability in backpropagation.
Welcome to Part 4: Calculus & Optimization!
You have laid the foundational bedrock of calculus. In upcoming lessons, we will expand limits into Derivatives, the Chain Rule, Multivariable Gradients, and Backpropagation—the engine that trains modern AI!