---
title: Sequences and their limits
heading: Does it settle down?
eyebrow: A6 · Lesson 22 · Sequences
xp: 40
---

::: hook
A digital filter produces one output number per sample. Newton's method produces one better guess per step. A feedback loop in a microcontroller updates once per tick. Each makes a **sequence**, an endless list of numbers, and the engineering question is always the same: does it settle to a final value, how fast, and does it overshoot on the way? This lesson makes "settles" precise and gives you the standard sequences to compare against.
:::

::: play
- A simple digital filter, $y_n = r\,y_{n-1} + (1 - r)$, starts at $y_0 = 0$ and is fed a constant 1. Its outputs are $y_n = 1 - r^n$.
- Slide $r$ between 0 and 1. How does the speed of settling change?
- Now make $r$ negative. What changes? What happens as $|r|$ approaches 1?
:::
:::

```sim plot
view: graph
x: n = 0..20
y: y = -0.2..2
slider: r = -0.95..0.95 step 0.05 = 0.7
plot: 1 - r^floor(n) | label: yₙ | samples: 800
plot: 1 | label: final value | color: ch3
readout: y after 10 samples = 1 - r^10 | digits: 5
readout: samples to settle within 1% = ceil(ln(0.01)/ln(abs(r) + 1e-9)) | digits: 3
```

::: predict
## The filter has $r = 0.9$. About how many samples does it take to get within 1% of its final value?

- [ ] About 10
- [ ] About 20
- [x] About 44
- [ ] About 100

::: reveal
About 44. The gap to the final value is $0.9^n$, and $0.9^n < 0.01$ needs $n > \frac{\ln 0.01}{\ln 0.9} = 43.7$. With $r = 0.5$ it takes only 7 samples. The closer $r$ is to 1, the slower the filter settles, which is the price of smoothing out more noise.
:::
:::

::: nameit
## The limit of a sequence

A sequence $a_1, a_2, a_3, \ldots$ **converges** to $L$ if its terms get and stay as close to $L$ as you like: for every tolerance $\varepsilon > 0$ there's a point $N$ after which every $a_n$ is within $\varepsilon$ of $L$. We write $\lim_{n\to\infty}a_n = L$. A sequence that doesn't converge **diverges**, by growing without bound like $n^2$ or by never settling like $(-1)^n$.

All the limit laws from A5 carry over. For ratios of polynomials, divide top and bottom by the highest power of $n$.

## Standard limits

| Sequence | Limit |
|---|---|
| $r^n$ | 0 if $\lvert r\rvert < 1$; 1 if $r = 1$; diverges otherwise |
| $\frac{n^k}{a^n}$, $a > 1$ | 0 (exponentials beat powers) |
| $\frac{\ln n}{n^p}$, $p > 0$ | 0 (powers beat logarithms) |
| $\frac{a^n}{n!}$ | 0 (factorials beat exponentials) |
| $\left(1 + \frac{x}{n}\right)^n$ | $e^x$ |
| $n^{1/n}$ | 1 |

## Two tools

**Monotone and bounded:** a sequence that only increases and never passes some ceiling must converge. That's how you know an iteration settles even before you know where.

**Fixed points:** if $a_{n+1} = g(a_n)$ converges, its limit $L$ satisfies $L = g(L)$. It converges to $L$ when $|g'(L)| < 1$; the filter above has $g(y) = ry + (1 - r)$, so $g' = r$, which is exactly the condition $|r| < 1$ for a stable filter.
:::

::: example
## Find $\displaystyle\lim_{n\to\infty}\frac{3n^2 + 1}{2n^2 - n}$.

::: solution
1. **Divide top and bottom by $n^2$.**
   $$\frac{3n^2 + 1}{2n^2 - n} = \frac{3 + 1/n^2}{2 - 1/n}$$
2. **Let $n \to \infty$.** The small terms vanish, leaving $\frac{3}{2}$.

**Answer:** the limit is $\frac{3}{2}$.
:::
:::

::: example
## Iterate $a_{n+1} = \frac{1}{2}\left(a_n + \frac{2}{a_n}\right)$ from $a_0 = 1$. Where does it go?

::: solution
1. **Iterate.**
   $$\begin{aligned} a_1 &= 1.5 \\ a_2 &= 1.41667 \\ a_3 &= 1.414216 \end{aligned}$$
   and $\sqrt{2} = 1.414214$.
2. **Find the limit.** If the limit is $L$, then
   $$L = \frac{1}{2}\left(L + \frac{2}{L}\right) \quad\text{so}\quad L^2 = 2$$
3. **Recognize the method.** This is Newton's method for $\sqrt 2$, and the number of correct digits roughly doubles each step.

**Answer:** it goes to $\sqrt 2 = 1.414214$.
:::
:::

::: example
## What does $\left(1 + \frac1n\right)^n$ approach as $n$ grows? Compute it at $n$ = 100.

::: solution
1. **Evaluate at $n = 100$.**
   $$1.01^{100} = 2.7048$$
2. **Take logs.** Since $\ln(1 + x) \approx x$,
   $$n\ln(1 + 1/n) \to 1$$
   so the sequence approaches $e^1 = 2.718\,28$.
3. **Interpret.** This is compound interest with ever more frequent compounding, and it's one way to define $e$.

**Answer:** it approaches $e = 2.718\,28$; at $n$ = 100 it's 2.7048.
:::
:::

::: check
given: a = 2 | 3 | 5; b = 4 | 7
answer: a/b
tolerance: 0.5%

## Find $\displaystyle\lim_{n\to\infty}\frac{\given{a}n^2 + 1}{\given{b}n^2 + n}$.

::: right
Right. Dividing by $n^2$ leaves $\frac{\given{a}}{\given{b}}$ = {answer}.
:::

