Calculus · Integrals with a Parameter

When an Integral Becomes a Function: Integrals Depending on a Parameter

What happens when the function you integrate contains an extra variable? The integral stops being a single number and becomes a function of that variable. This post shows when such functions are continuous, how to differentiate them, and how this idea lets you compute integrals that look impossible.

1. The idea: an integral as a function

Compare these two integrals:

\[ \int_0^1 x^2\,dx = \frac13 \qquad \text{and} \qquad \int_0^1 x^m\,dx = \frac{1}{m+1}. \]

The first is a number. The second depends on \(m\): for each value of \(m\) you get a different number. In other words, it defines a function of \(m\). The variable \(x\) is "used up" by the integration (it is a dummy variable), while \(m\) survives. We call \(m\) a parameter.

Setting Let \(f(x, m)\) be defined on the rectangle \[ R = \{(x, m) : a \le x \le b,\ m_1 \le m \le m_2\}. \] The function defined by a proper integral depending on a parameter is \[ I(m) = \int_a^b f(x, m)\,dx. \] ("Proper" means the interval \([a, b]\) is bounded and the integrand is well behaved; the improper case comes in a later post.)

The natural questions are the ones we ask about any function: Is \(I(m)\) continuous? Can we differentiate it? Can we integrate it? The answer to all three is "yes, provided \(f\) is nice enough", and each answer is a rule about swapping two operations: a limit, a derivative or an integral with respect to \(m\), on one side, and the integral with respect to \(x\) on the other.

2. Continuity: passing to the limit under the integral

Theorem 1 · Continuity If \(f(x, m)\) is defined and continuous on the closed rectangle \(R\), then \[ I(m) = \int_a^b f(x, m)\,dx \] is a continuous function on \([m_1, m_2]\).

Continuity of \(I\) at \(m_0\) means \( \lim_{m\to m_0} I(m) = I(m_0) \). Written out, the theorem says you may move the limit inside the integral:

\[ \lim_{m\to m_0} \int_a^b f(x, m)\,dx = \int_a^b \lim_{m\to m_0} f(x, m)\,dx = \int_a^b f(x, m_0)\,dx. \]

Why it works: a continuous function on a closed, bounded rectangle is uniformly continuous. So when \(m\) is close to \(m_0\), \( |f(x, m) - f(x, m_0)| < \varepsilon \) for all \(x\) simultaneously, and then

\[ |I(m) - I(m_0)| \le \int_a^b |f(x, m) - f(x, m_0)|\,dx < \varepsilon(b - a). \]
Example 1 Find \( \displaystyle\lim_{m\to 0} \int_0^1 \sqrt{x^2 + m^2}\,dx \).

The integrand is continuous on \([0,1]\times[-1,1]\), so we may set \(m = 0\) inside:

\[ \lim_{m\to 0} \int_0^1 \sqrt{x^2 + m^2}\,dx = \int_0^1 \sqrt{x^2}\,dx = \int_0^1 x\,dx = \frac12. \]
When continuity fails Take \( I(m) = \displaystyle\int_0^1 \frac{m}{x^2 + m^2}\,dx = \arctan\frac{1}{m} \) for \(m > 0\), and \(I(0) = 0\). Then \[ \lim_{m\to 0^+} I(m) = \frac{\pi}{2} \ne 0 = I(0). \] The limit cannot be moved inside. The culprit: \( f(x, m) = \frac{m}{x^2 + m^2} \) is not continuous at the corner \((0, 0)\) of the rectangle; it "spikes" there as \(m \to 0\). The hypothesis of the theorem really matters.

3. Leibniz's rule: differentiating under the integral sign

