---
title: Improper integrals
heading: Infinite ranges and singular integrands, and when they converge
eyebrow: A14 · Lesson 20 · Improper integrals
xp: 40
---

::: hook
The Riemann integral of lesson 17 needs a bounded function on a bounded interval. Engineering integrals break both rules constantly: the energy of a decaying pulse integrates to infinity in time, a Laplace transform integrates from 0 to ∞, and the field of a line charge has an integrand that blows up at the wire. **Improper integrals** handle these as limits of ordinary ones. The key question is whether the limit exists, and the answer, like the answer for series in lesson 5, comes from comparison with powers.
:::

::: play
- The curve is $x^{-p}$ on $[1, b]$, and the readout is its integral, $\frac{1 - b^{1-p}}{p - 1}$.
- Slide b toward the right. With p > 1 the integral levels off at $\frac{1}{p - 1}$; with p ≤ 1 it keeps growing, like ln b at p = 1.
- The dividing line, p = 1, is the same as for $\sum\frac{1}{k^p}$: the integral test makes them the same question.
:::

```sim plot
view: graph
x: x = 1..50
y: y = 0..1.05
slider: p = 0.5..3 step 0.05 = 1.5
slider: b = 2..50 step 1 = 10
plot: x^(-p) | label: x to the minus p | samples: 400
readout: integral from 1 to b = (1 - b^(1 - p))/(p - 1 + 1e-12) | digits: 4
readout: limit as b grows, if p is above 1 = 1/(p - 1 + 1e-12) | digits: 4
```

::: predict
## Does $\int_1^\infty\frac{\sin x}{x}dx$ converge, and does $\int_1^\infty\frac{\lvert\sin x\rvert}{x}dx$?

- [ ] Both converge
- [x] The first converges and the second diverges
- [ ] Both diverge
- [ ] The second converges and the first diverges

::: reveal
The first converges and the second diverges. Each hump of $\lvert\sin x\rvert$ has area 2, so the second integral grows like $\frac2\pi\ln b$, a harmonic series in disguise. The first alternates in sign, and its humps shrink, so their contributions cancel more and more: it converges **conditionally**, like the alternating harmonic series.
:::
:::

::: nameit
## Definitions

$\int_a^\infty f = \lim_{b\to\infty}\int_a^bf$, if the limit exists. If f blows up at a, $\int_a^bf = \lim_{c\to a^+}\int_c^bf$. With trouble at both ends, split and require both pieces to converge.

## Power comparisons

- $\int_1^\infty x^{-p}\,dx$ converges exactly when p > 1, to $\frac{1}{p - 1}$.
- $\int_0^1x^{-p}\,dx$ converges exactly when p < 1, to $\frac{1}{1 - p}$.

## Tests

- **Comparison:** if $0 \le f \le g$ and $\int g$ converges, so does $\int f$; if $\int f$ diverges, so does $\int g$.
- **Limit comparison:** if $f/g$ tends to a positive constant, the two integrals converge or diverge together. So $\int_1^\infty\frac{dx}{x^2 + x}$ converges like $\int x^{-2}$.
- **Absolute convergence:** if $\int\lvert f\rvert$ converges, so does $\int f$.
- **Dirichlet's test:** if g decreases to 0 and $\int_a^bh$ stays bounded, then $\int_a^\infty gh$ converges. That handles $\frac{\sin x}{x}$.

## Where they matter

The **Laplace transform** $\int_0^\infty f(t)e^{-st}dt$ converges when $\lvert f(t)\rvert \le Me^{ct}$ and Re s > c, and when f's singularity at 0 is integrable. The **gamma function** $\Gamma(s) = \int_0^\infty t^{s-1}e^{-t}dt$ converges for s > 0, with $\Gamma(n + 1) = n!$ and $\Gamma(\frac12) = \sqrt\pi$. A signal has finite energy when $\int\lvert x(t)\rvert^2dt$ converges.
:::

::: example
## Does $\int_1^\infty\frac{\ln x}{x^2}dx$ converge? Find it if so.

::: solution
1. **Compare.** $\ln x$ grows more slowly than any power, so for large x,
   $$\frac{\ln x}{x^2} \le x^{-3/2}$$
   whose integral converges. By comparison, so does ours.
2. **Integrate by parts.** With $u = \ln x$ and $dv = x^{-2}dx$:
   $$\begin{aligned} \int_1^b\frac{\ln x}{x^2}dx &= \left[-\frac{\ln x}{x}\right]_1^b + \int_1^b\frac{dx}{x^2} \\ &= -\frac{\ln b}{b} + 1 - \frac1b \end{aligned}$$
