---
title: Limits of functions and continuity
heading: Choosing δ for a given ε
eyebrow: A14 · Lesson 12 · Limits of functions and continuity
xp: 40
---

::: hook
"A small change in the input gives a small change in the output" is what makes a measurement trustworthy, a controller stable and a numerical method meaningful. Continuity is that idea made exact, by the same game as lesson 3. You name a tolerance ε on the output; I must name a tolerance δ on the input such that every input within δ gives an output within ε. If I can always answer, the function is continuous there. How δ depends on ε, and whether one δ works at every point at once, are the quantitative questions behind sensitivity and robustness.
:::

::: play
- The function is $f(x) = x^2$ near the point a. The horizontal band is $f(a) \pm \varepsilon$; the vertical markers are $a \pm \delta$, with δ the largest that works.
- Every x between the markers gives f(x) inside the band. The largest δ here is $\sqrt{a^2 + \varepsilon} - \lvert a\rvert$.
- Move a away from 0 with ε fixed: δ shrinks, because the curve is steeper there. No single δ works at every point of the whole line; lesson 13 calls that failure of *uniform* continuity.
:::
:::

```sim plot
view: graph
x: x = -3..3
y: y = -0.5..9
slider: a = 0..2.5 step 0.05 = 1.5
slider: e = 0.05..2 step 0.05 = 0.5
plot: x^2 | label: f(x) = x²
plot: a^2 + e + 0*x | dashed | label: f(a) ± ε
plot: a^2 - e + 0*x | dashed
marker: x = a - (sqrt(a^2 + e) - a) | label: a − δ
marker: x = a + (sqrt(a^2 + e) - a) | label: a + δ
readout: largest δ = sqrt(a^2 + e) - a
```

::: predict
## For $f(x) = 3x + 1$ and ε = 0.03, what's the largest δ that works at every point?

- [ ] 0.03
- [x] 0.01
- [ ] 0.09
- [ ] It depends on the point

::: reveal
0.01: $\lvert f(x) - f(a)\rvert = 3\lvert x - a\rvert < 0.03$ exactly when $\lvert x - a\rvert < 0.01$. For a straight line the slope sets δ, and the same δ works everywhere.
:::
:::

::: nameit
## Limits and continuity

$\lim_{x\to a}f(x) = L$ means: for every ε > 0 there's a δ > 0 such that $0 < \lvert x - a\rvert < \delta$ implies $\lvert f(x) - L\rvert < \varepsilon$.

f is **continuous at a** if $\lim_{x\to a}f(x) = f(a)$: for every ε there's a δ with $\lvert x - a\rvert < \delta \Rightarrow \lvert f(x) - f(a)\rvert < \varepsilon$.

**Sequential form:** f is continuous at a exactly when $x_n \to a$ implies $f(x_n) \to f(a)$. This is often the easier way to show a function is *not* continuous: find one sequence that breaks it.

## Building continuous functions

