SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 2.6.1 Integration by substitutionConcept · 30 min
      2. 2.6.2 Integration by partsConcept · 30 min
      3. 2.6.3 Improper integrals and the Gaussian integralConcept · 35 min
      4. 2.6.4 Practice set: integration techniquesPractice set · 25 min
      5. 2.6.5 Case study: the normal integrals behind Black–ScholesCase study · 35 min

Level 2, Single-variable calculus 2.6 Integration techniques Lesson 1 of 5

ConceptLesson 2.6.1 in Level 2, Single-variable calculus. About 30 minutes.

Integration by substitution

The chain rule, backwards

The chain rule (lesson 2.3.3) differentiates a function inside a function. Take the slope of the outer function, then multiply by the slope of the inner one. So an integrand of that shape, an outer function ff applied to g(x)g(x) and multiplied by g′(x)g'(x), is a derivative you can recognise.

Take (x2+1)4(x^2 + 1)^4. The inner function x2+1x^2 + 1 has slope 2x2x, so the chain rule gives

ddx(x2+1)4=4(x2+1)3⋅2x=8x(x2+1)3\begin{aligned} \frac{d}{dx}(x^2 + 1)^4 &= 4(x^2 + 1)^3 \cdot 2x \\ &= 8x(x^2 + 1)^3 \end{aligned}

Read backwards, ∫8x(x2+1)3 dx=(x2+1)4+C\int 8x(x^2 + 1)^3\,dx = (x^2 + 1)^4 + C. Dividing by 4 gives ∫2x(x2+1)3 dx=(x2+1)44+C\int 2x(x^2 + 1)^3\,dx = \frac{(x^2 + 1)^4}{4} + C.

Renaming the inside

Substitution does this reading backwards for you. Call the inner function u=x2+1u = x^2 + 1.

Its slope is dudx=2x\frac{du}{dx} = 2x, written du=2x dxdu = 2x\,dx. A small step dxdx in xx moves uu by 2x2x times as much: the stretch factor of lesson 2.3.3.

Now each piece of the integrand has a uu version: (x2+1)3(x^2 + 1)^3 is u3u^3, and 2x dx2x\,dx is dudu. The integral becomes one in uu alone:

∫2x(x2+1)3 dx=∫u3 du=u44+C=(x2+1)44+C\begin{aligned} \int 2x(x^2 + 1)^3\,dx &= \int u^3\,du \\ &= \frac{u^4}{4} + C \\ &= \frac{(x^2 + 1)^4}{4} + C \end{aligned}

Rule: Substitution

∫f(g(x)) g′(x) dx=∫f(u) duwith u=g(x), du=g′(x) dx\begin{gathered} \int f\big(g(x)\big)\,g'(x)\,dx \\ = \int f(u)\,du \\[4pt] \text{with } u = g(x), \ du = g'(x)\,dx \end{gathered}

Choose the inner function as uu. Replace g′(x) dxg'(x)\,dx by dudu, so that no xx is left. Integrate in uu, put u=g(x)u = g(x) back, and check by differentiating.

A missing constant

In ∫x ex2 dx\int x\,e^{x^2}\,dx the inner function is the exponent, u=x2u = x^2. Its derivative is 2x2x, but the integrand has only xx. A missing constant can be fixed: du=2x dxdu = 2x\,dx gives x dx=12dux\,dx = \frac{1}{2}du.

  1. 1
    u=x2,du=2x dxx dx=12 du\begin{gathered} u = x^2, \quad du = 2x\,dx \\ x\,dx = \tfrac{1}{2}\,du \end{gathered}
  2. 2
    ∫x ex2 dx=12∫eu du\int x\,e^{x^2}\,dx = \frac{1}{2}\int e^u\,du
  3. 3
    12eu+C=12ex2+C\frac{1}{2}e^u + C = \frac{1}{2}e^{x^2} + C

Check with the chain rule: ddx 12ex2=12ex2⋅2x=x ex2\frac{d}{dx}\,\frac{1}{2}e^{x^2} = \frac{1}{2}e^{x^2} \cdot 2x = x\,e^{x^2}.

Only a constant can be fixed this way. In ∫ex2 dx\int e^{x^2}\,dx there is no xx in front to turn into dudu, and substitution fails (see the last section).

Choosing uu

Look for a function sitting inside something else: inside a power, an exponent, a root, a log or the bottom of a fraction. Then check that its derivative appears as a factor, up to a constant. Each line of the table leaves out the +C+ C.

integranduududuantiderivative
(3x+1)5(3x + 1)^53x+13x + 13 dx3\,dx(3x+1)618\frac{(3x + 1)^6}{18}
xx2+1\frac{x}{x^2 + 1}x2+1x^2 + 12x dx2x\,dx12ln⁡(x2+1)\frac{1}{2}\ln(x^2 + 1)
ln⁡xx\frac{\ln x}{x}ln⁡x\ln x1x dx\frac{1}{x}\,dx(ln⁡x)22\frac{(\ln x)^2}{2}
xx2+9x\sqrt{x^2 + 9}x2+9x^2 + 92x dx2x\,dx(x2+9)3/23\frac{(x^2 + 9)^{3/2}}{3}
x e−x2x\,e^{-x^2}−x2-x^2−2x dx-2x\,dx−12e−x2-\frac{1}{2}e^{-x^2}
(5−2x)3(5 - 2x)^35−2x5 - 2x−2 dx-2\,dx−(5−2x)48-\frac{(5 - 2x)^4}{8}