3. **Let b → ∞.** This tends to 1. Comparison told us the limit exists before we computed it.

**Answer:** it converges, to 1.
:::
:::

::: example
## For which s does $\int_0^\infty t^{-1/2}e^{-st}dt$, the Laplace transform of $\frac{1}{\sqrt t}$, converge? Evaluate it.

::: solution
1. **Near t = 0.** The integrand behaves like $t^{-1/2}$, integrable since $\frac12 < 1$.
2. **Near ∞.** It decays like $e^{-st}$, fine for s > 0. So it converges for every s > 0.
3. **Substitute u = st.** Calling the integral F(s),
   $$\begin{aligned} F(s) &= s^{-1/2}\int_0^\infty u^{-1/2}e^{-u}du \\ &= \frac{\Gamma(1/2)}{\sqrt s} \\ &= \sqrt{\frac\pi s} \end{aligned}$$
4. **At s = 1.**
   $$\sqrt\pi = 1.772$$
5. **What it shows.** A function that's infinite at t = 0 still has a perfectly good transform, as long as its singularity is integrable.

**Answer:** it converges for every s > 0, to $\sqrt{\pi/s}$, which is 1.772 at s = 1.
:::
:::

::: example
## Show that $\int_0^\infty\frac{\lvert\sin x\rvert}{x}dx$ diverges.

::: solution
1. **Bound one hump.** On $[k\pi, (k + 1)\pi]$, $\frac1x \ge \frac{1}{(k + 1)\pi}$ and $\int\lvert\sin x\rvert = 2$, so that piece contributes at least
   $$\frac{2}{(k + 1)\pi}$$
2. **Add the pieces.** Up to $K\pi$ they give at least
   $$\frac2\pi\left(1 + \frac12 + \cdots + \frac1K\right)$$
   which grows without limit like $\frac2\pi\ln K$.
3. **Conclude.** So $\frac{\sin x}{x}$ is not absolutely integrable on $[0, \infty)$, even though its integral converges (to $\frac\pi2$).
4. **What it means for filters.** That's why the ideal low-pass filter, whose impulse response is a sinc, isn't BIBO stable: a bounded input with the right signs drives its output without limit.

**Answer:** out to $K\pi$ the integral is at least $\frac2\pi\left(1 + \frac12 + \cdots + \frac1K\right)$, which grows without limit, so it diverges.
:::
:::

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

## What is $\int_1^\infty x^{-\given{p}}\,dx$?

::: right
Right. $\frac{1}{p - 1}$, finite because p > 1.
:::

::: misses
- [1/(1 - p)] The antiderivative is $\frac{x^{1-p}}{1 - p}$, which is 0 at ∞ and $\frac{1}{1 - p}$ at 1; subtract.
- [any] $\left[\frac{x^{1-p}}{1 - p}\right]_1^\infty$.
:::
:::

::: check
given: p = 0.25 | 0.6 | 0.8
answer: 1/(1 - p)
tolerance: 0.5%

## What is $\int_0^1x^{-\given{p}}\,dx$?

::: right
Right. $\frac{1}{1 - p}$, finite because p < 1.
:::

::: misses
- [1/p] Integrate: $\frac{x^{1-p}}{1 - p}$.
- [any] $\left[\frac{x^{1-p}}{1 - p}\right]_0^1$.
:::
:::

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

## What is $\int_1^\infty\frac{\ln x}{x^{\given{p}}}dx$?

::: right
Right. By parts, $\frac{1}{(p - 1)^2}$.
:::

::: misses
- [1/(p - 1)] That's without the log; integrating by parts adds another factor $\frac{1}{p - 1}$.
- [any] $u = \ln x$, $dv = x^{-p}dx$.
:::
:::

::: check
kind: parts
given: b = 0.5 | 2 | 4

## Gamma-type integrals with decay rate {b}.

::: part
answer: 1/b^2
tolerance: 0.5%

### What is $\int_0^\infty te^{-\given{b}t}dt$?

::: misses
- [1/b] That's without the factor t.
- [any] $\frac{\Gamma(2)}{b^2}$.
:::
:::

::: part
answer: 2/b^3
tolerance: 0.5%

### What is $\int_0^\infty t^2e^{-\given{b}t}dt$?