Sums, products, quotients (where the denominator isn't 0) and compositions of continuous functions are continuous. Polynomials, exp, sin, cos and $\sqrt x$ (for x ≥ 0) are continuous on their domains.

## Lipschitz functions

If $\lvert f(x) - f(y)\rvert \le L\lvert x - y\rvert$ for all x, y, then $\delta = \varepsilon/L$ works everywhere. A differentiable function with $\lvert f'\rvert \le L$ is Lipschitz with constant L, by the mean value theorem (lesson 15).

## How functions fail

- a **jump**, like the unit step at 0;
- a **blow-up**, like $\frac1x$ at 0;
- **wild oscillation**, like $\sin\frac1x$ at 0, which takes every value in [−1, 1] near 0;
- **everywhere**, like the indicator of the rationals, which is continuous nowhere.

$x\sin\frac1x$, defined as 0 at 0, *is* continuous at 0: $\lvert x\sin\frac1x\rvert \le \lvert x\rvert$, so δ = ε works.
:::

::: example
## Prove $x^2$ is continuous at a = 2, and find δ for ε = 0.1.

::: solution
1. **Factor.**
   $$\lvert x^2 - 4\rvert = \lvert x - 2\rvert\lvert x + 2\rvert$$
2. **Bound the second factor.** If $\lvert x - 2\rvert < 1$, then $\lvert x + 2\rvert < 5$, so
   $$\lvert x^2 - 4\rvert < 5\lvert x - 2\rvert$$
3. **Choose δ.** Taking
   $$\delta = \min(1, \varepsilon/5)$$
   works for every ε; for ε = 0.1, δ = 0.02.
4. **The largest δ.** The largest δ that works is
   $$\sqrt{4.1} - 2 = 0.0248$$

**Answer:** $x^2$ is continuous at 2, with $\delta = \min(1, \varepsilon/5)$; for ε = 0.1 that gives δ = 0.02 (the largest that works is 0.0248).
:::
:::

::: example
## Show the unit step u(x) (0 for x < 0, 1 for x ≥ 0) isn't continuous at 0.

::: solution
1. **Approach 0 from the left.** Take $x_n = -\frac1n \to 0$.
2. **Look at the values.** Then $u(x_n) = 0$ for every n, which doesn't tend to $u(0) = 1$.
3. **Conclude.** By the sequential form, u isn't continuous at 0: with ε = ½, no δ works.

**Answer:** along $x_n = -\frac1n$ the values stay at 0 while $u(0) = 1$, so u isn't continuous at 0.
:::
:::

::: example
## For $f(x) = \frac1x$ at a = 2, find the largest δ that works with ε = 0.1.

::: solution
1. **Translate the condition.** We need
   $$\left\lvert\frac1x - \frac12\right\rvert < 0.1$$
   that is, $0.4 < \frac1x < 0.6$, or
   $$1.667 < x < 2.5$$
2. **Measure both sides.** The interval around 2 reaches 0.333 to the left and 0.5 to the right.
3. **Take the smaller side.** δ must work on both sides, so the largest is
   $$\begin{aligned} \delta &= 2 - \frac53 \\ &= \frac13 \end{aligned}$$
4. **In general.** At a point a,
   $$\delta = \frac{a^2\varepsilon}{1 + a\varepsilon}$$
   which shrinks to 0 as a → 0: near the pole, ever-smaller δ are needed, which is why $\frac1x$ isn't uniformly continuous on (0, 1].

**Answer:** the largest δ is $\frac13$.
:::
:::

::: check
given: m = 3 | -5 | 0.4; e = 0.03 | 0.1
answer: e/abs(m)
tolerance: 0.1%

## For $f(x) = \given{m}x + 2$ and ε = {e}, what's the largest δ that works?

::: right
Right. $\varepsilon/\lvert m\rvert$ = {answer}.
:::

::: misses
- [e*abs(m)] Divide by the slope: a steeper line needs a smaller δ.
- [any] Not yet. $\lvert f(x) - f(a)\rvert = \lvert m\rvert\lvert x - a\rvert$.
:::
:::

::: check
given: a = 1 | 2 | 3; e = 0.1 | 0.01
answer: sqrt(a^2 + e) - a
tolerance: 0.01%

## For $f(x) = x^2$ at a = {a} and ε = {e}, what's the largest δ that works?

::: right
Right. $\sqrt{a^2 + \varepsilon} - a$ = {answer}.
:::

::: misses
- [e/(2*a)] That's the slope estimate; the exact δ is a little smaller because the curve bends up.
- [a - sqrt(a^2 - e)] That's the distance to the left crossing; the right side is tighter.
- [any] Not yet. Solve $(a + \delta)^2 = a^2 + \varepsilon$.
:::
:::

::: check
given: k = 2 | 5 | 50; e = 0.01 | 0.001
answer: e/k
tolerance: 0.1%

## $f(x) = \sin(\given{k}x)$ has Lipschitz constant {k}. What δ does that give for ε = {e}, at every point?

::: right
Right. $\varepsilon/L$ = {answer}.
:::

::: misses
- [e] The Lipschitz constant is k, from $\lvert f'\rvert \le k$.
- [any] Not yet. $\delta = \varepsilon/L$.
:::
:::

::: check
given: a = 2 | 3 | 7
answer: a
tolerance: 0.01%

## What's $\lim_{x\to 0}\frac{\sin(\given{a}x)}{x}$?

::: right
Right. {answer}: write it as $a\cdot\frac{\sin(ax)}{ax}$.
:::

::: misses
- [1] That's $\lim\frac{\sin u}{u}$; here u = ax.
- [any] Not yet. Substitute u = ax.
:::
:::

::: check
given: a = 4 | 9 | 25; e = 0.01 | 0.1
answer: e*sqrt(a)
tolerance: 0.1%

## Using $\lvert\sqrt x - \sqrt a\rvert = \frac{\lvert x - a\rvert}{\sqrt x + \sqrt a} \le \frac{\lvert x - a\rvert}{\sqrt a}$, what δ guarantees $\lvert\sqrt x - \sqrt a\rvert < \given{e}$ at a = {a}?

::: right
Right. $\delta = \varepsilon\sqrt a$ = {answer}.
:::

::: misses
- [e/sqrt(a)] Multiply: $\frac{\delta}{\sqrt a} = \varepsilon$ gives $\delta = \varepsilon\sqrt a$.
- [any] Not yet. Make $\frac{\delta}{\sqrt a} \le \varepsilon$.
:::
:::

::: check
kind: choice

## Which function is continuous at 0 (each defined as 0 at x = 0)?

- [ ] $\sin\frac1x$
- [x] $x\sin\frac1x$
- [ ] $\frac{\lvert x\rvert}{x}$
- [ ] $\frac1x$

::: misses
- [1] It oscillates between −1 and 1 near 0.
- [3] It's −1 for x < 0 and 1 for x > 0: a jump.
- [4] It blows up.
:::
:::

::: check
kind: order

## Put the steps of the proof that $x^2$ is continuous at a in order.

1. Let ε > 0.
2. Restrict to $\lvert x - a\rvert < 1$, so $\lvert x + a\rvert < 2\lvert a\rvert + 1$.
3. Then $\lvert x^2 - a^2\rvert = \lvert x - a\rvert\lvert x + a\rvert < (2\lvert a\rvert + 1)\lvert x - a\rvert$.
4. Let $\delta = \min\left(1, \frac{\varepsilon}{2\lvert a\rvert + 1}\right)$.
5. For $\lvert x - a\rvert < \delta$, $\lvert x^2 - a^2\rvert < (2\lvert a\rvert + 1)\delta \le \varepsilon$.

::: right
Right. First tame the factor that varies, then choose δ to handle the rest: the standard move.
:::
:::

::: check
kind: parts
given: a = 1 | 2; e = 0.1 | 0.01

## $f(x) = \frac1x$ at a = {a}, with ε = {e}.

::: part
answer: a^2*e/(1 + a*e)
tolerance: 0.5%

### What is the largest δ that works?

::: misses
- [a^2*e/(1 - a*e)] That's the right-hand side's room; the left side is tighter.
- [any] Solve $\frac1x = \frac1a + \varepsilon$ for the left end.
:::
:::

::: part
answer: e*a^2/4
tolerance: 0.5%

### What δ does the Lipschitz bound $\lvert f'\rvert \le \frac{4}{a^2}$ on $[a/2, \infty)$ give?

::: misses
- [any] $\delta = \varepsilon/L$ with $L = 4/a^2$.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.5..3, e = 0.01..1

## Find the largest δ at a > 0 for a given ε.

::: step
answer: sqrt(a^2 + e) - a

### For $f = x^2$?
:::

::: step
answer: (a^3 + e)^(1/3) - a

### For $f = x^3$?
:::

::: right
Right. For increasing convex functions the right side is tighter, so δ comes from $f(a + \delta) = f(a) + \varepsilon$.
:::
:::

::: explain
## Why does the largest δ for $x^2$ shrink as the point a moves away from 0, and what does that say about sensitivity?

::: model
δ measures how far the input may move before the output moves by ε, so it's roughly ε divided by how fast the function changes there. The slope of $x^2$ is 2a, which grows with a, so near a = 10 an input error is magnified 20 times and δ must be about ε/20, while near 0 a much larger input error is harmless. That's the same as a condition number: a steep function amplifies input errors. Over the whole real line the slope is unbounded, so no single δ serves every point; on a bounded interval the steepest point sets a δ that works everywhere.
:::
:::

::: practice

::: check
given: m = 7 | -0.25; e = 0.07 | 0.002
answer: e/abs(m)
tolerance: 0.1%

## δ for $\given{m}x + 2$, ε = {e}?

::: misses
- [any] $\varepsilon/\lvert m\rvert$.
:::
:::

::: check
given: a = 0.5 | 3; e = 0.2 | 0.02
answer: sqrt(a^2 + e) - a
tolerance: 0.01%

## Largest δ for $x^2$ at {a}, ε = {e}?

::: misses
- [any] $\sqrt{a^2 + \varepsilon} - a$.
:::
:::

::: check
given: k = 3 | 100; e = 0.05 | 0.0004
answer: e/k
tolerance: 0.1%

## δ from the Lipschitz constant of $\sin(\given{k}x)$, ε = {e}?

::: misses
- [any] $\varepsilon/k$.
:::
:::
:::
