---
title: Sequences and geometric series
heading: Infinitely many trips round a loop, and a finite answer
eyebrow: A2 · Lesson 12 · Sequences and geometric series
xp: 40
---

::: hook
Feed a signal into a loop that passes 60% of it back around to the input. The signal goes in, 0.6 of it comes back and adds on, 0.6 of that comes back again, and so on forever. Infinitely many contributions, yet the total settles at exactly 2.5 times the input. Sums like this, where each term is the last one times a fixed ratio, are geometric series. They're behind feedback, echoes on cables, and the binary weights of a digital-to-analog converter.

::: play
- The staircase is the running total after $n$ terms of $a + ar + ar^2 + \cdots$. The dashed line is $a/(1 - r)$.
- Set $r$ to 0.5, then to 0.9. How many terms does it take to get close to the line each time?
- Change $a$. Does it change how fast the staircase closes in?
:::
:::

```sim plot
view: graph
x: n = 0..30
y: S = 0..6
slider: a = 0.5..2 step 0.1 = 1
slider: r = 0.05..0.95 step 0.05 = 0.6
plot: a*(1 - r^floor(n))/(1 - r) | label: sum of n terms
plot: a/(1 - r) | dashed | color: ch2 | label: a/(1 − r)
readout: limit = a/(1 - r) | digits: 4
readout: after 10 terms = a*(1 - r^10)/(1 - r) | digits: 4
```

::: predict
## A loop passes 60% of a signal back to its input, where it adds to the next pass. In total, how many times the input does the signal build up to?

- [ ] 1.6
- [x] 2.5
- [ ] 6
- [ ] It grows without limit

::: reveal
2.5. The total is $1 + 0.6 + 0.6^2 + \cdots = 1/(1 - 0.6) = 2.5$. The terms shrink fast enough that the sum settles. If the loop passed back 100% or more, the terms wouldn't shrink and the signal would grow without limit, which is how oscillators start.
:::
:::

::: nameit
## Sequences

A **sequence** is a list of numbers $a_1, a_2, a_3, \ldots$. Two kinds come up constantly.
- **Arithmetic:** each term adds the same difference $d$. The $n$th term is $a_1 + (n - 1)d$, and the first $n$ terms add to $\frac{n}{2}(a_1 + a_n)$, the number of terms times the average of the first and last.
- **Geometric:** each term multiplies by the same ratio $r$. The $n$th term is $a\,r^{n-1}$.

## Geometric series

Add the first $n$ terms of a geometric sequence:

$$S_n = a + ar + ar^2 + \cdots + ar^{n-1}$$

Multiply by $r$ and subtract; everything cancels except the ends: $S_n - rS_n = a - ar^n$. So

$$S_n = a\,\frac{1 - r^n}{1 - r} \qquad (r \ne 1)$$

When $|r| < 1$, $r^n$ shrinks toward zero as $n$ grows, and the infinite sum settles:

$$a + ar + ar^2 + \cdots = \frac{a}{1 - r} \qquad (|r| < 1)$$

When $|r| \ge 1$ the terms don't shrink, and the sum has no finite value.

**How many terms to get close?** The gap to the limit after $n$ terms is $r^n$ times the limit. To get within 1%, you need $r^n < 0.01$, so $n > \ln 0.01 / \ln r$. With $r = 0.5$ that's 7 terms; with $r = 0.9$, 44.

## In circuits

- **A loop with gain $g$:** a signal that goes round a loop, passing $g$ of itself back each time, totals $1/(1 - g)$ times the input when $|g| < 1$. That's the first view of feedback, which C6 develops.
- **Binary weights:** a digital-to-analog converter adds $\frac{1}{2}, \frac{1}{4}, \frac{1}{8}, \ldots$ of its reference, one term for each bit that's on. With every bit on, $N$ bits give $1 - 2^{-N}$ of the reference, just short of all of it.
:::

