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

ConceptLesson 2.6.3 in Level 2, Single-variable calculus. About 35 minutes.

Improper integrals and the Gaussian integral

Integrating to infinity

The fundamental theorem (lesson 2.5.3) needs a finite interval and a curve that stays finite on it. An improper integral breaks one of the two. The first kind runs to infinity: ∫1∞1x2 dx\int_1^\infty \frac{1}{x^2}\,dx asks for the area under 1x2\frac{1}{x^2} from 1 onwards, for ever.

The plan is to integrate up to a finite right edge bb, then let bb grow (lesson 2.1.3).

Rule: Improper integral

∫a∞f(x) dx=lim⁡b→∞∫abf(x) dx\int_a^{\infty} f(x)\,dx = \lim_{b \to \infty} \int_a^b f(x)\,dx

If the limit is a number, the integral converges to it. If not, it diverges: the area grows without end, or never settles. The units are those of any integral: the height's units times the input's.

Here ∫1b1x2 dx=[−1x]1b=1−1b\int_1^b \frac{1}{x^2}\,dx = \left[-\frac{1}{x}\right]_1^b = 1 - \frac{1}{b}, which tends to 1. But ∫1b1x dx=ln⁡b\int_1^b \frac{1}{x}\,dx = \ln b, which grows without end.

right edge bb101001000
∫1b1x2 dx\int_1^b \frac{1}{x^2}\,dx0.90.990.999
∫1b1x dx\int_1^b \frac{1}{x}\,dx2.3025854.605176.907755

Both curves sink towards 0, but only 1x2\frac{1}{x^2} sinks fast enough. Its area from 1 to bb levels off at 1; the area under 1x\frac{1}{x} climbs by 2.30 every time bb is multiplied by 10.

A curve that sinks to 0 can still enclose infinite area. At x=10x = 10, 1x2\frac{1}{x^2} is 0.01 while 1x\frac{1}{x} is 0.1, and the gap keeps widening. The harmonic series of lesson 1.5.3 diverges in the same way.

Powers: which tails converge

For any power p≠1p \neq 1, the power rule backwards (lesson 2.5.2) gives

∫1b1xp dx=b1−p−11−p\int_1^b \frac{1}{x^p}\,dx = \frac{b^{1-p} - 1}{1 - p}

If p>1p > 1, the exponent 1−p1 - p is negative, so b1−p→0b^{1-p} \to 0 and the integral tends to 1p−1\frac{1}{p - 1}. If p<1p < 1, b1−pb^{1-p} grows without end. The case p=1p = 1 is the ln⁡b\ln b above.

ppb=10b = 10b=100b = 100b=1000b = 1000b=106b = 10^6as b→∞b \to \infty
0.54.3245551861.2455531998diverges
12.3025854.605176.90775513.815511diverges
1.51.3675441.81.9367541.9982
20.90.990.9990.9999991

Rule: Tails of powers

∫1∞1xp dx=1p−1for p>1\int_1^{\infty} \frac{1}{x^p}\,dx = \frac{1}{p - 1} \quad \text{for } p > 1

For p≤1p \le 1 the integral diverges. The boundary case p=1p = 1 diverges very slowly: ln⁡b\ln b reaches only 13.8 at bb = one million.

Try it

area(p, b) is the formula above, with ln⁡b\ln b for p=1p = 1. The loop prints the table; the rows for p=2p = 2 and p=1p = 1 also give the first table.

SymPy writes infinity as sp.oo (two letters o). It confirms the limits for p=2p = 2 and p=1.5p = 1.5, and answers oo for p=1p = 1.

⌘/Ctrl + Enter runs the cell

Exponential tails

Exponentials sink much faster than any power. ∫0be−x dx=1−e−b\int_0^b e^{-x}\,dx = 1 - e^{-b}, which tends to 1.

In general ∫0∞e−kx dx=1k\int_0^\infty e^{-kx}\,dx = \frac{1}{k} for any k>0k > 0, using ∫e−kx dx=−e−kxk\int e^{-kx}\,dx = -\frac{e^{-kx}}{k} from lesson 2.5.2. For k≤0k \le 0 the curve does not sink at all, and the integral diverges.