The first row has a linear inner function, u=3x+1u = 3x + 1. Its derivative is the constant 3, so it is always there: dx=13dudx = \frac{1}{3}du, and the answer gains a factor 13\frac{1}{3}. This is the rule ∫ekx dx=ekxk+C\int e^{kx}\,dx = \frac{e^{kx}}{k} + C of lesson 2.5.2, now for any outer function.

In the second row ln⁡(x2+1)\ln(x^2 + 1) needs no absolute value (lesson 2.5.2), because x2+1x^2 + 1 is always positive. In the third, the log itself is the inner function, and 1x\frac{1}{x} is its derivative.

The last two rows have inner functions that fall, with negative slope. The minus sign in dudu comes through to the answer. Lesson 2.6.3 meets x e−x2x\,e^{-x^2} again, under the bell curve.

Try it

The cell differentiates each answer in the table, and the first example, then subtracts the integrand. A check of 0 means the answer is right.

SymPy writes ln⁡\ln as log. sp.Rational(3, 2) is the exact fraction 32\frac{3}{2}.

⌘/Ctrl + Enter runs the cell

Definite integrals: change the limits

A definite integral can be finished in two ways, and they give the same number.

  1. Change the limits. Turn each limit into a value of uu and finish in uu, without going back to xx.
  2. Switch back. Find the antiderivative in xx first, then use the original limits, as in lesson 2.5.3.

Take ∫012xx2+1 dx\int_0^1 \frac{2x}{x^2 + 1}\,dx with u=x2+1u = x^2 + 1 and du=2x dxdu = 2x\,dx. At x=0x = 0, u=1u = 1; at x=1x = 1, u=2u = 2. So

∫012xx2+1 dx=∫121u du=ln⁡2−ln⁡1=ln⁡2\begin{aligned} \int_0^1 \frac{2x}{x^2 + 1}\,dx &= \int_1^2 \frac{1}{u}\,du \\ &= \ln 2 - \ln 1 = \ln 2 \end{aligned}

Switching back gives the same: [ln⁡(x2+1)]01=ln⁡2−ln⁡1=ln⁡2\big[\ln(x^2 + 1)\big]_0^1 = \ln 2 - \ln 1 = \ln 2.

Rule: Substitution with limits

∫abf(g(x)) g′(x) dx=∫g(a)g(b)f(u) du\begin{gathered} \int_a^b f\big(g(x)\big)\,g'(x)\,dx \\ = \int_{g(a)}^{g(b)} f(u)\,du \end{gathered}

The new limits are the values of uu at the old ones. The value from the old lower limit stays at the bottom, even when it is the larger one.

One area, two curves

Substitution does not change an area; it redraws it. The two integrals above measure regions under different curves, over different intervals, and the regions have the same area.

The same area before and after the substitution u=x2+1u = x^2 + 1. The highlighted strip is wider on the uu side and lower by the same factor, so its area, 0.0843, does not change.

A strip of width dxdx becomes a strip of width du=2x dxdu = 2x\,dx, so it is 2x2x times as wide. Its height 2xx2+1\frac{2x}{x^2 + 1} becomes 1u\frac{1}{u}, which is 2x2x times lower. The two factors cancel, and every strip keeps its area.

Midpoint sums (lesson 2.5.1) with equal strips show it in numbers. The two curves have different shapes, so the sums differ at first, but both settle on ln⁡2≈0.693147\ln 2 \approx 0.693147.

strips4101001000
∫012xx2+1 dx\int_0^1 \frac{2x}{x^2 + 1}\,dx0.6984290.6939820.6931560.693147
∫121u du\int_1^2 \frac{1}{u}\,du0.691220.6928350.6931440.693147

Try it

mid(f, a, b, n) is the midpoint sum with n strips. The loop prints both sides of the table, then ln⁡2\ln 2.

The last line measures the highlighted strip on each side: 0.084341 both times.

⌘/Ctrl + Enter runs the cell

When the new limits run backwards

In ∫01x(1−x2)3 dx\int_0^1 x(1 - x^2)^3\,dx, take u=1−x2u = 1 - x^2. Then du=−2x dxdu = -2x\,dx, so x dx=−12dux\,dx = -\frac{1}{2}du. At x=0x = 0, u=1u = 1, and at x=1x = 1, u=0u = 0: the new integral runs from 1 down to 0.

∫01x(1−x2)3 dx=−12∫10u3 du=12∫01u3 du=18\begin{aligned} \int_0^1 x(1 - x^2)^3\,dx &= -\frac{1}{2}\int_1^0 u^3\,du \\ &= \frac{1}{2}\int_0^1 u^3\,du = \frac{1}{8} \end{aligned}

