Limits and Continuity
Why It Matters
Limits are the foundation of calculus. Every derivative, integral, and convergence proof rests on the concept of a limit. In machine learning, limits explain why gradient descent converges, why loss functions stabilize, and why certain approximations work. Without limits, you cannot understand the mathematics behind modern AI — from the backpropagation algorithm to the asymptotic analysis of training complexity.
What is a Limit?
DfLimit (Intuitive Definition)
The limit of as approaches is the value gets closer and closer to as gets arbitrarily close to (from either side), but not equal to . The function does not need to be defined at — only near .
Limit Notation
Here,
- =The function being evaluated
- =The point x approaches
- =The limit value (the value f(x) approaches)
DfLimit (Epsilon-Delta Definition)
The limit of as approaches equals if for every , there exists a such that whenever , it follows that . Symbolically:
Epsilon-Delta Definition
Here,
- =An arbitrarily small positive tolerance around L
- =The corresponding tolerance around a
- =The claimed limit value
How to think about epsilon-delta
Think of it as a challenge-response game: your opponent picks any tolerance around , and you must find a neighborhood around so that every in that neighborhood maps within of . If you can always win, the limit exists.
Example: Proving a Limit with Epsilon-Delta
Prove that .
We need: given , find such that .
Simplify: . So we need , i.e., .
Choose . Then . QED.
Limit Laws
ThLimit Laws (Algebraic Properties)
Assume and exist. Then:
- Sum Law:
- Difference Law:
- Product Law:
- Quotient Law: , provided
- Constant Multiple Law: for any constant
- Power Law: for any positive integer
- Root Law: when is odd or
- Composite Law: If and is continuous at , then
ThSqueeze Theorem (Sandwich Theorem)
If for all in an open interval containing (except possibly at ), and if , then .
Example: Using the Squeeze Theorem
Find .
Since , we have .
Both and as , so by the Squeeze Theorem, .
One-Sided Limits
DfLeft-Hand Limit
The left-hand limit of as approaches is the value approaches as approaches from below (values less than ):
Left-Hand Limit
Here,
- =x approaches a from the left (x < a)
- =The left-hand limit value
DfRight-Hand Limit
The right-hand limit of as approaches is the value approaches as approaches from above (values greater than ):
Right-Hand Limit
Here,
- =x approaches a from the right (x > a)
- =The right-hand limit value
ThTwo-Sided Limit Exists iff Both One-Sided Limits Exist and Are Equal
if and only if .
Example: One-Sided Limits with the Sign Function
Consider .
Since , the two-sided limit does not exist.
Infinite Limits and Limits at Infinity
DfInfinite Limit
We write if grows without bound as approaches . This does not mean the limit exists in the traditional sense — it is a way of describing the behavior of unbounded growth.
DfLimit at Infinity
We write if approaches a finite value as grows without bound. This means has a horizontal asymptote .
Limits at Infinity for Rational Functions
Here,
- =Degree of the numerator
- =Degree of the denominator
- =Leading coefficients
Horizontal Asymptotes
To find horizontal asymptotes, compute and . If either limit is finite, that value defines a horizontal asymptote.
Common Limits
| Limit | Value | Context |
|---|---|---|
| Fundamental trigonometric limit | ||
| Follows from | ||
| Definition of derivative at 0 | ||
| Definition of derivative at 0 | ||
| Generalized binomial limit | ||
| Definition of Euler's number | ||
| Generalized exponential limit | ||
| Since | ||
| Inverse trigonometric limit | ||
| Inverse trigonometric limit | ||
| Continuous compounding | ||
| General exponential limit |
Squeeze Theorem
ThSqueeze Theorem (Formal Statement)
Let , , and be functions defined on an open interval containing , except possibly at itself. If for all in the interval and
Squeeze Theorem Condition
Here,
- =Lower bound function
- =Upper bound function
- =The function sandwiched between them
- =The common limit of the bounding functions
then .
Example: Squeeze Theorem Application
Find .
Multiply top and bottom by : .
As , we have , so .
Therefore .
L'Hôpital's Rule
ThL'Hôpital's Rule
If (both approach 0) or both approach , and if exists (or equals ), then:
L'Hôpital's Rule
Here,
- =Numerator (approaches 0 or ±∞)
- =Denominator (approaches 0 or ±∞)
- =Derivative of numerator
- =Derivative of denominator
When NOT to use L'Hôpital's Rule
L'Hôpital's Rule only applies to indeterminate forms or . If substituting gives a form like or , do not use L'Hôpital's Rule — evaluate directly.
Example: L'Hôpital's Rule
Compute .
Substituting : — indeterminate.
Apply L'Hôpital: again.
Apply L'Hôpital again: .
Example: L'Hôpital's Rule — Infinite Form
Compute .
Substituting : — indeterminate.
Apply L'Hôpital: .
Apply L'Hôpital again: .
This shows that exponentials grow faster than polynomials.
Continuity
DfContinuity at a Point
A function is continuous at if and only if all three conditions hold:
- is defined (the function exists at )
- exists (the left and right limits are equal)
- (the limit equals the function value)
DfContinuity on an Interval
A function is continuous on an interval if it is continuous at every point in the interval. Continuous functions have no breaks, jumps, or holes.
DfTypes of Discontinuities
Removable Discontinuity: The limit exists but is either undefined or not equal to the limit. You can "fix" it by redefining .
Jump Discontinuity: The left and right limits both exist but are not equal. The function "jumps" from one value to another.
Infinite Discontinuity: At least one of the one-sided limits is . The function has a vertical asymptote.
Oscillating Discontinuity: The function oscillates infinitely (e.g., near ), so the limit does not exist.
| Type | Condition | Example | Fixable? |
|---|---|---|---|
| Removable | but or undefined | at | Yes (redefine ) |
| Jump | at integers | No | |
| Infinite | at | No | |
| Oscillating | Limit does not exist due to oscillation | at | No |
Intermediate Value Theorem
ThIntermediate Value Theorem (IVT)
If is continuous on the closed interval and is any number between and , then there exists at least one such that .
Intuition
A continuous function cannot "skip" values. If you draw it without lifting your pen, and it goes from to , it must pass through every value between 2 and 5.
Example: Applying the IVT
Show that has a root in .
Since is continuous (polynomial) and is between and , by IVT there exists such that .
Limits and Derivatives
DfThe Derivative as a Limit
The derivative of at is defined as a limit of the difference quotient:
Derivative Definition via Limits
Here,
- =The derivative (instantaneous rate of change)
- =The increment (approaches 0)
- =The difference quotient (average rate of change)
Key Connection
The entire theory of derivatives rests on limits. Without limits, the concept of an "instantaneous rate of change" is undefined. This is why limits are taught before derivatives — they are the rigorous foundation beneath calculus.
Python Implementation: Numerical Verification of Limits
import numpy as np
def verify_limit(func, a, expected, approach='both', tol=1e-8):
"""Numerically verify that lim_{x -> a} f(x) = expected."""
results = {}
if approach in ('both', 'left'):
x_left = a - np.array([1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6])
x_left = x_left[x_left != a] # exclude a itself
vals_left = [func(x) for x in x_left]
results['left'] = vals_left
if approach in ('both', 'right'):
x_right = a + np.array([1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6])
vals_right = [func(x) for x in x_right]
results['right'] = vals_right
if approach == 'both':
final = (np.mean(vals_left[-2:]) + np.mean(vals_right[-2:])) / 2
elif approach == 'left':
final = np.mean(vals_left[-2:])
else:
final = np.mean(vals_right[-2:])
return final, abs(final - expected) < tol
# Example 1: sin(x)/x -> 1
val, ok = verify_limit(lambda x: np.sin(x) / x if x != 0 else 1.0, a=0, expected=1.0)
print(f"lim x->0 sin(x)/x = {val:.10f} (expected 1.0) {'PASS' if ok else 'FAIL'}")
# Example 2: (e^x - 1)/x -> 1
val, ok = verify_limit(lambda x: (np.exp(x) - 1) / x if x != 0 else 1.0, a=0, expected=1.0)
print(f"lim x->0 (e^x-1)/x = {val:.10f} (expected 1.0) {'PASS' if ok else 'FAIL'}")
# Example 3: (1 + 1/n)^n -> e
def compound(n):
return (1 + 1/n) ** n if n != 0 else np.e
val, ok = verify_limit(compound, a=10000, expected=np.e, approach='right')
print(f"lim n->inf (1+1/n)^n = {val:.10f} (expected {np.e:.10f}) {'PASS' if ok else 'FAIL'}")
# Example 4: Numerical derivative (limit definition)
def f(x):
return x**2
h_values = np.array([1e-1, 1e-2, 1e-3, 1e-4, 1e-5])
numerical_derivs = [(f(1 + h) - f(1)) / h for h in h_values]
print(f"\nNumerical derivative of x^2 at x=1:")
for h, d in zip(h_values, numerical_derivs):
print(f" h={h:.0e}: {d:.10f}")
print(f" Expected: 2.0")
# Example 5: Squeeze theorem verification — x^2 sin(1/x)
def squeeze_func(x):
return x**2 * np.sin(1/x) if x != 0 else 0.0
val, ok = verify_limit(squeeze_func, a=0, expected=0.0)
print(f"\nlim x->0 x^2*sin(1/x) = {val:.10f} (expected 0.0) {'PASS' if ok else 'FAIL'}")
Applications in AI/ML
Gradient Descent Convergence
Limits in Optimization
When we say gradient descent "converges," we mean . The learning rate must satisfy or follow specific schedules so that the limit exists. Without limits, we cannot prove convergence guarantees.
Asymptotic Analysis
Limits allow us to compare algorithm complexity:
- vs : we evaluate , confirming is asymptotically larger.
- Training time for large models: determines cost scaling.
Convergence of Loss Functions
Convergence Condition
Here,
- =Loss at training step t
- =Optimal (minimum) loss
Probability and Statistics
- Law of Large Numbers: (sample mean converges to population mean)
- Central Limit Theorem: Distributional limits underpin confidence intervals
- Bayesian posterior: (posterior concentrates at true parameter)
Neural Network Expressiveness
Universal Approximation
The Universal Approximation Theorem states that for any continuous function on and any , there exists a neural network such that . This is fundamentally an epsilon-type statement about the limit of approximation quality as network width grows.
Common Mistakes
| Mistake | Why It's Wrong | Correct Approach |
|---|---|---|
| Assuming always | Only true for continuous functions | Check all three continuity conditions |
| Applying L'Hôpital to non-indeterminate forms | is not | Evaluate directly; only use L'Hôpital for or |
| Thinking is a number | is a concept, not a value | Use limits to describe unbounded behavior rigorously |
| Confusing limit existence with limit value | The limit can exist and equal a finite value, or not exist | Check both sides: left = right? |
| Forgetting to check exists for all | Epsilon-delta requires universal quantification | Verify for every , not just small ones |
| Assuming always | Only valid when both limits exist (finite) | Check existence first; is indeterminate |
| Canceling in without care | Must account for domain () | Factor and cancel before taking the limit |
Interview Questions
Q1: What is the epsilon-delta definition of a limit, and why is it needed?
A: The epsilon-delta definition provides a rigorous foundation for limits. It eliminates ambiguity by formalizing "approaches" with precise tolerances. Intuitive notions of limits fail for pathological functions (like near 0). The epsilon-delta definition is needed to prove limit laws, establish the correctness of L'Hôpital's Rule, and build calculus on solid logical foundations.
Q2: When does exist even though direct substitution fails?
A: When both and (or both ), we have an indeterminate form. The limit may still exist. Techniques include:
- Factor and cancel common factors
- Apply L'Hôpital's Rule (differentiate top and bottom)
- Use series expansion (Taylor series)
- Use the Squeeze Theorem
Q3: Explain the relationship between one-sided limits and continuity.
A: A function is continuous at if and only if:
- The left-hand limit exists
- The right-hand limit exists
- Both are equal to
If the one-sided limits exist but differ, there is a jump discontinuity. If one or both don't exist, continuity fails.
Q4: Why can't we just use L'Hôpital's Rule for every limit problem?
A: L'Hôpital's Rule only applies to indeterminate forms ( or ). Applying it to non-indeterminate forms gives incorrect results. For example, , but applying L'Hôpital gives , which is wrong. Additionally, L'Hôpital requires the derivatives to exist and the limit of the ratio of derivatives to exist.
Q5: How does the Squeeze Theorem help in machine learning?
A: The Squeeze Theorem is used to:
- Prove convergence of algorithms when direct evaluation is difficult
- Establish bounds on error terms in numerical methods
- Show that noise terms vanish: if you can bound the noise between two functions that both go to 0, the noise itself vanishes
- Prove that regularized loss functions converge to their unregularized counterparts as the regularization parameter goes to 0
Q6: What happens when you take the limit of a sequence of functions? Is it always continuous?
A: No. The limit of continuous functions can be discontinuous. Consider on : each is continuous, but equals 0 for and 1 at , which is discontinuous. Uniform convergence (a stronger condition than pointwise convergence) preserves continuity.
Practice Problems
Problem 1: Compute the Limit
Evaluate .
Solution
Multiply by the conjugate:
Problem 2: Continuity Analysis
Determine where is discontinuous and classify each.
Solution
Factor: .
- At : removable discontinuity. . Redefine to fix.
- At : infinite discontinuity. . Vertical asymptote at .
Problem 3: L'Hôpital's Rule
Evaluate .
Solution
Substituting gives . Apply L'Hôpital three times:
Answer: .
Problem 4: Using the Squeeze Theorem
Prove that .
Solution
Since , we have .
As : and .
By the Squeeze Theorem, .
Problem 5: Limit at Infinity
Evaluate .
Solution
Divide numerator and denominator by :
Since the degrees of numerator and denominator are equal, the limit is the ratio of leading coefficients: .
Quick Reference
| Concept | Formula / Rule | Key Point |
|---|---|---|
| Limit Definition | as | |
| Epsilon-Delta | Rigorous definition | |
| Sum Law | Requires both limits exist | |
| Product Law | Requires both limits exist | |
| Quotient Law | Denominator limit | |
| Squeeze Theorem | , | Sandwich between bounds |
| L'Hôpital's Rule | Only for or | |
| Continuity | No breaks, jumps, or holes | |
| IVT | continuous on , between | Continuous functions don't skip values |
| Derivative | Derivative is a limit | |
| Fundamental trig limit | Foundation for derivatives of trig functions | |
| Definition of | Compound interest, exponential growth |
Cross-References
- 025 — Derivatives and Differentiation: The derivative is defined as a limit of the difference quotient.
- 026 — Chain Rule: Chain rule relies on limits of composite functions.
- 027 — Partial Derivatives: Multivariable limits and partial derivatives.
- 028 — Integrals: Integrals are defined as limits of Riemann sums.
- 029 — Taylor Series: Taylor series convergence depends on limit behavior.
- 030 — Optimization: Optimization requires limits to define derivatives and find critical points.
- 062 — Gradient Descent: Convergence proofs use limit theory.
- 042 — Central Limit Theorem: Distributional limits in probability.