Theorem 2 · Leibniz's rule If, in addition to the conditions of Theorem 1, the partial derivative \( f_m'(x, m) \) is continuous on \(R\), then for \( m \in (m_1, m_2) \) \[ \frac{d}{dm}\int_a^b f(x, m)\,dx = \int_a^b f_m'(x, m)\,dx. \]

In words: to differentiate the integral, differentiate the integrand with respect to the parameter, treating \(x\) as a constant. This is the famous technique Richard Feynman liked to call "differentiating under the integral sign".

Why it works: the difference quotient of \(I\) is

\[ \frac{I(m + h) - I(m)}{h} = \int_a^b \frac{f(x, m + h) - f(x, m)}{h}\,dx = \int_a^b f_m'(x, m + \theta h)\,dx \quad (0 < \theta < 1), \]

by the mean value theorem. Since \(f_m'\) is continuous, Theorem 1 lets us take the limit \(h \to 0\) inside the integral.

Example 2 · A whole family of integrals for free Start with \( \displaystyle\int_0^1 x^m\,dx = \frac{1}{m+1} \) (\(m > 0\)). Differentiate both sides with respect to \(m\). Since \( \frac{\partial}{\partial m}x^m = x^m\ln x \), \[ \int_0^1 x^m\ln x\,dx = -\frac{1}{(m+1)^2}. \] Differentiate again, and again: after \(n\) steps, \[ \int_0^1 x^m(\ln x)^n\,dx = \frac{(-1)^n\,n!}{(m+1)^{n+1}}. \] Computing these directly would need \(n\) integrations by parts each. Here they come out in one line.
Example 3 · Evaluating an integral by inventing a parameter Compute \( I(m) = \displaystyle\int_0^1 \frac{x^m - 1}{\ln x}\,dx \) for \(m \ge 0\). (The integrand extends continuously to \(x = 0\) and \(x = 1\).)

There is no elementary antiderivative in \(x\). But differentiating in \(m\) removes the troublesome \(\ln x\):

\[ I'(m) = \int_0^1 \frac{x^m\ln x}{\ln x}\,dx = \int_0^1 x^m\,dx = \frac{1}{m+1}. \] Hence \( I(m) = \ln(m+1) + C \). Since \(I(0) = \int_0^1 0\,dx = 0\), we get \(C = 0\): \[ \int_0^1 \frac{x^m - 1}{\ln x}\,dx = \ln(m+1). \]

4. Variable limits of integration

Often the limits of integration depend on the parameter too. Then \(m\) appears in three places, and each one contributes to the derivative.

General Leibniz rule Let \(f\) and \(f_m'\) be continuous on \(R\), and let \(\varphi(m)\), \(\psi(m)\) be differentiable functions with \( a \le \varphi(m) \le b \) and \( a \le \psi(m) \le b \) for \( m_1 < m < m_2 \). Then \[ \frac{d}{dm}\int_{\varphi(m)}^{\psi(m)} f(x, m)\,dx = f\big(\psi(m), m\big)\,\psi'(m) - f\big(\varphi(m), m\big)\,\varphi'(m) + \int_{\varphi(m)}^{\psi(m)} f_m'(x, m)\,dx. \]

How to remember it: think of the integral as a function \( F(\varphi, \psi, m) \) of three variables and use the chain rule:

The Fundamental Theorem of Calculus is the simplest special case: with \(f\) independent of \(m\), \(\varphi = a\) and \(\psi(m) = m\),

\[ \frac{d}{dm}\int_a^{m} f(x)\,dx = f(m). \]
Example 4 · Checking the rule two ways Let \( F(m) = \displaystyle\int_0^{m} \frac{\sin(mx)}{x}\,dx \) for \(m > 0\) (at \(x = 0\) the integrand equals \(m\) by continuity).

By the general rule: \( \psi(m) = m \), \( \varphi = 0 \), and \( \frac{\partial}{\partial m}\frac{\sin(mx)}{x} = \cos(mx) \):

\[ F'(m) = \frac{\sin(m^2)}{m}\cdot 1 + \int_0^m \cos(mx)\,dx = \frac{\sin(m^2)}{m} + \frac{\sin(m^2)}{m} = \frac{2\sin(m^2)}{m}. \]

Check by substitution: with \(t = mx\), \( F(m) = \int_0^{m^2} \frac{\sin t}{t}\,dt \), so by the FTC and chain rule \( F'(m) = \frac{\sin(m^2)}{m^2}\cdot 2m = \frac{2\sin(m^2)}{m} \). Same answer.

Example 5 · Solving a differential equation Show that \( y(x) = \displaystyle\int_0^{x} \sin(x - t)\,g(t)\,dt \) satisfies \( y'' + y = g(x) \) (for continuous \(g\)). Here \(x\) plays the role of the parameter. \[ y' = \underbrace{\sin(x - x)\,g(x)}_{=0} + \int_0^x \cos(x - t)\,g(t)\,dt, \qquad y'' = \underbrace{\cos 0\cdot g(x)}_{=g(x)} - \int_0^x \sin(x - t)\,g(t)\,dt = g(x) - y. \] So \( y'' + y = g \), with \(y(0) = y'(0) = 0\). Formulas like this are how engineers write down the response of a system to an arbitrary input.

5. Integrating with respect to the parameter

Theorem 3 · Changing the order of integration If \(f(x, m)\) is continuous on \(R\), then \[ \int_{m_1}^{m_2} dm\int_a^b f(x, m)\,dx = \int_a^b dx\int_{m_1}^{m_2} f(x, m)\,dm. \]

Both sides compute the same thing: the double integral of \(f\) over the rectangle \(R\), summed "row by row" or "column by column". In the language of this post: the function \(I(m)\) is continuous (Theorem 1), so it can be integrated, and its integral can be computed by integrating \(f\) in \(m\) first.

Example 6 · Writing a fraction as an integral Compute \( \displaystyle\int_0^1 \frac{x^b - x^a}{\ln x}\,dx \) for \(0 < a < b\).

The key observation: \( \dfrac{x^b - x^a}{\ln x} = \displaystyle\int_a^b x^m\,dm \) (integrate \(x^m = e^{m\ln x}\) in \(m\)). Therefore

\[ \int_0^1 \frac{x^b - x^a}{\ln x}\,dx = \int_0^1 dx\int_a^b x^m\,dm = \int_a^b dm\int_0^1 x^m\,dx = \int_a^b \frac{dm}{m+1} = \ln\frac{b+1}{a+1}. \] This agrees with Example 3 (\(a = 0\), \(b = m\)): two different swaps, same answer.
Continuity is not a formality For \( f(x, m) = \dfrac{x^2 - m^2}{(x^2 + m^2)^2} \) on \([0,1]\times[0,1]\), using \( \frac{\partial}{\partial m}\frac{m}{x^2 + m^2} = f \): \[ \int_0^1 dx\int_0^1 f\,dm = \int_0^1 \frac{dx}{1 + x^2} = \frac{\pi}{4}, \qquad \text{but} \qquad \int_0^1 dm\int_0^1 f\,dx = -\frac{\pi}{4}. \] The order matters here because \(f\) is unbounded (and discontinuous) at \((0, 0)\). Always check the hypotheses before swapping.

6. The parameter trick in action

Here is a slightly bigger example that shows the full strategy: start from an integral you can do, differentiate it with respect to a parameter, and read off a new result.

Example 7 For \(a, b > 0\), the substitution \(t = \operatorname{tg}x\) gives \[ J(a, b) = \int_0^{\pi/2} \frac{dx}{a^2\cos^2x + b^2\sin^2x} = \int_0^{\infty} \frac{dt}{a^2 + b^2t^2} = \frac{\pi}{2ab}. \] Differentiate with respect to \(a\) (Leibniz's rule applies, the integrand is smooth for \(a, b > 0\)): \[ -2a\int_0^{\pi/2} \frac{\cos^2x\,dx}{(a^2\cos^2x + b^2\sin^2x)^2} = -\frac{\pi}{2a^2b} \;\Longrightarrow\; \int_0^{\pi/2} \frac{\cos^2x\,dx}{(a^2\cos^2x + b^2\sin^2x)^2} = \frac{\pi}{4a^3b}. \] By symmetry (differentiate with respect to \(b\)): \( \int_0^{\pi/2} \frac{\sin^2x\,dx}{(\cdots)^2} = \frac{\pi}{4ab^3} \). Adding the two, since \( \cos^2x + \sin^2x = 1 \): \[ \int_0^{\pi/2} \frac{dx}{(a^2\cos^2x + b^2\sin^2x)^2} = \frac{\pi}{4ab}\left(\frac{1}{a^2} + \frac{1}{b^2}\right). \]

The general recipe:

  1. Introduce a parameter (or spot one already there) so that differentiating with respect to it simplifies the integrand.
  2. Differentiate under the integral sign and compute the easier integral \(I'(m)\).
  3. Integrate back in \(m\) to get \(I(m)\).
  4. Find the constant from a value of \(m\) where \(I(m)\) is obvious (often \(I = 0\)).

7. Summary

Operation on \(I(m)\)RuleCondition (on the rectangle \(R\))
Limit\( \lim_{m\to m_0} \int_a^b f\,dx = \int_a^b f(x, m_0)\,dx \)\(f\) continuous
Derivative\( \frac{d}{dm}\int_a^b f\,dx = \int_a^b f_m'\,dx \)\(f\) and \(f_m'\) continuous
Derivative, variable limits\( f(\psi, m)\psi' - f(\varphi, m)\varphi' + \int_\varphi^\psi f_m'\,dx \)as above, \(\varphi, \psi\) differentiable
Integral in \(m\)\( \int_{m_1}^{m_2} dm\int_a^b f\,dx = \int_a^b dx\int_{m_1}^{m_2} f\,dm \)\(f\) continuous

8. Practice problems

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

Problem 1: Find \( \displaystyle\lim_{m\to 0} \int_{-1}^{1} \sqrt{x^2 + m^2}\,dx \).

The integrand is continuous, so put \(m = 0\): \( \int_{-1}^{1} |x|\,dx = 1 \).

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

Differentiate \( \int_0^1 x^m\,dx = \frac{1}{m+1} \) twice with respect to \(m\) (Example 2 with \(n = 2\)).

Problem 3: Compute \( \displaystyle\int_0^1 \frac{x^3 - x}{\ln x}\,dx \).

Example 6 with \(a = 1\), \(b = 3\): \( \ln\frac{4}{2} = \ln 2 \).

Problem 4: Find \(F'(m)\) for \( F(m) = \displaystyle\int_{\sin m}^{\cos m} e^{m\sqrt{1 - x^2}}\,dx \), \( 0 < m < \frac{\pi}{2} \).

Using \( \sqrt{1 - \cos^2m} = \sin m \) and \( \sqrt{1 - \sin^2m} = \cos m \): \[ F'(m) = -\sin m\,e^{m\sin m} - \cos m\,e^{m\cos m} + \int_{\sin m}^{\cos m} \sqrt{1 - x^2}\,e^{m\sqrt{1 - x^2}}\,dx. \]

Problem 5: Show that \( y(x) = \displaystyle\int_0^x (x - t)\,g(t)\,dt \) satisfies \( y'' = g(x) \).

\( y' = (x - x)g(x) + \int_0^x g(t)\,dt = \int_0^x g(t)\,dt \), and then \( y'' = g(x) \) by the FTC.

Problem 6 (challenge): Compute \( I(m) = \displaystyle\int_0^{\pi/2} \ln\big(\cos^2x + m^2\sin^2x\big)\,dx \) for \(m > 0\).

Differentiate: \( I'(m) = \int_0^{\pi/2} \frac{2m\sin^2x}{\cos^2x + m^2\sin^2x}\,dx \). With \(t = \operatorname{tg}x\) and partial fractions (for \(m \ne 1\)), \[ I'(m) = \frac{2m}{m^2 - 1}\int_0^\infty\left(\frac{1}{1 + t^2} - \frac{1}{1 + m^2t^2}\right)dt = \frac{2m}{m^2 - 1}\left(\frac{\pi}{2} - \frac{\pi}{2m}\right) = \frac{\pi}{m + 1}. \] So \( I(m) = \pi\ln(m + 1) + C \). Since \( I(1) = \int_0^{\pi/2} \ln 1\,dx = 0 \), \( C = -\pi\ln 2 \), and \[ I(m) = \pi\ln\frac{1 + m}{2}. \]

Final thoughts

All three theorems in this post say the same thing in different forms: when the integrand is continuous on a closed rectangle, you may swap the integral with a limit, a derivative or another integral. That freedom turns into a powerful technique. When an integral resists every substitution, try embedding it in a family \(I(m)\), and let calculus in \(m\) do the work.

Next in the series: functions defined by improper integrals, uniform convergence, and the Gamma and Beta functions.