---
title: Using series for integrals and limits
heading: Integrating what has no antiderivative
eyebrow: A6 · Lesson 44 · Series at work
xp: 40
---

::: hook
The probability that Gaussian noise pushes a bit across the decision threshold, the bit error rate of every digital radio, comes from the integral of $e^{-x^2}$. That integral has no formula in terms of the functions you know; no amount of substitution or integration by parts will find one. But $e^{-x^2}$ has a power series, and a power series can be integrated one term at a time. That's how the error function is computed, and the same idea evaluates stubborn limits in one line.
:::

::: play
- The blue curve is the area $\int_0^b e^{-x^2}dx$ as $b$ grows, computed exactly. The other curve integrates the first $N$ terms of the series for $e^{-x^2}$.
- With 2 terms the series is good near 0 and wanders off past $b \approx 0.7$. Add terms and watch the good range grow.
- Read off how many terms give 4 correct decimals at $b = 1$.
:::
:::

```sim plot
view: graph
x: b = 0..2.5
y: area = -0.5..1.5
slider: N = 1..5 step 1 = 2
slider: b0 = 0.1..2.5 step 0.1 = 1
plot: sqrt(pi)/2*erf(b) | label: exact area
plot: b - step(N - 1.5)*b^3/3 + step(N - 2.5)*b^5/10 - step(N - 3.5)*b^7/42 + step(N - 4.5)*b^9/216 | label: N terms | color: ch2 | samples: 600
marker: x = b0 | label: b
readout: exact = sqrt(pi)/2*erf(b0) | digits: 6
readout: series = b0 - step(N - 1.5)*b0^3/3 + step(N - 2.5)*b0^5/10 - step(N - 3.5)*b0^7/42 + step(N - 4.5)*b0^9/216 | digits: 6
```

::: predict
## The series for $e^{-x^2}$ is $1 - x^2 + \frac{x^4}{2!} - \frac{x^6}{3!} + \cdots$. What is the series for $\int_0^1 e^{-x^2}dx$?

- [x] $1 - \frac{1}{3} + \frac{1}{5 \cdot 2!} - \frac{1}{7 \cdot 3!} + \cdots$
- [ ] $1 - 1 + \frac{1}{2!} - \frac{1}{3!} + \cdots$
- [ ] $1 - \frac{2}{3} + \frac{4}{5 \cdot 2!} - \cdots$
- [ ] There isn't one, since $e^{-x^2}$ has no antiderivative

::: reveal
Integrate each term: $\int_0^1 x^{2n}dx = \frac{1}{2n + 1}$, so the integral is $\sum\frac{(-1)^n}{(2n + 1)\,n!}$. The function has no elementary antiderivative, but its series does, and five terms give 0.7475 against the true 0.7468.
:::
:::

::: nameit
## Integrating with series

Inside the radius of convergence, integrate term by term:

$$\int_0^b e^{-x^2}dx = \sum_{n=0}^\infty\frac{(-1)^nb^{2n+1}}{(2n + 1)\,n!} = b - \frac{b^3}{3} + \frac{b^5}{10} - \frac{b^7}{42} + \cdots$$

The series for $e^{-x^2}$ converges everywhere, so this works for every $b$, though large $b$ needs many terms. Engineers use this through the **error function**, $\text{erf}(b) = \frac{2}{\sqrt\pi}\int_0^b e^{-x^2}dx$, and the Gaussian tail $Q(x)$ built from it (A11, S8).

Other integrals done this way: the sine integral $\int_0^b\frac{\sin x}{x}dx$ (filter design and the Gibbs overshoot), and the Fresnel integrals $\int\cos(x^2)\,dx$ (diffraction, B8).

When the series alternates, the alternating series bound gives the error for free.

## Limits with series

Substitute series and the leading terms cancel, leaving the answer:

$$\lim_{x\to 0}\frac{\sin x - x}{x^3} = \lim_{x\to 0}\frac{(x - \frac{x^3}{6} + \frac{x^5}{120} - \cdots) - x}{x^3} = -\frac{1}{6}$$

This is often faster than L'Hôpital's rule, which here would need three rounds.

## Recognizing series

Sometimes a series is a known function in disguise: $\sum\frac{x^n}{n!} = e^x$, $\sum\frac{(-1)^nx^{2n}}{(2n)!} = \cos x$, $\sum\frac{(-1)^{n+1}}{n} = \ln 2$. Matching the pattern of the coefficients finds the sum.
:::

