Calculus · Integrals with a Parameter

Differentiating and Integrating Improper Integrals: How to Compute the "Impossible" Ones

Some of the most famous integrals in mathematics, like \( \int_0^\infty e^{-x^2}dx \) and \( \int_0^\infty \frac{\sin x}{x}dx \), have no elementary antiderivative. Yet their values are known exactly. The secret is to treat them as members of a family and apply calculus to the parameter. This post shows how, and when it is allowed.

1. Where we are

For proper integrals \( \int_a^b f(x, m)\,dx \), continuity of \(f\) and \(f_m'\) on a closed rectangle was enough to differentiate and integrate with respect to \(m\) under the integral sign. For improper integrals we saw that convergence alone does not even guarantee continuity; the extra ingredient was uniform convergence. This post finishes the story: the same ingredient makes differentiation and integration legal.

The common theme, in one sentence: an improper integral is a limit, and swapping two limiting operations requires uniformity.

2. Substitution in improper integrals

The substitution rule works for improper integrals just as for proper ones, provided the substitution \( x = \varphi(t) \) is continuously differentiable and strictly monotone, mapping the \(t\)-interval onto the \(x\)-interval (the endpoints may be infinite). Then both integrals converge or diverge together, and

\[ \int_a^{\infty} f(x)\,dx = \int_{\alpha}^{\beta} f\big(\varphi(t)\big)\,\varphi'(t)\,dt, \qquad \varphi(\alpha) = a,\ \ \varphi(\beta^-) = \infty. \]

With a parameter, the most useful substitution is scaling, \( x = t/m \). It often shows how the integral depends on \(m\) without computing anything.

Example 1 · Scaling reveals the dependence on m Let \( F(m) = \displaystyle\int_0^\infty \frac{\sin(mx)}{x}\,dx \). For \(m > 0\), put \(t = mx\): \[ F(m) = \int_0^\infty \frac{\sin t}{t/m}\cdot\frac{dt}{m} = \int_0^\infty \frac{\sin t}{t}\,dt. \] So \(F\) is constant for \(m > 0\). Since \(F(-m) = -F(m)\) and \(F(0) = 0\), we get \[ F(m) = \operatorname{sgn}(m)\int_0^\infty \frac{\sin t}{t}\,dt. \] We will show below that the remaining integral equals \( \frac\pi2 \). Notice that \(F\) jumps at \(m = 0\): by the previous post, the convergence cannot be uniform near \(m = 0\).
Example 2 For \(m > 0\), substituting \( x = t/\sqrt m \) in the Gaussian integral gives \[ \int_0^\infty e^{-mx^2}\,dx = \frac{1}{\sqrt m}\int_0^\infty e^{-t^2}\,dt. \] Once we know \( \int_0^\infty e^{-t^2}dt = \frac{\sqrt\pi}{2} \) (Section 6), this becomes \( \frac12\sqrt{\frac{\pi}{m}} \).

3. Leibniz's rule for improper integrals

Theorem 1 · Leibniz's rule Let \(f(x, m)\) and \(f_m'(x, m)\) be continuous for \( a \le x < \infty,\ m_1 < m < m_2 \). Suppose that
  1. \( \displaystyle\int_a^\infty f(x, m)\,dx \) converges (for each \(m\)), and
  2. \( \displaystyle\int_a^\infty f_m'(x, m)\,dx \) converges uniformly on \((m_1, m_2)\).
Then for \( m_1 < m < m_2 \) \[ \frac{d}{dm}\int_a^\infty f(x, m)\,dx = \int_a^\infty f_m'(x, m)\,dx. \]

Note the asymmetry: the original integral only has to converge, but the differentiated integral must converge uniformly. That is the one you have to check.

Why it works: write \( I(m) = \lim_{b\to\infty} I_b(m) \) with \( I_b(m) = \int_a^b f\,dx \). For each finite \(b\), the proper Leibniz rule gives \( I_b'(m) = \int_a^b f_m'\,dx \). Uniform convergence of \( \int_a^\infty f_m' \) means these derivatives converge uniformly as \(b \to \infty\), and a standard theorem of analysis says: if functions converge and their derivatives converge uniformly, the limit is differentiable and its derivative is the limit of the derivatives.

How to check condition 2 in practice: find a majorant for \(f_m'\) (Weierstrass test). As in the last post, if the trouble is at an endpoint of the parameter interval, prove uniformity on \([m_0, \infty)\) for every \(m_0 > 0\); that is enough to get the formula at every \(m > 0\), since each such \(m\) lies inside some \((m_0, \infty)\).

What goes wrong without uniformity From Example 1, \( F(m) = \int_0^\infty \frac{\sin(mx)}{x}\,dx \) is constant for \(m > 0\), so \(F'(m) = 0\). Differentiating blindly under the integral would give \[ \int_0^\infty \cos(mx)\,dx, \] which diverges. The differentiated integral doesn't even converge, let alone uniformly, so the rule doesn't apply.

4. Differentiation at work

Example 3 · Factorials from one integral For \(m > 0\), \( \displaystyle\int_0^\infty e^{-mx}\,dx = \frac1m \). Differentiating \(n\) times with respect to \(m\): \[ \int_0^\infty x^n e^{-mx}\,dx = \frac{n!}{m^{n+1}}. \]

Justification: each differentiated integrand \( x^ke^{-mx} \) is bounded on \([m_0, \infty)\) by the integrable majorant \( x^ke^{-m_0x} \), so each step is uniform. With \(m = 1\) this gives \( \int_0^\infty x^ne^{-x}\,dx = n! \), i.e. \( \Gamma(n + 1) = n! \).

Example 4 · An integral that satisfies a differential equation Compute \( I(m) = \displaystyle\int_0^\infty e^{-x^2}\cos(mx)\,dx \) for all real \(m\).

The differentiated integrand is \( -xe^{-x^2}\sin(mx) \), with the majorant \( xe^{-x^2} \) (integrable, independent of \(m\)). So Leibniz applies on all of \(\mathbb{R}\):

\[ I'(m) = -\int_0^\infty xe^{-x^2}\sin(mx)\,dx. \] Integrate by parts with \( u = \sin(mx) \), \( dv = xe^{-x^2}dx \), \( v = -\frac12e^{-x^2} \): \[ I'(m) = \Big[\tfrac12e^{-x^2}\sin(mx)\Big]_0^\infty - \frac m2\int_0^\infty e^{-x^2}\cos(mx)\,dx = -\frac m2\,I(m). \] This is a separable ODE: \( \frac{I'}{I} = -\frac m2 \), so \( I(m) = I(0)\,e^{-m^2/4} \). With \( I(0) = \frac{\sqrt\pi}{2} \), \[ \int_0^\infty e^{-x^2}\cos(mx)\,dx = \frac{\sqrt\pi}{2}\,e^{-m^2/4}. \] (A Gaussian transforms into a Gaussian, a fact at the heart of Fourier analysis and probability.)
Example 5 · The Dirichlet integral Now we compute \( \displaystyle\int_0^\infty \frac{\sin x}{x}\,dx \). Introduce a damping parameter: \[ F(m) = \int_0^\infty e^{-mx}\,\frac{\sin x}{x}\,dx \qquad (m > 0). \]

Step 1: differentiate. \( \frac{\partial}{\partial m}\Big(e^{-mx}\frac{\sin x}{x}\Big) = -e^{-mx}\sin x \), with majorant \( e^{-m_0x} \) on \([m_0, \infty)\). So

\[ F'(m) = -\int_0^\infty e^{-mx}\sin x\,dx = -\frac{1}{1 + m^2}. \]

(The \(\frac1x\) disappeared: that's the whole point of the parameter.)

Step 2: integrate back. \( F(m) = C - \arctan m \).

Step 3: find the constant. Since \( \left|\frac{\sin x}{x}\right| \le 1 \), \( |F(m)| \le \int_0^\infty e^{-mx}dx = \frac1m \to 0 \) as \(m \to \infty\). So \( 0 = C - \frac\pi2 \), and \( F(m) = \frac\pi2 - \arctan m \).

Step 4: let \(m \to 0^+\). The integral defining \(F\) converges uniformly on \([0, \infty)\) (this follows from Abel's test, since \(e^{-mx}\) is monotone in \(x\) and bounded by 1, and \( \int_0^\infty \frac{\sin x}{x}dx \) converges), so \(F\) is continuous at \(0\):

\[ \int_0^\infty \frac{\sin x}{x}\,dx = \lim_{m\to 0^+} F(m) = \frac\pi2. \]

5. Integrating with respect to the parameter

Theorem 2 · Changing the order of integration If \(f(x, m)\) is continuous for \( x \ge a \) and \( m_1 \le m \le m_2 \), and \( \int_a^\infty f(x, m)\,dx \) converges uniformly on the finite interval \([m_1, m_2]\), then \[ \int_{m_1}^{m_2} dm\int_a^\infty f(x, m)\,dx = \int_a^\infty dx\int_{m_1}^{m_2} f(x, m)\,dm. \tag{1} \]

The most common use is the trick from the previous post on proper integrals: recognise part of the integrand as an integral with respect to a parameter, then swap the order.

Example 6 · A Frullani-type integral Compute \( \displaystyle\int_0^\infty \frac{e^{-ax} - e^{-bx}}{x}\,dx \) for \(0 < a < b\).

Observe that \( \dfrac{e^{-ax} - e^{-bx}}{x} = \displaystyle\int_a^b e^{-mx}\,dm \). The integral \( \int_0^\infty e^{-mx}dx \) converges uniformly on \([a, b]\) (majorant \(e^{-ax}\)), so

\[ \int_0^\infty dx\int_a^b e^{-mx}\,dm = \int_a^b dm\int_0^\infty e^{-mx}\,dx = \int_a^b \frac{dm}{m} = \ln\frac ba. \]

6. Positive integrands and infinite intervals: the Gaussian integral

Theorem 2 needs a finite parameter interval. For non-negative integrands there is a much more generous rule:

Theorem 3 · Non-negative integrands If \( f(x, m) \ge 0 \), formula (1) also holds for an infinite interval of the parameter (for example \(m \in (0, \infty)\)), provided one side of (1) makes sense (is finite). Then the other side is finite too, and they are equal.

The intuition: with no negative values, nothing can cancel, so adding up "by rows" or "by columns" must give the same total. Problems like the warning examples in earlier posts come from positive and negative parts cancelling differently in different orders.

Example 7 · The Gaussian integral \( \int_0^\infty e^{-x^2}dx = \frac{\sqrt\pi}{2} \) Let \( I = \int_0^\infty e^{-x^2}\,dx \). For any \(m > 0\), substitute \(x = mt\) (Section 2): \[ I = \int_0^\infty m\,e^{-m^2t^2}\,dt. \] Multiply by \( e^{-m^2} \) and integrate over \( m \in (0, \infty) \). On the left, \( \int_0^\infty e^{-m^2}\,I\,dm = I\cdot I = I^2 \). On the right: \[ I^2 = \int_0^\infty dm\int_0^\infty m\,e^{-m^2(1 + t^2)}\,dt. \] The integrand is positive, so by Theorem 3 we may swap the order: \[ I^2 = \int_0^\infty dt\int_0^\infty m\,e^{-m^2(1 + t^2)}\,dm = \int_0^\infty \frac{dt}{2(1 + t^2)} = \frac12\cdot\frac\pi2 = \frac\pi4. \] Since \(I > 0\), \( I = \dfrac{\sqrt\pi}{2} \). (This is the same result usually obtained with polar coordinates in a double integral, here done entirely with the tools of this post.)

7. Summary

OperationFormulaSufficient conditions
Substitution\( \int_a^\infty f(x)\,dx = \int_\alpha^\beta f(\varphi(t))\varphi'(t)\,dt \)\(\varphi\) strictly monotone, \(C^1\)
Differentiation\( \frac{d}{dm}\int_a^\infty f\,dx = \int_a^\infty f_m'\,dx \)\(f, f_m'\) continuous; \(\int f\) converges; \(\int f_m'\) converges uniformly
Integration, finite interval\( \int_{m_1}^{m_2}\!dm\int_a^\infty f\,dx = \int_a^\infty\!dx\int_{m_1}^{m_2} f\,dm \)\(f\) continuous; \(\int f\,dx\) converges uniformly on \([m_1, m_2]\)
Integration, infinite intervalsame formula\(f \ge 0\) and one side finite

The general strategy for a hard integral:

  1. Embed it in a family \(I(m)\), adding a parameter if necessary (a damping factor \(e^{-mx}\) is a popular choice).
  2. Differentiate in \(m\) to get a simpler integral, or write a factor as \(\int dm\) and swap the order.
  3. Check the uniform convergence (usually with a majorant).
  4. Solve for \(I(m)\) and fix the constant from a value of \(m\) where \(I(m)\) is known, often a limit \(m \to 0\) or \(m \to \infty\).

8. Practice problems

Try these before opening the solution. More solved problems are in Definite Integrals and Double Integrals.

Problem 1: Show that \( \displaystyle\int_0^\infty x^2e^{-mx}\,dx = \frac{2}{m^3} \) for \(m > 0\).

Example 3 with \(n = 2\): differentiate \( \int_0^\infty e^{-mx}dx = \frac1m \) twice. Majorant on \([m_0, \infty)\): \(x^2e^{-m_0x}\).

Problem 2: Compute \( \displaystyle\int_0^\infty e^{-x}\,\frac{1 - \cos(mx)}{x}\,dx \).

Call it \(F(m)\). Then \( F'(m) = \int_0^\infty e^{-x}\sin(mx)\,dx = \frac{m}{1 + m^2} \) (majorant \(e^{-x}\), so uniform on \(\mathbb R\)). Integrating, \( F(m) = \frac12\ln(1 + m^2) + C \), and \(F(0) = 0\) gives \(C = 0\): \[ F(m) = \tfrac12\ln(1 + m^2). \]

Problem 3: Show that \( \displaystyle\int_0^\infty e^{-mx}\,\frac{\sin(bx)}{x}\,dx = \arctan\frac bm \) for \(m, b > 0\).

As in Example 5: \( F'(m) = -\int_0^\infty e^{-mx}\sin(bx)\,dx = -\frac{b}{m^2 + b^2} \), so \( F(m) = C - \arctan\frac mb \). Since \(F(m) \to 0\) as \(m \to \infty\), \(C = \frac\pi2\), and \( \frac\pi2 - \arctan\frac mb = \arctan\frac bm \).

Problem 4: Compute \( \displaystyle\int_0^\infty \frac{e^{-ax^2} - e^{-bx^2}}{x^2}\,dx \) for \(0 < a < b\).

Write the integrand as \( \int_a^b e^{-mx^2}\,dm \) and swap (uniform on \([a, b]\), majorant \(e^{-ax^2}\)): \[ \int_a^b dm\int_0^\infty e^{-mx^2}dx = \int_a^b \frac12\sqrt{\frac\pi m}\,dm = \sqrt\pi\big(\sqrt b - \sqrt a\big). \]

Problem 5: Compute \( \displaystyle\int_0^\infty \frac{\arctan(ax) - \arctan(bx)}{x}\,dx \) for \(a > b > 0\).

Since \( \frac{\partial}{\partial m}\arctan(mx) = \frac{x}{1 + m^2x^2} \), the integrand equals \( \int_b^a \frac{dm}{1 + m^2x^2} \), which is positive. By Theorem 3 (or Theorem 2, as \([b, a]\) is finite): \[ \int_b^a dm\int_0^\infty \frac{dx}{1 + m^2x^2} = \int_b^a \frac{\pi}{2m}\,dm = \frac\pi2\ln\frac ab. \]

Problem 6: Using Example 2, compute \( \displaystyle\int_0^\infty x^2e^{-mx^2}\,dx \) for \(m > 0\).

Differentiate \( \int_0^\infty e^{-mx^2}dx = \frac{\sqrt\pi}{2}m^{-1/2} \) with respect to \(m\) (majorant \(x^2e^{-m_0x^2}\) on \([m_0,\infty)\)): \[ -\int_0^\infty x^2e^{-mx^2}dx = -\frac{\sqrt\pi}{4}m^{-3/2} \;\Longrightarrow\; \int_0^\infty x^2e^{-mx^2}dx = \frac{\sqrt\pi}{4m^{3/2}}. \]

Final thoughts

The integrals in this post are not curiosities: the Gaussian integral underlies the normal distribution, the Dirichlet integral appears in signal processing, and Example 4 is a first glimpse of the Fourier transform. What made them computable was one idea, turning a number into a function and doing calculus on it, together with one safety check: uniform convergence before any swap.

Next in the series: the Euler integrals, the Gamma and Beta functions, and the relation \( \mathrm B(p, q) = \frac{\Gamma(p)\Gamma(q)}{\Gamma(p + q)} \).