---
title: The integral and comparison tests
heading: Does the sum stay finite?
eyebrow: A6 · Lesson 26 · Convergence tests
xp: 40
---

::: hook
The power in a square wave is spread over its harmonics, with the $n$th harmonic carrying power proportional to $1/n^2$. Does the total come out finite? The harmonics of a sawtooth's amplitude fall as $1/n$; does that sum stay finite too? Terms shrinking to zero isn't enough: $1 + \frac{1}{2} + \frac{1}{3} + \cdots$ grows forever. This lesson gives you tests that decide, by comparing a sum with an integral or with a series you already understand.
:::

::: play
- The curve is $1/x^p$. Each bar has height $1/n^p$ and width 1, so the bars' total area is the series $\sum 1/n^p$.
- The bars sit above the curve, so the series is bigger than the integral; slide each bar one step left and they sit under it. The readouts are the bounds this gives.
- Move $p$ toward 1. What happens to both bounds?
:::
:::

```sim plot
view: graph
x: x = 1..12
y: y = 0..1.1
slider: p = 1.05..3 step 0.05 = 2
plot: 1/x^p | label: 1/xᵖ
plot: 1/floor(x)^p | label: terms 1/nᵖ | color: ch2 | samples: 1200
readout: the sum is at least = 1/(p - 1) | digits: 4
readout: the sum is at most = 1 + 1/(p - 1) | digits: 4
```

::: predict
## The harmonic series $1 + \frac{1}{2} + \frac{1}{3} + \cdots$ grows forever. Roughly how many terms does it take to pass 10?

- [ ] About 100
- [ ] About 1000
- [x] About 12 000
- [ ] About a million

::: reveal
About 12 000. The partial sums grow like $\ln N + 0.577$, so passing 10 needs $\ln N \approx 9.42$, or $N \approx 12\,400$. Passing 20 would take about 270 million terms. It does grow without limit, but so slowly you'd never notice by adding terms on a calculator.
:::
:::

::: nameit
## First, the divergence test

If the terms $a_n$ don't approach 0, the series diverges. The converse is false: the harmonic series has terms approaching 0 and still diverges.

## The integral test

If $f(x)$ is positive and decreasing for $x \ge 1$, then $\sum_{n=1}^\infty f(n)$ and $\int_1^\infty f(x)\,dx$ either both converge or both diverge. The bars in the sim show why, and they also give bounds:

$$\int_1^\infty f(x)\,dx \;\le\; \sum_{n=1}^\infty f(n) \;\le\; f(1) + \int_1^\infty f(x)\,dx$$

After adding the first $N$ terms, the rest (the **tail**) lies between $\int_{N+1}^\infty f$ and $\int_N^\infty f$.

## p-series

$\sum\frac{1}{n^p}$ converges when $p > 1$ and diverges when $p \le 1$, because $\int_1^\infty x^{-p}dx$ does. These are the standard yardsticks.

## Comparison

If $0 \le a_n \le b_n$ and $\sum b_n$ converges, so does $\sum a_n$. If $a_n \ge b_n \ge 0$ and $\sum b_n$ diverges, so does $\sum a_n$.

**Limit comparison** is easier to use: if $a_n/b_n \to c$ with $0 < c < \infty$, the two series behave the same way. Compare a messy term with its leading behavior: $\frac{2n + 1}{n^3 + 5}$ behaves like $\frac{2}{n^2}$, so its series converges.
:::

::: example
## Pin down $\sum_{n=1}^\infty\frac{1}{n^2}$ using ten terms and the integral bounds.

::: solution
1. **Add ten terms.** The first ten terms add to 1.54977.
2. **Bound the tail.** The tail lies between these two integrals:
   $$\begin{aligned} \int_{11}^\infty\frac{dx}{x^2} &= \frac{1}{11} \\ &= 0.0909 \\ \int_{10}^\infty\frac{dx}{x^2} &= 0.1 \end{aligned}$$
3. **Add the tail to the ten terms.** The sum is between 1.64068 and 1.64977.
4. **Compare with the exact value.** The exact value is $\frac{\pi^2}{6} = 1.64493$. Ten terms plus two easy integrals already give it to within 0.005.

