Unit 10, lesson 126

Approximating Improper Integrals

How to approximate an integral over an infinite interval or with an unbounded integrand by cutting off a tail you can bound, removing singularities, and keeping track of each source of error.

  • Theory part 251
  • Practice part 252
  • Numerical Integration

The rules for definite integrals need a finite interval and a function that stays bounded. Improper integrals break both. A computer cannot sample infinitely far out, and it cannot evaluate 1x\frac{1}{\sqrt{x}} at 00. The fix is not a new rule but some honest preparation, so that what is left is an ordinary integral with a known extra error.

Key terms

Truncating an infinite interval

Definition Suppose ff is continuous on [a,∞)[a, \infty) and ∫a∞f(x) dx\int_a^\infty f(x) \, dx converges. For any T>aT > a,

∫a∞f(x) dx=∫aTf(x) dx+∫T∞f(x) dx.\int_a^\infty f(x) \, dx = \int_a^T f(x) \, dx + \int_T^\infty f(x) \, dx.

Truncating at TT means approximating the whole integral by the proper integral ∫aTf(x) dx\int_a^T f(x) \, dx. The truncation error is the tail ∫T∞f(x) dx\int_T^\infty f(x) \, dx, which tends to 00 as T→∞T \to \infty because the integral converges.

In plain words Stop at some far point TT and ignore what lies beyond. That is fine as long as you know the part you threw away is small.

Example For ∫0∞e−x dx=1\int_0^\infty e^{-x} \, dx = 1 the tail can be found exactly. It is

∫T∞e−x dx=e−T.\int_T^\infty e^{-x} \, dx = e^{-T}.

With T=10T = 10 the truncation error is e−10≈4.5×10−5e^{-10} \approx 4.5 \times 10^{-5}.

Bounding tails

Definition Suppose ff and gg are continuous on [T,∞)[T, \infty), ∣f(x)∣≤g(x)\lvert f(x) \rvert \le g(x) for all x≥Tx \ge T, and ∫T∞g(x) dx\int_T^\infty g(x) \, dx converges. Then by the comparison test ∫T∞∣f(x)∣ dx\int_T^\infty \lvert f(x) \rvert \, dx converges, so ∫T∞f(x) dx\int_T^\infty f(x) \, dx converges absolutely, and

∣∫T∞f(x) dx∣≤∫T∞g(x) dx.\left\lvert \int_T^\infty f(x) \, dx \right\rvert \le \int_T^\infty g(x) \, dx.

The comparison function gg is chosen so that its tail can be computed exactly.

In plain words When you cannot compute the tail, trap it under something simpler that you can integrate.

Example Truncate

∫0∞e−x2 dx=π2≈0.886227\int_0^\infty e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2} \approx 0.886227

at T=3T = 3. For x≥3x \ge 3 we have x3≥1\frac{x}{3} \ge 1, so e−x2≤x3e−x2e^{-x^2} \le \frac{x}{3} e^{-x^2}, and the right side has an antiderivative. Hence

∫3∞e−x2 dx≤13∫3∞xe−x2 dx=13⋅e−92=e−96≈2.06×10−5.\int_3^\infty e^{-x^2} \, dx \le \frac{1}{3} \int_3^\infty x e^{-x^2} \, dx = \frac{1}{3} \cdot \frac{e^{-9}}{2} = \frac{e^{-9}}{6} \approx 2.06 \times 10^{-5}.

The true tail is about 1.96×10−51.96 \times 10^{-5}, so the bound is quite sharp.

Isolating a singularity

Definition Suppose ff is continuous on (a,b](a, b] and unbounded near aa, and ∫abf(x) dx\int_a^b f(x) \, dx converges. Isolating the singularity means writing f=s+rf = s + r on (a,b](a, b], where ss is continuous on (a,b](a, b] and carries the bad behavior near aa, the convergent improper integral ∫abs(x) dx\int_a^b s(x) \, dx can be found exactly, and rr has a finite limit as x→a+x \to a^+, so that defining r(a)r(a) as that limit makes rr continuous on [a,b][a, b]. Then

∫abf(x) dx=∫abs(x) dx+∫abr(x) dx,\int_a^b f(x) \, dx = \int_a^b s(x) \, dx + \int_a^b r(x) \, dx,

and only the second integral, which is proper, is approximated numerically.

In plain words Subtract off the part of the function that blows up, integrate that part by hand, and give the computer only the well behaved remainder.

Example Take

I=∫01cos⁡xx dx≈1.809048.I = \int_0^1 \frac{\cos x}{\sqrt{x}} \, dx \approx 1.809048.

Simpson’s rule cannot even start, since the integrand is undefined at 00. Near 00 we have cos⁡x≈1\cos x \approx 1, so subtract s(x)=1xs(x) = \frac{1}{\sqrt{x}}, whose integral over [0,1][0, 1] is 22. The remainder

r(x)=cos⁡x−1xr(x) = \frac{\cos x - 1}{\sqrt{x}}

tends to 00 as x→0+x \to 0^+, so set r(0)=0r(0) = 0. Simpson’s rule with n=4n = 4 gives ∫01r(x) dx≈−0.191160\int_0^1 r(x) \, dx \approx -0.191160, so I≈2−0.191160=1.808840I \approx 2 - 0.191160 = 1.808840, an error of about 2.1×10−42.1 \times 10^{-4}.

Substitutions