A power times an exponential still converges. By parts (lesson 2.6.2), ∫0bx e−x dx=[−(x+1)e−x]0b=1−(b+1)e−b\int_0^b x\,e^{-x}\,dx = \big[-(x + 1)e^{-x}\big]_0^b = 1 - (b + 1)e^{-b}. Since ebe^b outgrows every power of bb (lesson 2.1.3), (b+1)e−b→0(b + 1)e^{-b} \to 0 and the area is 1.

The finite pieces get there fast: 0.95957232 at b=5b = 5, 0.9995006 at b=10b = 10 and 0.99999996 at b=20b = 20. A higher power changes the value but not the verdict: ∫0∞x2e−x dx=2\int_0^\infty x^2 e^{-x}\,dx = 2.

Try it

SciPy's quad accepts an infinite limit, written math.inf. It finds the four tails of this section.

The last line prints 1−(b+1)e−b1 - (b + 1)e^{-b} for three edges. round hides float noise in the last digit.

⌘/Ctrl + Enter runs the cell

A curve that blows up

The second kind of improper integral has a curve that blows up (lesson 2.1.2) at an end of the interval. In ∫011x dx\int_0^1 \frac{1}{\sqrt{x}}\,dx, the curve has no value at 0. Start at a small a>0a > 0 instead, then let aa shrink to 0 from the right.

Here ∫a1x−1/2 dx=[2x]a1=2−2a\int_a^1 x^{-1/2}\,dx = \big[2\sqrt{x}\big]_a^1 = 2 - 2\sqrt{a}, which tends to 2. But ∫a11x dx=−ln⁡a\int_a^1 \frac{1}{x}\,dx = -\ln a, which grows without end.

left edge aa0.010.00010.000001
∫a11x dx\int_a^1 \frac{1}{\sqrt{x}}\,dx1.81.981.998
∫a11x dx\int_a^1 \frac{1}{x}\,dx4.605179.2103413.815511

Rule: Blow-ups of powers at 0

∫011xp dx=11−pfor p<1\int_0^1 \frac{1}{x^p}\,dx = \frac{1}{1 - p} \quad \text{for } p < 1

For p≥1p \ge 1 the integral diverges. This is the other way round from tails. Near 0 a small power blows up gently enough; far out, a large power is needed.

A blow-up inside the interval

Lesson 2.5.3 showed that ∫−111x2 dx\int_{-1}^{1} \frac{1}{x^2}\,dx is not −2-2: the curve blows up at 0, inside the interval. Split the integral there into ∫−10\int_{-1}^{0} and ∫01\int_{0}^{1}, so each piece has its trouble at an end.

By the rule above with p=2p = 2, ∫011x2 dx\int_0^1 \frac{1}{x^2}\,dx diverges, so the whole integral diverges. By contrast, ∫−111∣x∣ dx\int_{-1}^{1} \frac{1}{\sqrt{|x|}}\,dx splits into two pieces of 2, so it converges to 4.

Infinite at both ends

An integral over the whole line has two infinite ends. Split it at any point, such as 0, and each half must converge on its own.

∫−bbx dx=0\int_{-b}^{b} x\,dx = 0 for every bb, because the two sides cancel. But ∫0∞x dx\int_0^\infty x\,dx diverges, so ∫−∞∞x dx\int_{-\infty}^{\infty} x\,dx diverges too. Cancelling two infinite areas does not give a number.

Rule: Split at every trouble spot

∫−∞∞f dx=∫−∞0f dx+∫0∞f dx\begin{gathered} \int_{-\infty}^{\infty} f\,dx \\ = \int_{-\infty}^{0} f\,dx + \int_{0}^{\infty} f\,dx \end{gathered}

Split an integral so that each piece has only one trouble spot: one infinite end, or one blow-up at an end. The whole converges only if every piece converges.

Try it