::: example
## Find $3 + 1.5 + 0.75 + \cdots$ to five terms, and forever.

::: solution
1. **First term and ratio.** $a = 3$, $r = 0.5$.
2. **Five terms.**
   $$\begin{aligned} S_5 &= 3\,\frac{1 - 0.5^5}{1 - 0.5} \\ &= 3 \times \frac{0.96875}{0.5} \\ &= 5.8125 \end{aligned}$$
3. **Forever.**
   $$\frac{3}{1 - 0.5} = 6$$
4. **Compare.** Five terms are already within $0.5^5 = 3\%$ of the limit.

**Answer:** five terms sum to 5.8125, and the whole series to 6.
:::
:::

::: example
## A digital-to-analog converter has 8 bits and a 2.5 V reference. Its most significant bit adds half the reference, the next a quarter, and so on. What does it put out with every bit on?

::: solution
1. **Name the series.** It's a geometric series with $a = 1.25$ V and $r = \frac{1}{2}$, 8 terms.
2. **Sum it.**
   $$\begin{aligned} S_8 &= 1.25\,\frac{1 - 0.5^8}{1 - 0.5} \\ &= 2.5\,(1 - 0.5^8) \\ &= 2.5 \times \frac{255}{256} \\ &= 2.490\ \text{V} \end{aligned}$$
3. **Compare with the reference.** That's one step (1 LSB) short of the reference: the output can reach $\frac{255}{256}$ of it but never all of it.

**Answer:** with every bit on, it puts out 2.490 V.
:::
:::

::: example
## A digital filter's impulse response is 1, 0.9, 0.81, and so on, each value 0.9 times the last. What's its total, which sets the filter's gain for a steady input? How much of it do the first 20 values hold?

::: solution
1. **Name the series.** It's a geometric series with $a = 1$ and $r = 0.9$.
2. **Total.**
   $$\frac{1}{1 - 0.9} = 10$$
   A steady input of 1 comes out as 10.
3. **First 20 values.**
   $$\frac{1 - 0.9^{20}}{1 - 0.9} = 8.78$$
   about 88% of the total.
4. **What the tail means.** The tail matters: a filter like this takes many samples to settle, and that's the price of its smoothing.

**Answer:** the total is 10, so a steady input comes out 10 times larger, and the first 20 values hold 8.78 of it, about 88%.
:::
:::

::: check
given: a = 2 | 3 | 5; r = 2 | 3 | 0.5; n = 4..7 int
answer: a*r^(n - 1)
tolerance: 0.5%

## A geometric sequence starts at {a} and multiplies by {r} each step. What is its {n}th term?

::: right
Right. $a\,r^{n-1} = \given{a} \times \given{r}^{\given{n} - 1}$ = {answer}.
:::

::: misses
- [a*r^n] Count again: the first term has $r^0$, so the {n}th has $r^{\given{n} - 1}$.
- [a + (n - 1)*r] That's an arithmetic sequence. Here each step multiplies.
- [any] Not yet. Multiply {a} by {r} once for each step after the first.
:::
:::

::: check
given: a = 1 | 3 | 5; r = 2 | 3; n = 5..8 int
answer: a*(1 - r^n)/(1 - r)
tolerance: 0.5%

## What is the sum of the first {n} terms of $\given{a} + \given{a}(\given{r}) + \given{a}(\given{r})^2 + \cdots$?

::: right
Right. $S_n = a(1 - r^n)/(1 - r)$ = {answer}.
:::

::: misses
- [a*(1 - r^(n + 1))/(1 - r)] That's one term too many: {n} terms end at $r^{\given{n} - 1}$.
- [a*r^(n - 1)] That's only the last term. Add them all.
- [any] Not yet. Use $S_n = a\,\dfrac{1 - r^n}{1 - r}$.
:::
:::

::: check
given: a = 1 | 2 | 6; r = 0.25 | 0.8 | 0.9 | -0.5
answer: a/(1 - r)
tolerance: 0.5%

