Foundations to Frontier
Tests
A. Mathematical Foundations › A3 Calculus and Analysis › Single-variable calculus

Limits and Continuity

A limit asks where a function is heading, even if it never arrives. Continuity means no jumps. These two ideas underpin derivatives, integrals and every convergence guarantee in optimization, and they explain why bisection always finds a root.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Getting closer and closer

Stand 1 metre from a wall. Step halfway to it, then halfway again, and again. You’re 0.5 m away, then 0.25 m, then 0.125 m… You never touch the wall, but you’re clearly heading to it. Mathematicians say the distance has a limit of 0.

No jumps

Draw a line without lifting your pencil. That’s a continuous function. A light switch is not continuous: it jumps from off to on.

The ε–δ game: can you stay within ε of the limit?
claimed limit L = 2 at a = 1 · largest δ found: 0.299 (blue window); inside it every value stays in the green band
A hole at x = 1, but the limit is 2: removable discontinuity. Green band = L ± ε. Open circle = the point (a, L); the value at a itself never matters for a limit.
Why engineers care

If a robot’s distance to a wall is positive now and negative later, it must have touched the wall in between, because distance changes continuously. That simple fact lets collision-checking software find the exact moment of contact.

📝 Quick check (Level 0)
0/3 answered
  1. 1. 1 m from a wall, you step halfway three times. Distance left?
  2. 2. 0.9, 0.99, 0.999, … is heading to…
  3. 3. A light switch jumping from off to on is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

Notation

lim⁡x→af(x)=L\lim_{x\to a}f(x) = L

This means: as xx gets close to aa (but not equal to it), f(x)f(x) gets close to LL. The value at aa doesn’t matter. It may not even exist.

Example. f(x)=x2−1x−1f(x) = \frac{x^2 - 1}{x - 1} is undefined at x=1x = 1. For x≠1x\ne1, it equals x+1x + 1, so lim⁡x→1f(x)=2\lim_{x\to1}f(x) = 2.

  • One-sided limits: lim⁡x→a−\lim_{x\to a^-} (from the left) and lim⁡x→a+\lim_{x\to a^+} (from the right). The limit exists when both agree.
  • Continuity at a: lim⁡x→af(x)=f(a)\lim_{x\to a}f(x) = f(a). You can plug the point in.
  • Limit laws: limits of sums, products and quotients (with a nonzero denominator) are the sums, products and quotients of the limits. Polynomials, exp, sin and cos are continuous everywhere.
📝 Quick check (Level 1)
0/3 answered
  1. 1. lim_{x→3} (2x + 1) = ?
  2. 2. lim_{x→2} (x² − 4)/(x − 2) = ?
  3. 3. lim_{x→∞} 1/x = ?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

The precise definition (ε–δ)

lim⁡x→af(x)=L  ⟺  ∀ε>0 ∃δ>0: 0<∣x−a∣<δ  ⟹  ∣f(x)−L∣<ε\lim_{x\to a}f(x) = L \iff \forall\varepsilon>0\ \exists\delta>0:\ 0<\lvert x - a\rvert<\delta\implies\lvert f(x) - L\rvert<\varepsilon

It’s a game. You challenge me with a tolerance ε\varepsilon, and I must find a window δ\delta around aa where ff stays within ε\varepsilon of LL. For f(x)=3x+1f(x) = 3x + 1 at a=2a = 2, the choice δ=ε/3\delta = \varepsilon/3 always wins, because ∣3x+1−7∣=3∣x−2∣\lvert3x + 1 - 7\rvert = 3\lvert x - 2\rvert. Try the game in the demo above.

Important limits

Limit Value How
lim⁡x→0sin⁡xx\lim_{x\to0}\frac{\sin x}x 1 squeeze theorem (geometry)
lim⁡x→01−cos⁡xx2\lim_{x\to0}\frac{1 - \cos x}{x^2} 12\tfrac12 1−cos⁡x=2sin⁡2(x/2)1 - \cos x = 2\sin^2(x/2)
lim⁡n→∞(1+1n)n\lim_{n\to\infty}(1 + \tfrac1n)^n ee definition of ee
lim⁡x→∞3x2+1x2+5\lim_{x\to\infty}\frac{3x^2 + 1}{x^2 + 5} 3 divide by x2x^2
lim⁡x→0x2sin⁡(1/x)\lim_{x\to0}x^2\sin(1/x) 0 squeeze between ±x2\pm x^2
lim⁡x→0sin⁡(1/x)\lim_{x\to0}\sin(1/x) none oscillates

Kinds of discontinuity

  • Removable: a hole, as in x2−1x−1\frac{x^2-1}{x-1}.
  • Jump: the one-sided limits differ, as in a step function or a thresholded classifier.
  • Infinite: 1/x1/x.
  • Oscillating: sin⁡(1/x)\sin(1/x).

Limits on a computer

Numerically, you approach a limit by evaluating closer and closer. Floating point has about 16 digits, though. Subtracting nearly equal numbers (catastrophic cancellation) destroys them all.

🐍 Exercise 1: approaching a limit, and where computers fail
Tabulate f(a ± 10⁻ᵏ). Show that (1 − cos x)/x² collapses to 0 for tiny x in floating point, and fix it with 2sin²(x/2)/x².
📝 Quick check (Level 2)
0/3 answered
  1. 1. lim_{x→0} sin(3x)/x = ?
  2. 2. For f = 3x + 1 at a = 2 and ε = 0.3, the best δ is…
  3. 3. A step function at its jump has…

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

An ε–δ proof

Claim. f(x)=x2f(x) = x^2 is continuous at a=3a = 3.

