Limits & Continuity

Calculus & Optimization

Chapter 2 · Limits & Continuity

Chapter 1's numerical experiment shrank h toward zero and watched the approximation "converge toward" the true derivative — without ever setting h exactly to zero. That word, converge, has a precise name: a limit. This chapter formalizes it, practically rather than with full epsilon-delta rigor, per Chapter 1's own honest scope note.

What a Limit Actually Captures

The intuitive definition
lim(x→a) f(x) = L means: as x gets arbitrarily close to a — without necessarily ever reaching it — f(x) gets arbitrarily close to L. The limit describes what a function approaches, which is a genuinely different question from what the function's value is at that exact point — sometimes those two things differ entirely.

Why This Matters for Derivatives Specifically

The derivative is defined as a limit: f'(x) = lim(h→0) (f(x+h)−f(x))/h. Plugging in h=0 directly gives 0/0 — genuinely undefined, a real division by zero. The limit is precisely the tool that lets Chapter 1's whole numerical experiment make sense: reasoning about what the expression approaches as h shrinks toward zero, without ever actually dividing by zero.

A Worked Example: A Limit That Exists Where the Function Doesn't

Consider f(x) = (x²−4)/(x−2). Substituting x=2 directly gives 0/0 — undefined, a genuine division-by-zero error.

Resolved algebraically, verified numerically from both sides
Factoring: (x²−4)/(x−2) = (x−2)(x+2)/(x−2) = x+2, valid everywhere x≠2. Approaching from below: x=1.9→3.9, x=1.99→3.99, x=1.999→3.999. Approaching from above: x=2.001→4.001, x=2.01→4.01, x=2.1→4.1. Both directions converge on 4 — confirming lim(x→2) f(x) = 4, even though f(2) itself is a genuine ZeroDivisionError, confirmed directly.

Continuity: When the Limit and the Function Actually Agree

The definition
f is continuous at a when three things all hold: f(a) is defined, lim(x→a) f(x) exists, and the two are equal.
This chapter's own example is discontinuous — a "removable" hole
f(x)=(x²−4)/(x−2) is discontinuous at x=2 — the limit exists (4, verified above), but f(2) itself is undefined, so the first requirement of continuity fails outright. The simplified function g(x)=x+2 is continuous everywhere, including at x=2 where it equals 4 — the two functions agree everywhere except at the single point the original one has a hole.

A Real Case: Continuous, But Not Differentiable

Continuity is necessary for differentiability, but not sufficient — a function can be perfectly continuous and still have no well-defined derivative at a point. f(x) = |x| at x=0 is the classic case.

Verified directly — continuity holds
Approaching x=0 from both sides: f(-0.01)=0.01, f(-0.001)=0.001, f(0.001)=0.001, f(0.01)=0.01 — the limit is 0, matching f(0)=0 exactly. |x| is genuinely continuous at 0.
Verified directly — differentiability fails
The difference quotient (f(0+h)−f(0))/h, approached from the right (h=0.1, 0.01, 0.001, 0.0001): consistently 1.0. Approached from the left (h=−0.1, −0.01, −0.001, −0.0001): consistently −1.0. The two one-sided limits genuinely disagree — no single limit exists, so |x| has no derivative at x=0, despite being perfectly continuous there. A sharp corner, not a smooth curve, at that exact point.

Real Relevance

Chapter 6's gradient descent assumes it can always ask "which direction does this function decrease in?" — a question that only has a clean answer where the function is differentiable. Functions with sharp corners (like ReLU, an extremely common neural-network activation function, which is literally max(0,x) — a close cousin of |x|) genuinely have points where the derivative doesn't exist in the classical sense, a real practical wrinkle real ML libraries handle by defining a sensible value at that single point rather than pretending the problem doesn't exist.

Limits in Code

def f(x): return (x**2 - 4) / (x - 2) # approaching x=2 from both sides -- never substituting x=2 directly for x in [1.9, 1.99, 1.999, 2.001, 2.01, 2.1]: print(f"f({x}) = {f(x)}") # all approach 4 try: f(2) # ZeroDivisionError -- f(2) is genuinely undefined except ZeroDivisionError: print("f(2) is undefined, even though the limit at x=2 is 4")

Hands-On Exercises

Exercise 1

Find lim(x→3) (x²−9)/(x−3) algebraically (factor first), then verify your answer numerically by evaluating the function at x=2.99, x=2.999, x=3.001, and x=3.01.

📄 View solution
Exercise 2

Using this chapter's own three-part definition of continuity, explain specifically which part fails for f(x)=(x²−9)/(x−3) at x=3, given your answer to Exercise 1.

📄 View solution
Exercise 3

Using this chapter's own left/right difference-quotient method for |x|, compute the one-sided difference quotients for f(x) = -|x| at x=0 (approaching from the right with h=0.01, and from the left with h=-0.01). Do they agree? What does this tell you about whether -|x| is differentiable at x=0?

📄 View solution

Chapter 2 Quick Reference

  • Limit: what a function approaches as its input approaches a point — not necessarily what the function equals there
  • The derivative is defined as a limit specifically to avoid ever dividing by zero directly
  • An indeterminate 0/0 form can often be resolved by algebraic simplification first — verified on (x²−4)/(x−2) → 4 at x=2
  • Continuity: f(a) defined, the limit exists, and they're equal — all three, together
  • Continuity is necessary but not sufficient for differentiability — verified directly: |x| is continuous but not differentiable at x=0 (left/right difference quotients disagree, -1 vs. 1)
  • Next chapter: Derivatives — definition and rules