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 2 of 5

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

Integration by parts

The product rule, backwards

Substitution (lesson 2.6.1) undoes the chain rule. Integration by parts undoes the product rule. It turns the integral of a product into a different integral, in which one factor has been differentiated and the other integrated.

Call the two factors uu and vv. The product rule (lesson 2.3.2) says (uv)′=u′v+uv′(uv)' = u'v + uv'.

Integrate both sides: the left side gives back uvuv, so uv=∫u′v dx+∫uv′ dxuv = \int u'v\,dx + \int uv'\,dx. Move one integral across and

∫u v′ dx=uv−∫u′ v dx\int u\,v'\,dx = uv - \int u'\,v\,dx

The shorthand dv=v′ dxdv = v'\,dx and du=u′ dxdu = u'\,dx, as in lesson 2.6.1, gives the usual form.

Rule: Integration by parts

∫u dv=uv−∫v du\int u\,dv = uv - \int v\,du

Split the integrand into uu, a factor to differentiate, and dvdv, a factor to integrate. Then du=u′ dxdu = u'\,dx, and vv is any antiderivative of dvdv; the +C+ C waits until the end. The method helps when ∫v du\int v\,du is easier than the integral you started with.

A first example: x exx\,e^x

In ∫x ex dx\int x\,e^x\,dx, differentiating xx gives 1, which is simpler. Integrating exe^x gives exe^x again, which is no worse. So choose u=xu = x and dv=ex dxdv = e^x\,dx.

  1. 1
    u=x,dv=ex dxdu=dx,v=ex\begin{gathered} u = x, \quad dv = e^x\,dx \\ du = dx, \quad v = e^x \end{gathered}
  2. 2
    ∫x ex dx=x ex−∫ex dx\begin{aligned} &\int x\,e^x\,dx \\ &= x\,e^x - \int e^x\,dx \end{aligned}
  3. 3
    ∫x ex dx=x ex−ex+C=(x−1) ex+C\begin{aligned} &\int x\,e^x\,dx \\ &= x\,e^x - e^x + C \\ &= (x - 1)\,e^x + C \end{aligned}

Check with the product rule: ddx[(x−1)ex]=ex+(x−1)ex=x ex\frac{d}{dx}\big[(x - 1)e^x\big] = e^x + (x - 1)e^x = x\,e^x.

Numbers agree too. With F(x)=(x−1)exF(x) = (x - 1)e^x, the area under t ett\,e^t from 0 to xx is F(x)−F(0)=(x−1)ex+1F(x) - F(0) = (x - 1)e^x + 1 (lesson 2.5.3). A numerical integral gives the same values.

right edge xx0.512
area from 0 to xx, by quad0.17563918.389056
(x−1)ex+1(x - 1)e^x + 10.17563918.389056

Try it

quad(f, a, b) (lesson 2.5.3) integrates numerically; [0] keeps the value. The loop prints both rows of the table.

SymPy then integrates x exx\,e^x by itself and gets the same antiderivative.

⌘/Ctrl + Enter runs the cell

The area picture

Lesson 2.3.2 drew the product uvuv as the area of a rectangle. Integration by parts splits that rectangle into two pieces, one for each integral.

Take ∫1eln⁡x dx\int_1^e \ln x\,dx with u=ln⁡xu = \ln x and v=xv = x. As xx runs from 1 to ee, the point (v,u)=(x,ln⁡x)(v, u) = (x, \ln x) traces a curve from (1,0)(1, 0) to (e,1)(e, 1).

The rectangle out to (e,1)(e, 1) has area ee. The curve u=ln⁡vu = \ln v splits it into ∫u dv=1\int u\,dv = 1, under the curve, and ∫v du=e−1\int v\,du = e - 1, beside it.

  • Under the curve, measured along the vv axis, is ∫u dv=∫1eln⁡x dx\int u\,dv = \int_1^e \ln x\,dx, the integral we want.
  • Beside the curve, measured along the uu axis, is ∫v du\int v\,du. Here uu runs from 0 to 1 and v=euv = e^u, so this area is ∫01eu du=e−1\int_0^1 e^u\,du = e - 1.
  • Together they fill the rectangle e×1e \times 1. The value uvuv at the start is 1×0=01 \times 0 = 0, so nothing is cut off there.

So ∫1eln⁡x dx=e−(e−1)=1\int_1^e \ln x\,dx = e - (e - 1) = 1. In general [uv][uv] is the rectangle at the end minus the rectangle at the start, and the two integrals share what is left.