## What is $\given{a} + \given{a}(\given{r}) + \given{a}(\given{r})^2 + \cdots$, forever?

::: right
Right. $|r| < 1$, so the sum is $a/(1 - r)$ = {answer}.
:::

::: misses
- [a/(1 + r)] It's $1 - r$ on the bottom.
- [a*(1 + r)] That's just the first two terms. The rest add more.
- [a/r] Use $a/(1 - r)$.
- [any] Not yet. For $|r| < 1$ the sum is $a/(1 - r)$.
:::
:::

::: check
given: g = 0.5 | 0.75 | 0.8 | 0.9; x = 1 | 2 | 5
answer: x/(1 - g)
tolerance: 0.5%

## A loop passes {g} of a signal back to its input each time round. A steady input of {x} V goes in. What does the signal build up to?

::: right
Right. $\given{x}(1 + g + g^2 + \cdots) = \given{x}/(1 - \given{g})$ = {answer} V.
:::

::: misses
- [x*(1 + g)] That counts only the first trip back. Every trip adds a smaller share.
- [x*g/(1 - g)] That's only the part that came back round. Add the input itself.
- [any] Not yet. Add the input and every share that comes back: a geometric series.
:::
:::

::: check
given: a1 = 100 | 220; d = 10 | 47; n = 10 | 20 | 25
answer: n*(2*a1 + (n - 1)*d)/2
tolerance: 0.5%

## A resistor ladder's sections step up by {d} Ω, starting at {a1} Ω. What do {n} sections add to, in series?

::: right
Right. The last is $\given{a1} + (\given{n} - 1)\given{d}$, and the sum is $n$ times the average of the first and last: {answer} Ω.
:::

::: misses
- [n*a1 + n*d] Each section adds one more {d} than the last, so the steps add up to $d(0 + 1 + \cdots + (n - 1))$.
- [n*(a1 + (n - 1)*d)] That's $n$ times the last section. Use the average of the first and last.
- [any] Not yet. Number of terms times the average of the first and last.
:::
:::

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

## A geometric series has ratio {r}. How many terms until its sum is within 1% of the infinite total?

::: right
Right. The gap after $n$ terms is $r^n$ of the total, and $\given{r}^n < 0.01$ first at $n$ = {answer}.
:::

::: misses
- [floor(ln(0.01)/ln(r))] One short: at that $n$, $r^n$ is still just above 0.01. Round up.
- [any] Not yet. Solve $\given{r}^n < 0.01$ with logarithms.
:::
:::

::: check
kind: parts
given: V = 3.3 | 5 | 12; p = 10 | 20 | 25; n = 3 | 5 | 8

## A capacitor is charged toward {V} V in steps. Each step closes {p}% of the gap that remains, starting from 0 V.

::: part
answer: V*(1 - (1 - p/100)^n)
unit: V
tolerance: 0.5%

### What is its voltage after {n} steps?

::: misses
- [V*p/100*n] The steps shrink, because each closes a share of a smaller gap.
- [V*(1 - p/100)^n] That's the gap that's left.
- [any] The gap shrinks by the factor $1 - \given{p}/100$ each step.
:::
:::

::: part
answer: V*(p/100)*(1 - p/100)^(n - 1)
unit: V
tolerance: 0.5%

### How much does step {n} alone add?

::: misses
- [V*(p/100)*(1 - p/100)^n] That's step $\given{n} + 1$. The first step adds $\given{V} \times \given{p}/100$.
- [any] The terms form a geometric sequence starting at $V \times \given{p}/100$.
:::
:::

::: part
answer: ceil(ln(0.01)/ln(1 - p/100))
tolerance: 0

### After how many steps is it first within 1% of {V} V?

