A limit captures what f(x) approaches as x approaches a, even if f(a) is undefined. The epsilon-delta definition makes "approaches" precise. Continuity means the limit equals the function value. The Intermediate Value Theorem is the payoff.
Intuitive limits
The limit of f(x) as x approaches a is L if f(x) gets arbitrarily close to L whenever x is sufficiently close to a (but not equal to a). We can test this numerically by plugging in values closer and closer to a.
Scheme
; Limit of sin(x)/x as x -> 0; f(0) is undefined (0/0), but the limit exists
(define (f x) (/ (sin x) x))
; Approach 0 from the right
(display "x=1.0: ") (display (f 1.0)) (newline)
(display "x=0.1: ") (display (f 0.1)) (newline)
(display "x=0.01: ") (display (f 0.01)) (newline)
(display "x=0.001: ") (display (f 0.001)) (newline)
(display "x=0.0001: ") (display (f 0.0001)) (newline)
; Approach 0 from the left
(display "x=-0.01: ") (display (f -0.01)) (newline)
(display "x=-0.001: ") (display (f -0.001)) (newline)
(display "Limit = 1")
Python
importmathdef f(x): returnmath.sin(x) / x
for x in [1.0, 0.1, 0.01, 0.001, 0.0001]:
print(f"f({x}) = {f(x):.8f}")
print("Limit as x -> 0 is 1")
Epsilon-delta definition
For every ε > 0, there exists a δ > 0 such that |f(x) - L| < ε whenever 0 < |x - a| < δ. This replaces "approaches" with a checkable inequality. ε is the tolerance on the output; δ is the tolerance on the input.
Scheme
; Epsilon-delta: show that lim(2x+1) as x->3 = 7; For any epsilon, we need delta such that; |f(x) - 7| < epsilon when 0 < |x - 3| < delta; |(2x+1) - 7| = |2x - 6| = 2|x-3| < epsilon; So delta = epsilon/2 works.
(define (f x) (+ (* 2 x) 1))
(define L 7)
(define a 3)
(define (check-epsilon-delta epsilon)
(let ((delta (/ epsilon 2)))
; Test a point just inside delta
(let ((x (+ a (* delta 0.99))))
(let ((error (abs (- (f x) L))))
(display "eps=") (display epsilon)
(display " delta=") (display delta)
(display " |f(x)-L|=") (display (/ (round (* error 100000)) 100000))
(display (if (< error epsilon) " OK"" FAIL"))
(newline)))))
(check-epsilon-delta 1.0)
(check-epsilon-delta 0.1)
(check-epsilon-delta 0.01)
(check-epsilon-delta 0.001)
Python
# Epsilon-delta: lim(2x+1) as x->3 = 7# delta = epsilon/2 works because |(2x+1)-7| = 2|x-3|def f(x): return2*x + 1
L, a = 7, 3for eps in [1.0, 0.1, 0.01, 0.001]:
delta = eps / 2
x = a + delta * 0.99
error = abs(f(x) - L)
status = "OK"if error < eps else"FAIL"print("eps={} delta={} |f(x)-L|={:.5f} {}".format(eps, delta, error, status))
Squeeze theorem
If g(x) ≤ f(x) ≤ h(x) near a, and lim g(x) = lim h(x) = L, then lim f(x) = L. The classic example: -1 ≤ sin(x) ≤ 1, so -|x| ≤ x sin(1/x) ≤ |x|. As x approaches 0, both bounds go to 0, so x sin(1/x) goes to 0.
importmath# Squeeze theorem: -|x| <= x*sin(1/x) <= |x|def f(x): return x * math.sin(1/x)
for x in [1.0, 0.1, 0.01, 0.001]:
print("x={} lower={:.4f} f={:.4f} upper={:.4f}".format(
x, -abs(x), f(x), abs(x)))
print("All three squeeze to 0")
Continuity
f is continuous at a if three things hold: f(a) exists, lim f(x) as x approaches a exists, and the limit equals f(a). Polynomials, sin, cos, exp are continuous everywhere on their domains. Rational functions are continuous except where the denominator is zero.
Scheme
; Continuity check: f is continuous at a if lim f(x) = f(a); Continuous: f(x) = x^2 at x = 2
(define (f x) (* x x))
(display "f(2) = ") (display (f 2)) (newline)
(display "f(1.99) = ") (display (f 1.99)) (newline)
(display "f(2.01) = ") (display (f 2.01)) (newline)
(display "Continuous: limit = f(2) = 4") (newline) (newline)
; Discontinuous: g(x) = 1/x at x = 0; g(0) is undefined, so g is not continuous at 0
(display "g(0.001) = ") (display (/ 10.001)) (newline)
(display "g(-0.001) = ") (display (/ 1-0.001)) (newline)
(display "Left and right limits disagree: not continuous")
Python
# Continuity: lim f(x) must equal f(a)# Continuous: f(x) = x^2 at x = 2
f = lambda x: x**2print("f(2) =", f(2))
print("f(1.99) =", f(1.99))
print("f(2.01) =", f(2.01))
print("Continuous: limit = f(2) = 4")
print()
# Discontinuous: g(x) = 1/x at x = 0print("g(0.001) =", 1/0.001)
print("g(-0.001) =", 1/-0.001)
print("Left and right limits disagree: not continuous")
Intermediate Value Theorem
If f is continuous on [a,b] and f(a) < c < f(b), then there exists some x in (a,b) where f(x) = c. Geometrically: a continuous curve that goes from below c to above c must cross c somewhere. This is how we prove roots exist.
Scheme
; IVT: if f is continuous and changes sign, there's a root; Use bisection to find where x^2 - 2 = 0 (i.e., sqrt(2))
(define (f x) (- (* x x) 2))
(define (bisect lo hi n)
(if (= n 0)
(let ((mid (/ (+ lo hi) 2)))
(display "root ~ ") (display mid) (newline)
(display "f(root) ~ ") (display (f mid)))
(let ((mid (/ (+ lo hi) 2)))
(if (< (* (f lo) (f mid)) 0)
(bisect lo mid (- n 1))
(bisect mid hi (- n 1))))))
(display "f(1) = ") (display (f 1)) (newline) ; -1
(display "f(2) = ") (display (f 2)) (newline) ; 2
(display "Sign change: root exists in (1,2)") (newline)
(bisect 1.02.030)
Python
# IVT + bisection to find sqrt(2)def f(x): return x**2 - 2
lo, hi = 1.0, 2.0print("f(1) =", f(1), " f(2) =", f(2))
print("Sign change: root exists in (1,2)")
for _ inrange(30):
mid = (lo + hi) / 2if f(lo) * f(mid) < 0:
hi = mid
else:
lo = mid
print("root ~", mid)
print("f(root) ~", f(mid))