A1421 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A14 · Lesson 21 · Differentiating under the integral sign

When the derivative of an integral is the integral of the derivative

An engineer wants to know how a filter's output energy changes as its time constant changes, or how a detector's error rate moves with its threshold. Each is an integral that depends on a parameter, and the quick way to its derivative is to differentiate inside the integral. Usually that works. Sometimes it gives nonsense: an integral that's constant in its parameter, whose "derivative inside" doesn't even converge. This lesson states when the swap is allowed, uses it to evaluate integrals that resist every other method, and shows the case where it fails.

  • The curve is F(t)=∫0∞e−txsin⁡xxdx, computed as π2−arctan⁡t, against t. Its derivative, from differentiating under the integral, is −∫0∞e−txsin⁡xdx=−1/(1+t2).
  • At t=0 the integral is π/2, the famous Dirichlet integral, reached by a detour through the parameter.

Predict

F(t)=∫0∞sin⁡(tx)xdx equals π/2 for every t>0. What happens if you differentiate under the integral sign?

Name it

On a bounded interval

If f(x,t) and ∂f/∂t are continuous on [a,b]×[c,d], then for t in (c,d)

ddt∫abf(x,t)dx=∫ab∂f∂t(x,t)dx

The proof uses lesson 13's uniform continuity: on a compact set, the difference quotient f(x,t+h)−f(x,t)h approaches ∂f/∂t uniformly in x, and a uniform limit can be integrated term by term.

Moving limits: Leibniz's rule

ddt∫a(t)b(t)f(x,t)dx=f(b(t),t)b′(t)−f(a(t),t)a′(t)+∫a(t)b(t)∂f∂tdx

The first two terms come from the fundamental theorem (lesson 18), the last from the rule above.

Improper integrals: domination

On an infinite range the swap needs more. It's allowed when there's a single integrable function g(x) with |∂f/∂t(x,t)|≤g(x) for every t in the range of interest (lesson 47's dominated convergence, applied to difference quotients). For ∫0∞e−txsin⁡xxdx with t≥t0>0, the derivative inside is bounded by e−t0x, so the swap is fine; for ∫0∞sin⁡(tx)xdx there's no such bound.

Using it: Feynman's trick

To evaluate ∫h(x)dx, put it inside a family F(t) whose derivative is easy, find F′, integrate back in t, and fix the constant from a value of t where F is known.

Worked example

Find ∫01xnln⁡xdx by differentiating ∫01xtdx.

Show the solution
  1. The family to differentiate. For t>−1, I(t)=∫01xtdx=1t+1
  2. Differentiate under the integral. ∂∂txt=xtln⁡x is continuous and bounded on [0,1] for t>0 (it tends to 0 at x=0), so ∫01xtln⁡xdx=I′(t)=−1(t+1)2
  3. Put in t = 1. ∫01xln⁡xdx=−14
  4. Differentiate again. A second derivative gives ∫01xtln2⁡xdx=2(t+1)3 with no integration by parts at all.

Answer ∫01xnln⁡xdx=−1(n+1)2, which is −14 for n = 1.

Worked example

Evaluate the Dirichlet integral ∫0∞sin⁡xxdx with Feynman's trick.

Show the solution
  1. Put it in a family. For t>0 let F(t)=∫0∞e−txsin⁡xxdx
  2. Differentiate under the integral. The derivative inside, −e−txsin⁡x, is dominated by e−t0x for t≥t0>0, so F′(t)=−∫0∞e−txsin⁡xdx=−11+t2
  3. Integrate back. F(t)=C−arctan⁡t and F(t)→0 as t→∞ gives C=π/2.
  4. Let t→0+. The convergence is uniform enough to pass to the limit, so ∫0∞sin⁡xxdx=π2
  5. A value on the way. At t=1 the integral is π/4.

Answer ∫0∞sin⁡xxdx=π2.

Worked example

A filter's impulse response is e−t/τ, so its output energy for a unit impulse is E(τ)=∫0∞e−2t/τdt. Find dE/dτ both ways.

Show the solution
  1. Directly. E=τ/2, so dEdτ=12
  2. Differentiate the integrand. ∂∂τe−2t/τ=2tτ2e−2t/τ
  3. Check domination. For τ in any interval [τ1,τ2] with τ1>0, this is dominated by 2tτ12e−2t/τ2, which is integrable.
  4. Differentiate under the integral. dEdτ=2τ2∫0∞te−2t/τdt=2τ2⋅τ24=12
  5. Why it's useful. The same method gives sensitivities when the integral has no closed form, which is how circuit optimizers compute gradients of energy, noise or error measures.

Answer both ways give dE/dτ=12.

Check

Using ∫01xtdx=1/(t+1), what is ∫01x2ln⁡xdx?

Check

Starting from ∫0∞e−axdx=1/a, differentiate 2 time(s) with respect to a to find ∫0∞x2e−1xdx.

Check

What is ddt∫0t2sin⁡xdx at t = 1.2?

Check

For I(t)=∫0∞e−tx2dx=12π/t, compute I′(t) at t = 1 three ways: from the formula (exact), as a central difference of the formula with h=10−5 (diff), and by integrating −x2e−tx2 numerically from 0 to 20 with Simpson's rule on 20 000 intervals (inside).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Find ∫0∞x2e−axdx from ∫0∞e−axdx=1/a.

Step 1

What is ∂∂ae−ax?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Check

F(t)=∫0∞sin⁡(tx)xdx is π/2 for all t>0, yet differentiating inside gives a divergent integral. Which condition for the swap fails?

Explain why

Why does differentiating under an integral over an infinite range need a dominating function, when on a bounded range continuity is enough?

Practice

Keep practicing

6 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.