::: misses
- [floor(ln(0.01)/ln(1 - p/100))] One step short: the gap is still a little over 1%.
- [any] The gap after $n$ steps is $(1 - \given{p}/100)^n$ of {V} V. Find the first $n$ with that at most 0.01.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.5..5, r = 0.1..0.9, n = 1..20

## Derive the sum of a geometric series, $S = a + ar + \cdots + ar^{n-1}$.

::: step
answer: a - a*r^n

### Write out $rS$ and subtract it from $S$. Almost every term cancels. What is $S - rS$?

::: misses
- [a - a*r^(n - 1)] The last term of $rS$ is $ar^n$, one power higher than the last term of $S$.
:::
:::

::: step
answer: a*(1 - r^n)/(1 - r)

### Solve for $S$.
:::

::: step
answer: a/(1 - r)

### What does $S$ approach as $n$ grows, for $|r| < 1$?
:::

::: right
Right. Shifting the series by one term and subtracting is the trick behind every geometric sum.
:::
:::

::: explain
## Why does $1 + r + r^2 + \cdots$ settle to a finite value when $|r| < 1$, but not when $r = 1$?

::: model
With $|r| < 1$ each term is a fixed fraction of the one before, so the terms shrink so fast that what's left to add after $n$ terms, $r^n/(1 - r)$, goes to zero. The partial sums close in on $1/(1 - r)$. With $r = 1$ every term is 1, so after $n$ terms the sum is $n$, which keeps growing however far you go.
:::
:::

::: practice

::: check
given: a = 4 | 10 | 64; r = 0.5 | 3; n = 3..6 int
answer: a*r^(n - 1)
tolerance: 0.5%

## What is the {n}th term of a geometric sequence starting at {a} with ratio {r}?

::: misses
- [a*r^n] The first term has $r^0$.
- [any] $a\,r^{n-1}$.
:::
:::

::: check
given: a = 2 | 4; r = 0.5 | 0.8; n = 2..4 int
answer: a*(1 - r^n)/(1 - r)
tolerance: 0.5%

## Add the first {n} terms of $\given{a}, \given{a}(\given{r}), \given{a}(\given{r})^2, \ldots$

::: misses
- [a/(1 - r)] That's the infinite sum. Stop after {n} terms.
- [any] $a(1 - r^n)/(1 - r)$.
:::
:::

::: check
given: a = 3 | 5 | 10; r = 0.2 | 0.6 | -0.4 | 0.75
answer: a/(1 - r)
tolerance: 0.5%

## What is $\given{a} + \given{a}(\given{r}) + \cdots$ forever?

::: misses
- [a/(1 + r)] It's $1 - r$ on the bottom.
- [any] $a/(1 - r)$.
:::
:::

::: check
given: N = 4 | 6 | 8; V = 1 | 2.5 | 5
answer: V*(1 - 2^(-N))
unit: V
tolerance: 0.05%

## A {N}-bit DAC adds half its {V} V reference for the top bit, a quarter for the next, and so on. What does it put out with every bit on?

::: misses
- [V] It never quite reaches the reference: one step short.
- [V*(1 - 2^(-N - 1))] The last bit adds $2^{-\given{N}}$ of the reference, so the sum is $1 - 2^{-\given{N}}$.
- [any] A geometric series: $V(1 - 2^{-N})$.
:::
:::

::: check
given: g = 0.6 | 0.95 | 0.99; x = 0.1 | 1
answer: x/(1 - g)
tolerance: 0.5%

## A loop returns {g} of the signal each time round. An input of {x} builds up to what total?

::: misses
- [x*(1 + g)] Count every trip.
- [any] $x/(1 - g)$.
:::
:::

::: check
given: r = 0.3 | 0.6 | 0.95
answer: ceil(ln(0.001)/ln(r))
tolerance: 0.5

## With ratio {r}, how many terms bring a geometric series within 0.1% of its total?

::: misses
- [floor(ln(0.001)/ln(r))] Round up.
- [any] Solve $r^n < 0.001$.
:::
:::
:::