**Answer:** the sum lies between 1.64068 and 1.64977, around the exact $\frac{\pi^2}{6} = 1.64493$.
:::
:::

::: example
## Does $\sum\frac{n}{n^2 + 1}$ converge?

::: solution
1. **Find what the term looks like.** For large $n$ the term behaves like $\frac{n}{n^2} = \frac{1}{n}$.
2. **Limit comparison.**
   $$\frac{n/(n^2 + 1)}{1/n} = \frac{n^2}{n^2 + 1} \to 1$$
3. **Conclude.** Since $\sum\frac{1}{n}$ diverges, so does this series.

**Answer:** no, it diverges, as the harmonic series does.
:::
:::

::: example
## $\sum 1/n^{1.1}$ converges. How much does it still owe after 1000 terms?

::: solution
1. **Bound the tail.** By the integral test, the tail after $N$ terms is at most
   $$\int_N^\infty x^{-1.1}\,dx = \frac{N^{-0.1}}{0.1}$$
2. **Evaluate at $N = 1000$.**
   $$10 \times 1000^{-0.1} = 5.01$$
3. **Interpret.** The series converges, but so slowly that a thousand terms leave a tail of about 5: convergence alone says nothing about usefulness.

**Answer:** after 1000 terms it still owes about 5 (at most 5.01).
:::
:::

::: check
given: p = 3 | 4 | 5; N = 10 | 100
answer: N^(1 - p)/(p - 1)
tolerance: 0.5%

## After adding the first {N} terms of $\sum 1/n^{\given{p}}$, the tail is at most $\int_{\given{N}}^\infty x^{-\given{p}}dx$. What is that bound?

::: right
Right. $\frac{N^{1-p}}{p - 1}$ = {answer}.
:::

::: misses
- [N^(1 - p)] Divide by $p - 1$.
- [N^(-p)] That's the size of the $N$th term. The tail adds up all the terms after it.
- [any] Not yet. $\int_N^\infty x^{-p}dx = \frac{N^{1-p}}{p - 1}$.
:::
:::

::: check
given: p = 2 | 3 | 1.5
answer: 1 + 1/(p - 1)
tolerance: 0.5%

## Use the integral test to give an upper bound for $\sum_{n=1}^\infty 1/n^{\given{p}}$.

::: right
Right. $f(1) + \int_1^\infty x^{-p}dx = 1 + \frac{1}{p - 1}$ = {answer}.
:::

::: misses
- [1/(p - 1)] That's the lower bound. Add the first term.
- [any] Not yet. The sum is at most $f(1) + \int_1^\infty f$.
:::
:::

::: check
given: N = 100 | 1000 | 1000000
answer: ln(N) + 0.5772
tolerance: 1%

## The partial sums of the harmonic series grow like $\ln N + 0.5772$. Estimate $1 + \frac{1}{2} + \cdots + \frac{1}{\given{N}}$.

::: right
Right. About {answer}: even a million terms add up to less than 15.
:::

::: misses
- [ln(N)] Add Euler's constant, 0.5772.
- [log(N) + 0.5772] Use the natural logarithm.
- [any] Not yet. $\ln N + 0.5772$.
:::
:::

::: check
kind: choice

## Which series converges?

- [ ] $\sum\frac{1}{\sqrt{n}}$
- [ ] $\sum\frac{1}{n}$
- [x] $\sum\frac{1}{n^{1.1}}$
- [ ] $\sum\frac{n}{n + 1}$

::: right
Right. A p-series with $p = 1.1 > 1$ converges, though slowly.
:::

::: misses
- [1] $p = \frac{1}{2} \le 1$: it diverges.
- [2] The harmonic series, $p = 1$, diverges.
- [4] Its terms approach 1, not 0.
- [any] Look for $p > 1$.
:::
:::

::: check
kind: choice

## Does $\sum\dfrac{2n + 1}{n^3 + 5}$ converge?

- [x] Yes: it behaves like $\sum\frac{2}{n^2}$
- [ ] No: it behaves like $\sum\frac{2}{n}$
- [ ] No: the terms don't approach zero
- [ ] Yes: every series with shrinking terms converges