::: misses
- [any] $\frac{\Gamma(3)}{b^3} = \frac{2}{b^3}$.
:::
:::
:::

::: check
given: s = 2 | 4 | 10
answer: sqrt(pi/s)
tolerance: 0.5%

## What is the Laplace transform of $\frac{1}{\sqrt t}$ at s = {s}?

::: right
Right. $\sqrt{\pi/s}$, from $\Gamma(\frac12) = \sqrt\pi$.
:::

::: misses
- [sqrt(pi)/s] Substitute u = st: the factor is $s^{-1/2}$.
- [any] $\frac{\Gamma(1/2)}{\sqrt s}$.
:::
:::

::: check
given: k = 1 | 5 | 20
answer: 2/((k + 1)*pi)
tolerance: 0.5%

## On $[k\pi, (k + 1)\pi]$ with k = {k}, what lower bound does $\frac1x \ge \frac{1}{(k + 1)\pi}$ give for $\int\frac{\lvert\sin x\rvert}{x}dx$?

::: right
Right. Each hump has area 2, and these lower bounds add up like a harmonic series.
:::

::: misses
- [2/(k*pi)] That's an upper bound, using the left end.
- [any] $\frac{2}{(k + 1)\pi}$.
:::
:::

::: check
kind: choice

## Which of these integrals converges?

- [ ] $\int_1^\infty\frac{dx}{\sqrt x}$
- [x] $\int_1^\infty\frac{dx}{x^2 + x}$
- [ ] $\int_0^1\frac{dx}{x}$
- [ ] $\int_0^\infty\frac{\lvert\sin x\rvert}{x}dx$

::: right
Right. It behaves like $x^{-2}$ for large x; in fact it equals $\ln 2$.
:::

::: misses
- [1] p = ½ ≤ 1 at infinity: it diverges.
- [3] p = 1 at 0: $\ln\frac1c$ grows without limit.
- [4] The humps add like a harmonic series.
:::
:::

::: check
kind: derivation
vars: p = 1.1..4, b = 2..100

## The integral of $x^{-p}$ over [1, b].

::: step
answer: (1 - b^(1 - p))/(p - 1)

### What is $\int_1^bx^{-p}\,dx$?
:::

::: step
answer: 1/(p - 1)

### What is its limit as b → ∞?
:::

::: right
Right. For p > 1 the term $b^{1-p}$ vanishes, leaving $\frac{1}{p - 1}$.
:::
:::

::: check
kind: python

## $\Gamma(\frac12) = \int_0^\infty t^{-1/2}e^{-t}dt$ is singular at 0. Substitute $t = u^2$ to get $2\int_0^\infty e^{-u^2}du$, truncate at u = 10, and apply the trapezoid rule on 100 001 points. Set `g`.

```python starter
import numpy as np

g = 0.0
print(g)
```

```python solution
import numpy as np

u = np.linspace(0, 10, 100001)
y = np.exp(-u**2)
h = u[1] - u[0]
g = 2 * h * (np.sum(y) - (y[0] + y[-1]) / 2)
print(g)
```

```python tests
import math
assert abs(g - math.sqrt(math.pi)) < 1e-10, f"Gamma(1/2) = sqrt(pi) = 1.7724539; got {g}."
```

::: right
Right. $\sqrt\pi$ to ten digits: the substitution removed the singularity, and the tail beyond 10 is about $e^{-100}$.
:::
:::

::: explain
## Why do $\int_1^\infty x^{-p}\,dx$ and $\sum k^{-p}$ converge for exactly the same p?

::: model
For a decreasing positive function, the sum $\sum_{k=2}^Nf(k)$ is the area of rectangles that fit under the curve from 1 to N, and $\sum_{k=1}^{N-1}f(k)$ is the area of rectangles that cover it. So the partial sums and the integral up to N bound each other within one term. Both are increasing in N, so if one stays bounded the other must too, and if one grows without limit so does the other. For $x^{-p}$ the integral is easy to compute and is finite exactly when p > 1, which settles the series as well.
:::
:::

::: practice

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

## $\int_1^\infty x^{-\given{p}}\,dx$?

::: misses
- [any] $\frac{1}{p - 1}$.
:::
:::

::: check
given: s = 0.25 | 0.5 | 1 | 2 | 4 | 9
answer: sqrt(pi/s)
tolerance: 0.5%

## Laplace transform of $t^{-1/2}$ at s = {s}?

::: misses
- [any] $\sqrt{\pi/s}$.
:::
:::
:::