::: misses
- [0] Top and bottom grow at the same rate, $n^2$.
- [b/a] Upside down.
- [any] Not yet. Divide top and bottom by $n^2$.
:::
:::

::: check
given: r = 0.5 | 0.8 | 0.9; n = 5 | 10
answer: 1 - r^n
tolerance: 0.02%

## The filter $y_n = \given{r}y_{n-1} + (1 - \given{r})$ starts at 0 with a constant input of 1. What is $y_{\given{n}}$?

::: right
Right. $1 - r^n$ = {answer}.
:::

::: misses
- [r^n] That's the remaining gap. The output is $1 - r^n$.
- [1 - r^(n - 1)] $y_1 = 1 - r$, so the exponent matches the index.
- [any] Not yet. Work out $y_1$ and $y_2$ and spot the pattern.
:::
:::

::: check
given: r = 0.5 | 0.8 | 0.9
answer: ceil(ln(0.01)/ln(r))

## For that filter with $r$ = {r}, how many samples until the output is within 1% of its final value?

::: right
Right. $r^n < 0.01$ needs $n > \frac{\ln 0.01}{\ln r}$, so {answer} samples.
:::

::: misses
- [floor(ln(0.01)/ln(r))] One short: round up so the gap is actually below 1%.
- [any] Not yet. Solve $r^n < 0.01$ with logarithms.
:::
:::

::: check
given: a = 1 | 2 | 3; b = 0.5 | 0.75
answer: a/(1 - b)

## The iteration $x_{n+1} = \given{a} + \given{b}x_n$ converges. To what?

::: right
Right. The limit satisfies $L = a + bL$, so $L = \frac{a}{1 - b}$ = {answer}.
:::

::: misses
- [a/(1 + b)] Check the algebra: $L - bL = a$.
- [a] That's only the first step from zero.
- [any] Not yet. Set $L = a + bL$ and solve.
:::
:::

::: check
given: k = 2 | 3 | 0.5
answer: exp(k)
tolerance: 0.5%

## Find $\displaystyle\lim_{n\to\infty}\left(1 + \frac{\given{k}}{n}\right)^n$.

::: right
Right. $e^{\given{k}}$ = {answer}. It's the limit that defines continuous compounding, and the exponential itself.
:::

::: misses
- [1] $1^\infty$ is indeterminate: the base approaches 1 but the power grows.
- [any] Not yet. This is the standard limit $e^x$.
:::
:::

::: check
kind: choice

## Which sequence converges to zero?

- [ ] $\frac{n}{n + 1}$
- [ ] $(-1)^n$
- [x] $\frac{n^{10}}{2^n}$
- [ ] $\ln n$

::: right
Right. Exponentials beat powers: $2^n$ outgrows $n^{10}$ in the end, though $n^{10}$ is ahead for a long while (until about $n = 59$).
:::

::: misses
- [1] That one approaches 1.
- [2] It flips between −1 and 1 forever, so it doesn't converge at all.
- [4] It grows without limit, slowly.
- [any] Compare growth rates.
:::
:::

::: check
kind: parts
given: k = 1 | 2 | 3; n = 100 | 1000

## Consider $\left(1 + \frac{\given{k}}{n}\right)^n$.

::: part
answer: (1 + k/n)^n
tolerance: 0.01%

### What is it at $n$ = {n}?

::: misses
- [any] Compute it.
:::
:::

::: part
answer: exp(k)
tolerance: 0.01%

### What is its limit as $n \to \infty$?

::: misses
- [any] $n\ln(1 + k/n) \to k$.
:::
:::
:::

::: check
kind: derivation
vars: k = 0.5..3, n = 10..1000

## Find the limit of $\left(1 + \frac kn\right)^n$.

::: step
answer: n*ln(1 + k/n)

### Take the natural log of the sequence.
:::

::: step
answer: k

### Use $\ln(1 + u) \approx u$ for small $u$: what does the log approach?
:::

::: right
Right. The log approaches $k$, so the sequence approaches $e^k$.
:::
:::

::: explain
## Why does the filter $y_n = ry_{n-1} + (1 - r)$ settle only when $|r| < 1$?

::: model
The gap between the output and its final value 1 gets multiplied by $r$ every sample, so after $n$ samples it's $r^n$ times the starting gap. If $|r| < 1$, repeated multiplication shrinks it toward zero and the output settles; with negative $r$ the gap flips sign each time, so the output overshoots and undershoots while closing in. If $|r| > 1$ the gap grows every sample and the output runs away, which is an unstable filter.
:::
:::

::: practice

::: check
given: a = 4 | 9 | 16
answer: sqrt(a)
tolerance: 0.5%

## The iteration $x_{n+1} = \frac{1}{2}\left(x_n + \frac{\given{a}}{x_n}\right)$ converges from $x_0 = 1$. To what?

::: misses
- [any] Solve $L = \frac{1}{2}(L + a/L)$.
:::
:::

::: check
given: a = 3 | 6; b = 2 | 5
answer: a/b
tolerance: 0.5%

## Find $\displaystyle\lim_{n\to\infty}\frac{\given{a}n^3 - n}{\given{b}n^3 + 4}$.

::: misses
- [any] Divide by $n^3$.
:::
:::

::: check
given: r = -0.2 | -0.4 | -0.5 | -0.6 | -0.8 | -0.9
answer: 1 - r^3
tolerance: 0.5%

## The filter above with $r$ = {r} starts at 0. What is $y_3$?

::: misses
- [1 + r^3] $y_3 = 1 - r^3$, and $r^3$ is negative here.
- [any] $1 - r^n$ with $n = 3$.
:::
:::
:::