::: right
Right. The leading terms give $\frac{2n}{n^3} = \frac{2}{n^2}$, and limit comparison with a convergent p-series settles it.
:::

::: misses
- [2] Keep the leading power of the denominator, $n^3$.
- [3] The terms do approach zero.
- [4] Shrinking terms aren't enough: the harmonic series is the counterexample.
- [any] Compare with the leading behavior.
:::
:::

::: check
given: eps = 0.01 | 0.001 | 0.0001
answer: 1/eps

## How many terms of $\sum 1/n^2$ make the tail bound $\int_N^\infty x^{-2}dx$ smaller than {eps}?

::: right
Right. $\frac{1}{N} \le \varepsilon$ needs $N = 1/\varepsilon$ = {answer}.
:::

::: misses
- [sqrt(1/eps)] The tail is $\frac{1}{N}$, not $\frac{1}{N^2}$: the integral adds up all the terms after $N$.
- [any] Not yet. Solve $\frac{1}{N} = \varepsilon$.
:::
:::

::: check
kind: parts
given: p = 1.1 | 1.5 | 2; N = 100 | 1000

## Bound the tail of $\sum 1/n^{\given{p}}$ after {N} terms.

::: part
answer: N^(1 - p)/(p - 1)
tolerance: 0.5%

### What is the integral test's upper bound on the tail?

::: misses
- [any] $\int_N^\infty x^{-p}dx$.
:::
:::

::: part
answer: (N + 1)^(1 - p)/(p - 1)
tolerance: 0.5%

### What is its lower bound?

::: misses
- [any] $\int_{N+1}^\infty x^{-p}dx$.
:::
:::
:::

::: check
kind: derivation
vars: N = 10..1000

## Estimate the harmonic sum $H_N = \sum_{n=1}^N\frac1n$.

::: step
answer: ln(N)

### What is $\int_1^N\frac{dx}{x}$?
:::

::: step
answer: ln(N) + 0.5772

### $H_N$ minus that integral settles to Euler's constant, 0.5772. Write the approximation.
:::

::: right
Right. $H_N \approx \ln N + 0.5772$: it grows, but only logarithmically.
:::
:::

::: explain
## The terms of the harmonic series shrink to zero. Why does it still diverge?

::: model
Shrinking terms are necessary but not enough; what matters is how fast they shrink. Group the harmonic series as $1 + \frac{1}{2} + (\frac{1}{3} + \frac{1}{4}) + (\frac{1}{5} + \cdots + \frac{1}{8}) + \cdots$. Each group has twice as many terms as the last, each at least half the group's first term, so each group adds at least $\frac{1}{2}$. Adding $\frac{1}{2}$ infinitely many times grows without limit. The integral test says the same thing: $\int_1^N\frac{dx}{x} = \ln N$ grows forever.
:::
:::

::: practice

::: check
given: p = 2..8 int
answer: 1/(p - 1)
tolerance: 0.5%

## Give the integral test's lower bound for $\sum_{n=1}^\infty 1/n^{\given{p}}$.

::: misses
- [1 + 1/(p - 1)] That's the upper bound.
- [any] $\int_1^\infty x^{-p}dx$.
:::
:::

::: check
kind: choice

## Does $\sum\dfrac{1}{n\ln n}$, from $n = 2$, converge?

- [ ] Yes, since $n\ln n$ grows faster than $n$
- [x] No: $\int\frac{dx}{x\ln x} = \ln(\ln x)$, which grows without limit
- [ ] Yes, by comparison with $\sum\frac{1}{n^2}$
- [ ] It can't be decided

::: misses
- [1] Faster than $n$ isn't enough; it has to beat $n^p$ for some $p > 1$.
- [any] Use the integral test with $u = \ln x$.
:::
:::

::: check
given: k = 2..9 int
answer: k
tolerance: 0.5%

## The term $\dfrac{\given{k}n^2 + 1}{n^4}$ is compared with $\frac{1}{n^2}$. What is the limit of their ratio?

::: misses
- [any] $\frac{(kn^2 + 1)/n^4}{1/n^2}$.
:::
:::
:::