Proof. We have ∣x2−9∣=∣x−3∣ ∣x+3∣\lvert x^2 - 9\rvert = \lvert x - 3\rvert\,\lvert x + 3\rvert. If ∣x−3∣<1\lvert x - 3\rvert<1, then ∣x+3∣<7\lvert x + 3\rvert<7. Given ε\varepsilon, choose δ=min⁡(1,ε/7)\delta = \min(1, \varepsilon/7). Then ∣x2−9∣<7δ≤ε\lvert x^2 - 9\rvert<7\delta\le\varepsilon. ∎

The big theorems about continuous functions on [a,b][a,b]

Intermediate Value Theorem (IVT)

If ff is continuous on [a,b][a,b] and yy lies between f(a)f(a) and f(b)f(b), then f(c)=yf(c) = y for some c∈[a,b]c\in[a,b].

Proof idea. Suppose f(a)<0<f(b)f(a)<0<f(b), and let c=sup⁡{x∈[a,b]:f(x)<0}c = \sup\{x\in[a,b] : f(x)<0\}. This uses the completeness of the real numbers: every bounded set has a least upper bound. If f(c)<0f(c)<0, continuity keeps ff negative a bit to the right of cc, contradicting the sup. If f(c)>0f(c)>0, then ff is positive a bit to the left, so a smaller upper bound would exist. Hence f(c)=0f(c) = 0. ∎ Over the rationals, IVT fails: x2−2x^2 - 2 changes sign on [1,2][1,2] but has no rational root.

Extreme Value Theorem

A continuous function on a closed, bounded interval attains a maximum and a minimum.

This is why optimization over compact sets always has a solution (A6). On open sets, 1/x1/x on (0,1)(0,1) has no maximum.

Stronger kinds of continuity

Notion Definition Example
continuous δ\delta may depend on the point 1/x1/x on (0,1)(0,1)
uniformly continuous one δ\delta for all points any continuous function on [a,b][a,b] (Heine–Cantor)
Lipschitz ∣f(x)−f(y)∣≤L∣x−y∣\lvert f(x) - f(y)\rvert\le L\lvert x - y\rvert tanh⁡\tanh (L=1L = 1). x\sqrt x on [0,1][0,1] is uniformly continuous but not Lipschitz
Exercise 3.1: Why does bisection always converge?

Each step keeps a sub-interval where ff changes sign and halves its width. The left endpoints increase, the right endpoints decrease, and the gap goes to 0, so both converge to the same cc. By continuity, f(c)f(c) is both ≤0\le0 and ≥0\ge0. After nn steps the error is at most (b−a)/2n(b-a)/2^n.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Does x³ − x − 1 have a root in [1, 2]?
  2. 2. IVT relies on which property of ℝ?
  3. 3. √x on [0, 1] is…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Root finding and contact detection

The IVT is constructive through bisection: ⌈log⁡2((b−a)/tol)⌉\lceil\log_2((b-a)/\text{tol})\rceil function evaluations guarantee the tolerance, with no derivatives needed. Robotics uses this for continuous collision detection. If the signed distance d(t)d(t) between a robot and an obstacle is positive at t0t_0 and negative at t1t_1, there is a contact time in between, found by bisection or conservative advancement.

🐍 Exercise 2 (research): find the contact time of a robot trajectory
A robot follows p(t) = (2t, 1 + sin t). Bisect on the signed distance to a circular obstacle to find the crossing time to 10⁻⁹, and check the iteration count matches ⌈log₂(1.5/10⁻⁹)⌉.

Continuity in learning and control

  • Activations. ReLU is continuous but has a kink. The Heaviside step is discontinuous, and its gradient is 0 almost everywhere, which is why the perceptron’s step was replaced by sigmoids for backpropagation (Rumelhart, Hinton and Williams, 1986). Straight-through estimators and surrogate gradients (spiking networks) are workarounds for discontinuous units.
  • Lipschitz continuity bounds how much outputs can change. It gives certified robustness for classifiers and controllers (A2.3-8), and step-size rules in optimization (A6: η<2/L\eta<2/L).
  • Contact and hybrid dynamics. A legged robot’s dynamics jump when a foot touches the ground. Differentiable simulators smooth these discontinuities so gradients exist (e.g. MuJoCo’s soft contacts; Todorov, Erez and Tassa, 2012). Policy-gradient methods avoid differentiating through them at all.
  • Floating-point limits. Finite differences, log⁡(1+x)\log(1+x), ex−1e^x - 1 and softmax all need numerically stable forms (log1p, expm1, max-subtraction) to avoid cancellation (Higham, 2002).

References

  1. A.-L. Cauchy (1821). Cours d’analyse de l’École royale polytechnique.
  2. K. Weierstrass (1861, lectures); the ε–δ definition as standardized in W. Rudin (1976), Principles of Mathematical Analysis, 3rd ed. McGraw-Hill. Chapter 4.
  3. B. Bolzano (1817). “Rein analytischer Beweis des Lehrsatzes…” (the first proof of the intermediate value theorem).
  4. N. Higham (2002). Accuracy and Stability of Numerical Algorithms, 2nd ed. SIAM.
  5. D. Rumelhart, G. Hinton, R. Williams (1986). “Learning representations by back-propagating errors.” Nature, 323.
  6. E. Todorov, T. Erez, Y. Tassa (2012). “MuJoCo: A physics engine for model-based control.” IROS.
  7. S. Redon, A. Kheddar, S. Coquillart (2002). “Fast continuous collision detection between rigid bodies.” Computer Graphics Forum, 21(3).