Choosing the parts

Choose uu to be the factor that gets simpler when you differentiate it. Choose dvdv to be a factor you can integrate, and that does not get worse. Each line of the table leaves out the +C+ C.

integranduudvdvantiderivative
x e2xx\,e^{2x}xxe2x dxe^{2x}\,dx(2x−1)e2x4\frac{(2x - 1)e^{2x}}{4}
x e−xx\,e^{-x}xxe−x dxe^{-x}\,dx−(x+1)e−x-(x + 1)e^{-x}
ln⁡x\ln xln⁡x\ln xdxdxxln⁡x−xx\ln x - x
xln⁡xx\ln xln⁡x\ln xx dxx\,dxx2ln⁡x2−x24\frac{x^2\ln x}{2} - \frac{x^2}{4}
  • A log goes in uu. Its derivative 1x\frac{1}{x} is simpler, and it is hard to integrate. For ln⁡x\ln x alone, the other factor is an unseen 1, so dv=dxdv = dx and v=xv = x.
  • Otherwise a power of xx goes in uu. Each derivative lowers its power by one.
  • Watch the sign of vv. For dv=e−x dxdv = e^{-x}\,dx, v=−e−xv = -e^{-x}: dividing by k=−1k = -1, as in lesson 2.5.2. So ∫x e−x dx=−x e−x+∫e−x dx=−(x+1)e−x+C\int x\,e^{-x}\,dx = -x\,e^{-x} + \int e^{-x}\,dx = -(x + 1)e^{-x} + C.

The other choice for x exx\,e^x shows what goes wrong. With u=exu = e^x and dv=x dxdv = x\,dx, v=x22v = \frac{x^2}{2} and the new integral is ∫x22ex dx\int \frac{x^2}{2}e^x\,dx. The power of xx went up, so the integral got harder.

Try it

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

The last line is the bad choice: the integral it leaves behind contains x2x^2, a higher power than before.

⌘/Ctrl + Enter runs the cell

Parts with limits

For a definite integral, evaluate uvuv at both limits, as in the fundamental theorem (lesson 2.5.3).

Rule: Parts with limits

∫abu dv=[uv]ab−∫abv du\int_a^b u\,dv = \big[uv\big]_a^b - \int_a^b v\,du

[uv]ab\big[uv\big]_a^b means uvuv at bb minus uvuv at aa. Both terms use the same limits.

For ∫01x e−x dx\int_0^1 x\,e^{-x}\,dx, take u=xu = x and v=−e−xv = -e^{-x}:

∫01x e−x dx=[−x e−x]01+∫01e−x dx=−e−1+(1−e−1)=1−2e\begin{aligned} &\int_0^1 x\,e^{-x}\,dx \\ &= \big[-x\,e^{-x}\big]_0^1 + \int_0^1 e^{-x}\,dx \\ &= -e^{-1} + \left(1 - e^{-1}\right) = 1 - \frac{2}{e} \end{aligned}

That is about 0.264241. The figure's integral works the same way: ∫1eln⁡x dx=[xln⁡x]1e−∫1e1 dx=e−(e−1)=1\int_1^e \ln x\,dx = \big[x\ln x\big]_1^e - \int_1^e 1\,dx = e - (e - 1) = 1.

Repeated parts

One round of parts lowers a power of xx by one. If a power is still left, use parts again.

For ∫x2ex dx\int x^2 e^x\,dx, take u=x2u = x^2 and dv=ex dxdv = e^x\,dx. Then ∫x2ex dx=x2ex−∫2x ex dx\int x^2 e^x\,dx = x^2 e^x - \int 2x\,e^x\,dx. The new integral is twice the first example, 2(x−1)ex2(x - 1)e^x, so

∫x2ex dx=(x2−2x+2) ex+C\int x^2 e^x\,dx = (x^2 - 2x + 2)\,e^x + C

With limits, ∫01x2ex dx=(1−2+2)e−2=e−2≈0.718282\int_0^1 x^2 e^x\,dx = (1 - 2 + 2)e - 2 = e - 2 \approx 0.718282. A cube needs three rounds: ∫x3ex dx=(x3−3x2+6x−6)ex+C\int x^3 e^x\,dx = (x^3 - 3x^2 + 6x - 6)e^x + C.

An integral that comes back

Sometimes parts brings back the integral you started with. Then treat it as an unknown and solve for it, as in lesson 0.3.2.