The first line prints the table, 2−2a2 - 2\sqrt{a} and −ln⁡a-\ln a. SymPy then finds each limit: 2 for 1x\frac{1}{\sqrt{x}}, oo for 1x\frac{1}{x}, and oo for 1x2\frac{1}{x^2} across 0.

quad adds the two halves of 1∣x∣\frac{1}{\sqrt{|x|}}. The last line shows the trap: the symmetric pieces give 0, but one half alone is infinite.

⌘/Ctrl + Enter runs the cell

The Gaussian integral

The curve e−x2e^{-x^2} is a bell: 1 at x=0x = 0, falling fast on both sides. Lesson 2.5.2 noted that it has no antiderivative made of powers, roots, exponentials and logs.

The natural guess shows why. The chain rule suggests trying F=R(x) e−x2F = R(x)\,e^{-x^2} with RR a polynomial; the product rule then gives F′=(R′−2xR) e−x2F' = (R' - 2xR)\,e^{-x^2}. For F′=e−x2F' = e^{-x^2} we need R′−2xR=1R' - 2xR = 1, but 2xR2xR has a higher power of xx than R′R', so they never cancel down to 1.

Mathematicians proved in the nineteenth century that no formula built from familiar functions works, not just this guess. The area function ∫0xe−t2 dt\int_0^x e^{-t^2}\,dt still exists (lesson 2.5.3); it is a new function, computed numerically, like a square root. SymPy's erf from lesson 2.5.2 is this area times 2π\frac{2}{\sqrt{\pi}}.

Its total area

The tails converge. For ∣x∣≥1|x| \ge 1, x2≥∣x∣x^2 \ge |x|, so e−x2≤e−∣x∣e^{-x^2} \le e^{-|x|}, and exponential tails have finite area. The total area is known exactly.

Rule: Gaussian integral

∫−∞∞e−x2 dx=π≈1.772454\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi} \approx 1.772454

Stated here without proof. Module 4.7 shows where it comes from, using a double integral, and the proof belongs to the Proof Gym.

Check it numerically by integrating from −b-b to bb. The missing tails shrink astonishingly fast, because e−x2e^{-x^2} is already 1.4×10−111.4 \times 10^{-11} at x=5x = 5.

bb12345
∫−bbe−x2 dx\int_{-b}^{b} e^{-x^2}\,dx1.4936481.7641631.7724151.7724541.772454
tails left out0.280.00830.0000392.7×10−82.7 \times 10^{-8}2.7×10−122.7 \times 10^{-12}

So cutting the integral off at a moderate bb loses almost nothing. Case study 2.6.5 relies on that.

An extra factor of xx changes everything. x e−x2x\,e^{-x^2} does have an antiderivative, −12e−x2-\frac{1}{2}e^{-x^2}, by substitution (lesson 2.6.1). So ∫0∞x e−x2 dx=12\int_0^\infty x\,e^{-x^2}\,dx = \frac{1}{2} exactly.

Try it

The loop integrates e−x2e^{-x^2} from −b-b to bb and prints what is left out, π\sqrt{\pi} minus the result, in scientific notation (e-08 means ×10−8\times 10^{-8}).

quad over the whole line and SymPy both give π\sqrt{\pi}. SymPy also gives the half-line integral of x e−x2x\,e^{-x^2}.

⌘/Ctrl + Enter runs the cell

The standard normal density

Stretch the bell sideways by 2\sqrt{2} and it becomes e−t2/2e^{-t^2/2}. Substitute u=t2u = \frac{t}{\sqrt{2}}, a linear inner function, so dt=2 dudt = \sqrt{2}\,du (lesson 2.6.1). The limits stay at −∞-\infty and ∞\infty, and

∫−∞∞e−t2/2 dt=2∫−∞∞e−u2 du=2⋅π=2π\begin{aligned} \int_{-\infty}^{\infty} e^{-t^2/2}\,dt &= \sqrt{2}\int_{-\infty}^{\infty} e^{-u^2}\,du \\ &= \sqrt{2}\cdot\sqrt{\pi} = \sqrt{2\pi} \end{aligned}