::: example
## Estimate $\int_0^1 e^{-x^2}dx$ with five terms, and bound the error.

::: solution
1. **Add five terms.**
   $$\begin{aligned} &1 - \frac{1}{3} + \frac{1}{10} - \frac{1}{42} + \frac{1}{216} \\ &= 1 - 0.333333 + 0.1 \\ &\quad - 0.023810 + 0.004630 \\ &= 0.747487 \end{aligned}$$
2. **Bound the error.** The series alternates, so the error is less than the next term:
   $$\begin{aligned} \frac{1}{11 \cdot 5!} &= \frac{1}{1320} \\ &= 0.00076 \end{aligned}$$
3. **Compare.** The true value is 0.746824, off by 0.00066.

**Answer:** five terms give 0.747487, with an error under 0.00076; the true value is 0.746824.
:::
:::

::: example
## Find $\displaystyle\lim_{x\to 0}\frac{e^x - 1 - x}{x^2}$.

::: solution
1. **Expand the numerator.**
   $$e^x - 1 - x = \frac{x^2}{2} + \frac{x^3}{6} + \cdots$$
2. **Divide by $x^2$.**
   $$\frac{e^x - 1 - x}{x^2} = \frac{1}{2} + \frac{x}{6} + \cdots$$
   which tends to $\frac{1}{2}$.

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

::: example
## Estimate $\displaystyle\int_0^{0.5}\frac{\sin x}{x}\,dx$ with three terms of a series.

::: solution
1. **Divide the sine series by $x$.**
   $$\frac{\sin x}{x} = 1 - \frac{x^2}{6} + \frac{x^4}{120} - \cdots$$
2. **Integrate term by term.** The integral is $x - \frac{x^3}{18} + \frac{x^5}{600}$, which at $x = 0.5$ is
   $$\begin{aligned} &0.5 - 0.006\,944 + 0.000\,052 \\ &= 0.493\,11 \end{aligned}$$
3. **Bound the error.** The series alternates, so the next term bounds the error:
   $$\frac{x^7}{35\,280} \approx 2 \times 10^{-7}$$

**Answer:** the integral is about 0.493 11, with an error below about $2 \times 10^{-7}$.
:::
:::

::: check
given: b = 0.2 | 0.4 | 0.5 | 0.6 | 0.8 | 1
answer: b - b^3/18 + b^5/600
tolerance: 0.001%

## Estimate $\displaystyle\int_0^{\given{b}}\frac{\sin x}{x}\,dx$ with three terms of its series.

::: right
Right. $\frac{\sin x}{x} = 1 - \frac{x^2}{6} + \frac{x^4}{120} - \cdots$; integrating gives $b - \frac{b^3}{18} + \frac{b^5}{600}$ = {answer}.
:::

::: misses
- [b - b^3/6 + b^5/120] That's $\sin b$. Divide by $x$ first, then integrate.
- [any] Not yet. Divide the sine series by $x$, then integrate each term.
:::
:::

::: check
given: k = 2 | 3 | 4
answer: -k^3/6
tolerance: 0.5%

## Find $\displaystyle\lim_{x\to 0}\frac{\sin(\given{k}x) - \given{k}x}{x^3}$.

::: right
Right. $\sin(kx) - kx = -\frac{(kx)^3}{6} + \cdots$, so the limit is $-\frac{k^3}{6}$ = {answer}.
:::

::: misses
- [k^3/6] Check the sign: the series for sine subtracts $\frac{x^3}{6}$.
- [-1/6] The cubic term is $\frac{(kx)^3}{6}$: the $k$ is cubed too.
- [any] Not yet. Substitute the sine series.
:::
:::

::: check
given: k = 2 | 3 | 4
answer: k^2/2

## Find $\displaystyle\lim_{x\to 0}\frac{e^{\given{k}x} - 1 - \given{k}x}{x^2}$.

::: right
Right. The first surviving term is $\frac{(kx)^2}{2}$, so the limit is {answer}.
:::

::: misses
- [k/2] The square term is $\frac{(kx)^2}{2}$, with $k^2$.
- [1/2] Include the {k} in each power.
- [any] Not yet. Substitute the series for $e^{kx}$.
:::
:::

::: check
given: b = 0.2 | 0.3 | 0.1
answer: b - b^3/3
tolerance: 0.001%

## Estimate $\displaystyle\int_0^{\given{b}}e^{-x^2}dx$ with two terms.

::: right
Right. $b - \frac{b^3}{3}$ = {answer}, good to about $\frac{b^5}{10}$.
:::