Call I=∫ln⁡xx dxI = \int \frac{\ln x}{x}\,dx. Take u=ln⁡xu = \ln x and dv=1x dxdv = \frac{1}{x}\,dx, so du=1x dxdu = \frac{1}{x}\,dx and v=ln⁡xv = \ln x. Parts gives

I=(ln⁡x)2−∫ln⁡xx dx=(ln⁡x)2−I\begin{aligned} I &= (\ln x)^2 - \int \frac{\ln x}{x}\,dx \\ &= (\ln x)^2 - I \end{aligned}

Add II to both sides: 2I=(ln⁡x)22I = (\ln x)^2, so I=(ln⁡x)22+CI = \frac{(\ln x)^2}{2} + C. Substitution found the same answer in lesson 2.6.1.

The best-known case is ∫exsin⁡x dx\int e^x \sin x\,dx, where two rounds bring it back. It needs the slopes of sin⁡x\sin x and cos⁡x\cos x from lesson 2.3.5: cos⁡x\cos x and −sin⁡x-\sin x. The answer is 12ex(sin⁡x−cos⁡x)+C\frac{1}{2}e^x(\sin x - \cos x) + C.

Try it

The cell checks the two repeated-parts answers, the integral that came back, and the exsin⁡xe^x \sin x answer, each by differentiating. Then it computes ∫01x2ex dx\int_0^1 x^2 e^x\,dx.

SymPy writes ee as E, so e−2e - 2 appears as -2 + E.

⌘/Ctrl + Enter runs the cell

When parts does not help

Parts needs a factor you can integrate. In ∫x ex2 dx\int x\,e^{x^2}\,dx, the choice u=xu = x would need v=∫ex2 dxv = \int e^{x^2}\,dx, which has no formula. Substitution (lesson 2.6.1) does it in one line: 12ex2+C\frac{1}{2}e^{x^2} + C.

Some integrals defeat both methods. For ∫ex2 dx\int e^{x^2}\,dx, parts with u=ex2u = e^{x^2} and dv=dxdv = dx gives x ex2−∫2x2ex2 dxx\,e^{x^2} - \int 2x^2 e^{x^2}\,dx, which is worse. Lesson 2.6.3 finds areas under the related bell curve e−x2e^{-x^2} by other means.

A rule of thumb: first look for an inside and its derivative (substitution). If there is none, and the integrand is a power or a log times something you can integrate, try parts. Lesson 2.6.3 uses parts to find the area under x e−xx\,e^{-x} out to infinity.

Common mistakes

  1. Choose uu to get simpler. With u=exu = e^x and dv=x dxdv = x\,dx, the new integral ∫x22ex dx\int \frac{x^2}{2}e^x\,dx is harder.
  2. Keep the minus sign in uv−∫v duuv - \int v\,du.
  3. Get the sign of vv right. For dv=e−x dxdv = e^{-x}\,dx, v=−e−xv = -e^{-x}, not e−xe^{-x}.
  4. Use both limits on uvuv. [uv]ab\big[uv\big]_a^b is the value at bb minus the value at aa, even when the second is not 0.
  5. Keep going while a power is left. ∫x2ex dx\int x^2 e^x\,dx needs two rounds.
  6. When the integral comes back, solve for it. I=(ln⁡x)2−II = (\ln x)^2 - I gives 2I=(ln⁡x)22I = (\ln x)^2.
  7. Try substitution first when an inside and its derivative are both there.

Integration by parts

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

  • Integration by parts reverses the product rule: ∫u dv=uv−∫v du\int u\,dv = uv - \int v\,du.
  • Choose uu to get simpler when differentiated (a log first, then a power of xx) and dvdv easy to integrate.
  • With limits: ∫abu dv=[uv]ab−∫abv du\int_a^b u\,dv = \big[uv\big]_a^b - \int_a^b v\,du. As areas, [uv][uv] is a rectangle split between the two integrals.
  • Repeat while a power of xx is left; if the starting integral comes back, solve for it.
  • ∫x ex dx=(x−1)ex+C\int x\,e^x\,dx = (x - 1)e^x + C and ∫ln⁡x dx=xln⁡x−x+C\int \ln x\,dx = x\ln x - x + C.
  • Try substitution first when an inside and its derivative are both present.

Free further reading

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

  • Calculus II

    Paul's Online Notes. Notes.

    Integration techniques, improper integrals, sequences and series.

  • 18.01SC Single Variable Calculus

    MIT OpenCourseWare. Course.

    Full lectures, recitation videos and problem sets with solutions.