That is about 2.506628. Dividing the curve by 2π\sqrt{2\pi} gives it total area 1.

Rule: Standard normal density

φ(x)=12π e−x2/2∫−∞∞φ(x) dx=1\begin{gathered} \varphi(x) = \frac{1}{\sqrt{2\pi}}\,e^{-x^2/2} \\[4pt] \int_{-\infty}^{\infty} \varphi(x)\,dx = 1 \end{gathered}

φ\varphi (phi) is the bell curve scaled to have area 1. Its peak is φ(0)=12π≈0.398942\varphi(0) = \frac{1}{\sqrt{2\pi}} \approx 0.398942, and it is symmetric: φ(−x)=φ(x)\varphi(-x) = \varphi(x).

The standard normal density φ\varphi. The whole shaded area is 1; the darker band from −1-1 to 1 holds 0.683 of it.

Areas under φ\varphi have no formula either, so they are computed numerically. The band from −1.96-1.96 to 1.96 holds 0.950004, and the area up to 1 is 0.841345. By symmetry, the area up to 0 is exactly 12\frac{1}{2}.

The area from −∞-\infty up to xx is called N(x)N(x), the normal cumulative distribution; SciPy computes it as norm.cdf(x). Level 5 (module 5.4) reads these areas as probabilities. Case study 2.6.5 prices an option with them.

Try it

norm.pdf is φ\varphi and norm.cdf is NN, from scipy.stats. quad of e−t2/2e^{-t^2/2} gives 2π\sqrt{2\pi}, and quad of φ\varphi gives 1.

Then each band is found twice: by quad and by subtracting values of NN.

⌘/Ctrl + Enter runs the cell

Common mistakes

  1. An improper integral is a limit. Integrate to a finite edge first, then let it go to infinity or to the blow-up.
  2. A curve that sinks to 0 can still have infinite area, like 1x\frac{1}{x} from 1 on.
  3. The power tests run opposite ways. Tails ∫1∞\int_1^\infty need p>1p > 1; blow-ups ∫01\int_0^1 need p<1p < 1; p=1p = 1 fails both.
  4. Do not integrate across a blow-up. ∫−111x2 dx\int_{-1}^{1} \frac{1}{x^2}\,dx is not −2-2: split at 0, and it diverges.
  5. Each half must converge. ∫−bbx dx=0\int_{-b}^{b} x\,dx = 0 does not make ∫−∞∞x dx\int_{-\infty}^{\infty} x\,dx equal 0.
  6. e−x2e^{-x^2} has no antiderivative formula, but x e−x2x\,e^{-x^2} does, by substitution.
  7. Match the bell to its area. e−x2e^{-x^2} has area π\sqrt{\pi}; e−x2/2e^{-x^2/2} has area 2π\sqrt{2\pi}; φ\varphi has area 1.

Improper integrals and the Gaussian integral

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

  • An improper integral is a limit: ∫a∞f dx=lim⁡b→∞∫abf dx\int_a^\infty f\,dx = \lim_{b \to \infty}\int_a^b f\,dx, and likewise towards a blow-up. It converges if the limit is a number.
  • Tails: ∫1∞1xp dx=1p−1\int_1^\infty \frac{1}{x^p}\,dx = \frac{1}{p - 1} for p>1p > 1, and diverges for p≤1p \le 1. Exponential tails always converge.
  • Blow-ups at 0: ∫011xp dx=11−p\int_0^1 \frac{1}{x^p}\,dx = \frac{1}{1 - p} for p<1p < 1, and diverges for p≥1p \ge 1.
  • Split at every trouble spot; the whole converges only if every piece does.
  • e−x2e^{-x^2} has no antiderivative formula, yet ∫−∞∞e−x2 dx=π\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}, and its tails shrink very fast.
  • φ(x)=12πe−x2/2\varphi(x) = \frac{1}{\sqrt{2\pi}}e^{-x^2/2} has area 1; its areas N(x)N(x) are computed numerically with norm.cdf.

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.

  • Normal distribution

    probabilitycourse.com. Free book.

    The normal distribution and standardising.