Swapping the limits flips the sign (lesson 2.5.3), which cancels the minus sign from dudu.

Switching back instead

For ∫1eln⁡xx dx\int_1^e \frac{\ln x}{x}\,dx, the table gives the antiderivative (ln⁡x)22\frac{(\ln x)^2}{2}. With the original limits, (ln⁡e)22−(ln⁡1)22=12−0=12\frac{(\ln e)^2}{2} - \frac{(\ln 1)^2}{2} = \frac{1}{2} - 0 = \frac{1}{2}. Changing the limits instead gives ∫01u du=12\int_0^1 u\,du = \frac{1}{2}.

Try it

Each line computes an integral in xx and again in uu with the new limits. They agree.

The last line keeps the old limits by mistake: ∫01u3 du=14\int_0^1 u^3\,du = \frac{1}{4}, not the correct 154\frac{15}{4}.

⌘/Ctrl + Enter runs the cell

When substitution does not help

Substitution needs the derivative of the inside to be in the integral. Here are three cases where it is not.

  • The missing factor is not a constant. ∫ex2 dx\int e^{x^2}\,dx has nothing to pair with du=2x dxdu = 2x\,dx. Forcing u=x2u = x^2 gives ∫eu2u du\int \frac{e^u}{2\sqrt{u}}\,du, which is no easier. In fact ex2e^{x^2} has no antiderivative made of familiar functions; SymPy needs a new one, erfi.
  • There is a simpler route. ∫(x2+1)2 dx\int (x^2 + 1)^2\,dx lacks the 2x2x, but multiplying out (lesson 2.5.2) gives x55+2x33+x+C\frac{x^5}{5} + \frac{2x^3}{3} + x + C.
  • A product of two kinds of function, such as x exx\,e^x. Neither factor is the derivative of an inside. Lesson 2.6.2 handles these with integration by parts.

Dividing by a missing 2x2x does not work either. The derivative of ex22x\frac{e^{x^2}}{2x} is (1−12x2)ex2\left(1 - \frac{1}{2x^2}\right)e^{x^2}, not ex2e^{x^2}. Lesson 2.6.3 meets the close relative e−x2e^{-x^2}, whose area is found another way.

Try it

SymPy's answer for ex2e^{x^2} uses erfi, a function defined by this very integral. The second line multiplies out instead.

The third line differentiates the wrong answer ex22x\frac{e^{x^2}}{2x}. SymPy writes the result as (x2−12)ex2x2\frac{(x^2 - \frac{1}{2})e^{x^2}}{x^2}, the same as above.

⌘/Ctrl + Enter runs the cell

Case study 2.6.5 uses a substitution to turn part of an option price into an area under the bell curve.

Common mistakes

  1. Convert dxdx as well. ∫(3x+1)5 dx\int (3x + 1)^5\,dx is (3x+1)618+C\frac{(3x + 1)^6}{18} + C, not (3x+1)66+C\frac{(3x + 1)^6}{6} + C, whose derivative is 3(3x+1)53(3x + 1)^5.
  2. Leave no xx behind. An integral with both uu and xx in it cannot be done in uu.
  3. Only a constant can be fixed. ex22x\frac{e^{x^2}}{2x} is not an antiderivative of ex2e^{x^2}.
  4. Keep the minus sign from a falling inner function: ∫x e−x2 dx=−12e−x2+C\int x\,e^{-x^2}\,dx = -\frac{1}{2}e^{-x^2} + C.
  5. Change the limits with the variable. ∫012x(x2+1)3 dx=∫12u3 du=154\int_0^1 2x(x^2 + 1)^3\,dx = \int_1^2 u^3\,du = \frac{15}{4}. Keeping the old limits gives 14\frac{1}{4}.
  6. Keep the new limits in order. When uu falls, the new lower limit is the larger number. Swap them only if you also flip the sign.
  7. Choose one way to finish. After changing the limits, finish in uu; do not also put xx back.

Substitution

0 of 12 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • Substitution reverses the chain rule: ∫f(g(x)) g′(x) dx=∫f(u) du\int f(g(x))\,g'(x)\,dx = \int f(u)\,du with u=g(x)u = g(x) and du=g′(x) dxdu = g'(x)\,dx.
  • Choose an inner function whose derivative is also there; a missing constant can be fixed, a missing xx cannot.
  • A linear inside ax+bax + b always works: the answer gains a factor 1a\frac{1}{a}.
  • For a definite integral, change the limits to u=g(a)u = g(a) and u=g(b)u = g(b), or switch back to xx and use the old ones.
  • The substitution redraws the area under a new curve; the area itself does not change.
  • It fails when the derivative of the inside is missing, as for ex2e^{x^2}, or when the integrand is a product like x exx\,e^x.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.

  • Calculus I

    Paul's Online Notes. Notes.

    Limits, derivatives and integrals in short sections with worked examples and practice.

  • 18.01SC Single Variable Calculus

    MIT OpenCourseWare. Course.

    Full lectures, recitation videos and problem sets with solutions.