::: misses
- [b - b^3] Integrating $x^2$ gives $\frac{x^3}{3}$.
- [any] Not yet. Integrate $1 - x^2$.
:::
:::

::: check
given: b = 0.2 | 0.4 | 0.5 | 0.6 | 0.8 | 1
answer: b - b^5/10 + b^9/216
tolerance: 0.001%

## Estimate $\displaystyle\int_0^{\given{b}}\cos(x^2)\,dx$ with three terms.

::: right
Right. $\cos(x^2) = 1 - \frac{x^4}{2} + \frac{x^8}{24} - \cdots$, which integrates to $b - \frac{b^5}{10} + \frac{b^9}{216}$ = {answer}.
:::

::: misses
- [b - b^3/6 + b^5/120] That integrates $\cos x$'s pattern with the wrong powers. Put $x^2$ into the cosine series first.
- [any] Not yet. Substitute $x^2$ for $u$ in $1 - \frac{u^2}{2} + \frac{u^4}{24}$, then integrate.
:::
:::

::: check
given: x = 1 | 2 | 0.5
answer: cos(x)
tolerance: 0.5%

## What is $1 - \dfrac{x^2}{2!} + \dfrac{x^4}{4!} - \dfrac{x^6}{6!} + \cdots$ at $x$ = {x}?

::: right
Right. It's the cosine series: $\cos\given{x}$ = {answer}.
:::

::: misses
- [sin(x)] Even powers and even factorials make the cosine.
- [exp(-x^2)] The denominators are $(2n)!$, not $n!$, so it's not $e^{-x^2}$.
- [any] Not yet. Which function has this series?
:::
:::

::: check
kind: parts
given: b = 0.2 | 0.4 | 0.5 | 0.6 | 0.8 | 1

## Estimate $\displaystyle\int_0^{\given{b}}\frac{\sin x}{x}\,dx$ with series.

::: part
answer: b - b^3/18 + b^5/600
tolerance: 0.01%

### What do three terms give?

::: misses
- [any] Integrate $1 - \frac{x^2}{6} + \frac{x^4}{120}$.
:::
:::

::: part
answer: b^7/35280
tolerance: 0.5%

### What bounds the error?

::: misses
- [any] The next term, $\frac{x^7}{7 \cdot 7!}$.
:::
:::
:::

::: check
kind: derivation
vars: x = -1..1

## Find $\displaystyle\lim_{x \to 0}\frac{1 - \cos x}{x^2}$ with a series.

::: step
answer: x^2/2 - x^4/24

### Write $1 - \cos x$ with two terms of its series.
:::

::: step
answer: 1/2 - x^2/24

### Divide by $x^2$.
:::

::: step
answer: 1/2

### Let $x \to 0$.
:::

::: right
Right. The limit is ½, with no L'Hôpital needed.
:::
:::

::: explain
## $e^{-x^2}$ has no antiderivative made of familiar functions. How can a series still find $\int_0^1 e^{-x^2}dx$ to any accuracy you want?

::: model
Write $e^{-x^2}$ as its power series, $1 - x^2 + \frac{x^4}{2!} - \cdots$, which converges for every $x$. Each term is a power of $x$, and powers are easy to integrate, so integrating term by term turns the integral into a series of numbers, $1 - \frac{1}{3} + \frac{1}{10} - \cdots$. That series alternates with shrinking terms, so you can stop once the next term is smaller than the accuracy you need. No closed-form antiderivative is required, only the series.
:::
:::

::: practice

::: check
given: k = 2..9 int
answer: -k^2/2

## Find $\displaystyle\lim_{x\to 0}\frac{\cos(\given{k}x) - 1}{x^2}$.

::: misses
- [k^2/2] Check the sign.
- [any] $\cos u - 1 = -\frac{u^2}{2} + \cdots$.
:::
:::

::: check
given: b = 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.8
answer: b - b^3/3 + b^5/10
tolerance: 0.001%

## Estimate $\displaystyle\int_0^{\given{b}}e^{-x^2}dx$ with three terms.

::: misses
- [any] $b - \frac{b^3}{3} + \frac{b^5}{10}$.
:::
:::

::: check
given: x = 0.5 | 1 | 1.5 | 2 | 2.5 | 3
answer: exp(x)
tolerance: 0.5%

## What is $\displaystyle\sum_{n=0}^\infty\frac{(\given{x})^n}{n!}$?

::: misses
- [any] The series for $e^x$.
:::
:::
:::