Definition Let ff be continuous on (a,b)(a, b), where aa or bb may be infinite, and let φ\varphi be continuously differentiable and strictly increasing on (α,β)(\alpha, \beta) with φ(t)→a\varphi(t) \to a as t→α+t \to \alpha^+ and φ(t)→b\varphi(t) \to b as t→β−t \to \beta^-. Then

∫abf(x) dx=∫αβf(φ(t)) φ′(t) dt,\int_a^b f(x) \, dx = \int_\alpha^\beta f(\varphi(t)) \, \varphi'(t) \, dt,

in the sense that one improper integral converges exactly when the other does, and then they are equal. The same holds with φ\varphi strictly decreasing if the limits of integration on the right are swapped. A good substitution turns an improper integral into a proper one with a smooth integrand.

In plain words A change of variable can stretch an infinite interval into a finite one or cancel the factor that blows up.

Example In ∫01cos⁡xx dx\int_0^1 \frac{\cos x}{\sqrt{x}} \, dx put x=t2x = t^2 with tt in (0,1)(0, 1), so dx=2t dtdx = 2t \, dt and x=t\sqrt{x} = t. The integral becomes

∫012cos⁡(t2) dt,\int_0^1 2\cos(t^2) \, dt,

a proper integral of a smooth function. Simpson’s rule gives 1.8090031.809003 with n=4n = 4 (error about 4.6×10−54.6 \times 10^{-5}) and 1.80904831.8090483 with n=8n = 8 (error about 1.6×10−71.6 \times 10^{-7}). For an infinite interval, the substitution x=1tx = \frac{1}{t} turns

∫1∞dx1+x2into∫01dt1+t2,\int_1^\infty \frac{dx}{1 + x^2} \quad \text{into} \quad \int_0^1 \frac{dt}{1 + t^2},

and Simpson’s rule with n=4n = 4 gives 0.7853920.785392 against the exact π4≈0.785398\frac{\pi}{4} \approx 0.785398.

Splitting integration error from truncation error

Definition Let I=∫a∞f(x) dxI = \int_a^\infty f(x) \, dx converge, where ff is continuous on [a,∞)[a, \infty), and let QQ be a numerical approximation to ∫aTf(x) dx\int_a^T f(x) \, dx. By the triangle inequality

∣I−Q∣≤∣∫T∞f(x) dx∣+∣∫aTf(x) dx−Q∣.\lvert I - Q \rvert \le \left\lvert \int_T^\infty f(x) \, dx \right\rvert + \left\lvert \int_a^T f(x) \, dx - Q \right\rvert.

The first term is the truncation error, controlled by the choice of TT. The second is the integration error, controlled by the rule and the number of subintervals. To reach a total tolerance τ\tau, choose TT and nn so that the two bounds add up to at most τ\tau. The same split applies to an isolated singularity.

In plain words There are two separate mistakes, cutting off the tail and approximating what is left. Bound each one on its own and share the error budget between them.

Example Approximate ∫0∞e−x2 dx\int_0^\infty e^{-x^2} \, dx within 10−410^{-4}. Truncating at T=3T = 3 costs at most 2.06×10−52.06 \times 10^{-5}, which leaves about 7.9×10−57.9 \times 10^{-5} for Simpson’s rule on [0,3][0, 3]. For f(x)=e−x2f(x) = e^{-x^2} the fourth derivative is

f(4)(x)=(16x4−48x2+12)e−x2,f^{(4)}(x) = (16x^4 - 48x^2 + 12) e^{-x^2},

and ∣f(4)(x)∣≤12\lvert f^{(4)}(x) \rvert \le 12 for x≥0x \ge 0. The Simpson bound is

12⋅35180n4,\frac{12 \cdot 3^5}{180 n^4},

which equals about 6.9×10−56.9 \times 10^{-5} at n=22n = 22, the smallest even nn that fits the budget. The total is at most 9.0×10−59.0 \times 10^{-5}. In fact S22≈0.886207S_{22} \approx 0.886207, and the actual error 1.96×10−51.96 \times 10^{-5} is almost entirely truncation.

Check yourself

  1. Show that truncating ∫1∞dx1+x3\int_1^\infty \frac{dx}{1 + x^3} at T=10T = 10 costs at most 0.0050.005.
Show the answer

For x≥10x \ge 10 we have 11+x3<1x3\frac{1}{1 + x^3} < \frac{1}{x^3}, so the tail is less than

∫10∞x−3 dx=12⋅100=0.005.\int_{10}^\infty x^{-3} \, dx = \frac{1}{2 \cdot 100} = 0.005.
  1. Which substitution turns ∫01exx dx\int_0^1 \frac{e^x}{\sqrt{x}} \, dx into a proper integral, and what is the new integral?
Show the answer

The substitution x=t2x = t^2 with dx=2t dtdx = 2t \, dt gives

∫012et2 dt,\int_0^1 2e^{t^2} \, dt,

whose integrand is smooth on [0,1][0, 1].

  1. You want ∫0∞e−xcos⁡x dx\int_0^\infty e^{-x} \cos x \, dx within 10−610^{-6}. How large should TT be to keep the truncation error below 5×10−75 \times 10^{-7}?
Show the answer

Since ∣e−xcos⁡x∣≤e−x\lvert e^{-x} \cos x \rvert \le e^{-x}, the tail is at most e−Te^{-T}. You need e−T≤5×10−7e^{-T} \le 5 \times 10^{-7}, that is T≥ln⁡(2×106)≈14.51T \ge \ln(2 \times 10^6) \approx 14.51. The remaining 5×10−75 \times 10^{-7} goes to the integration rule.

How this lesson connects