Quantitative Finance Interviews
36

3.2 Integration

Basics of integration

Again, let’s begin with some basic definitions and equations used in integration.
If we can find a function F(x)F(x) with derivative f(x)f(x), then we call F(x)F(x) an antiderivative of f(x)f(x).

If f(x)=F′(x)f(x)=F'(x), ∫abf(x)=∫abF′(x)dx=[F(x)]ab=F(b)−F(a)\displaystyle\int_a^b f(x)=\int_a^b F'(x)dx=[F(x)]_a^b=F(b)-F(a)

37 dF(x)dx=f(x),F(a)=ya⇒F(x)=ya+∫axf(t)dt\frac{dF(x)}{dx}=f(x),\quad F(a)=y_a\Rightarrow F(x)=y_a+\int_a^x f(t)dt

The generalized power rule in reverse: ∫ukdu=uk+1k+1+c(k≠1)\displaystyle\int u^kdu=\frac{u^{k+1}}{k+1}+c\quad(k\ne1), where cc is any constant.

Integration by substitution:

∫f(g(x))⋅g′(x)dx=∫f(u)duwith u=g(x),du=g′(x)dx\int f(g(x))\cdot g'(x)dx=\int f(u)du\quad\text{with }u=g(x),\quad du=g'(x)dx

Substitution in definite integrals: ∫abf(g(x))⋅g′(x)dx=∫g(a)g(b)f(u)du\displaystyle\int_a^b f(g(x))\cdot g'(x)dx=\int_{g(a)}^{g(b)}f(u)du

Integration by parts: ∫u dv=uv−∫v du\displaystyle\int u\,dv=uv-\int v\,du

A. What is the integral of ln⁡(x)\ln(x)?

Solution: This is an example of integration by parts. Let u=ln⁡xu=\ln x and v=xv=x, we have
d(uv)=vdu+udv=(x×1/x)dx+ln⁡xdxd(uv)=vdu+udv=(x\times1/x)dx+\ln xdx,

∴∫ln⁡xdx=xln⁡x−∫dx=xln⁡x−x+c\displaystyle\therefore\quad\int\ln xdx=x\ln x-\int dx=x\ln x-x+c, where cc is any constant.

B. What is the integral of sec⁡(x)\sec(x) from x=0x=0 to x=π/6x=\pi/6?

Solution: Clearly this problem is directly related to differentiation/integration of trigonometric functions. Although there are derivative functions for all basic trigonometric functions, we only need to remember two of them: ddxsin⁡x=cos⁡x\displaystyle\frac{d}{dx}\sin x=\cos x, ddxcos⁡x=−sin⁡x\displaystyle\frac{d}{dx}\cos x=-\sin x. The rest can be derived using the product rule or the quotient rule. For example,

dsec⁡xdx=d(1/cos⁡x)dx=sin⁡xcos⁡2x=sec⁡xtan⁡x,\frac{d\sec x}{dx}=\frac{d(1/\cos x)}{dx}=\frac{\sin x}{\cos^2x}=\sec x\tan x, dtan⁡xdx=d(sin⁡x/cos⁡x)dx=cos⁡2x+sin⁡2xcos⁡2x=sec⁡2x.\frac{d\tan x}{dx}=\frac{d(\sin x/\cos x)}{dx}=\frac{\cos^2x+\sin^2x}{\cos^2x}=\sec^2x. ∴d(sec⁡x+tan⁡x)dx=sec⁡x(sec⁡x+tan⁡x).\therefore\quad\frac{d(\sec x+\tan x)}{dx}=\sec x(\sec x+\tan x). 38

Since the (sec⁡x+tan⁡x)(\sec x+\tan x) term occurs in the derivative, we also have

dln⁡∣sec⁡x+tan⁡x∣dx=sec⁡x(sec⁡x+tan⁡x)(sec⁡x+tan⁡x)=sec⁡x\frac{d\ln|\sec x+\tan x|}{dx}=\frac{\sec x(\sec x+\tan x)}{(\sec x+\tan x)}=\sec x ⇒∫sec⁡x=ln⁡∣sec⁡x+tan⁡x∣+c\Rightarrow\int\sec x=\ln|\sec x+\tan x|+c

and ∫0π/6sec⁡x=ln⁡(sec⁡(π/6)+tan⁡(π/6))−ln⁡(sec⁡(0)+tan⁡(0))=ln⁡(3)\displaystyle\int_0^{\pi/6}\sec x=\ln(\sec(\pi/6)+\tan(\pi/6))-\ln(\sec(0)+\tan(0))=\ln(\sqrt3)

Applications of integration

A. Suppose that two cylinders each with radius 1 intersect at right angles and their centers also intersect. What is the volume of the intersection?

Solution: This problem is an application of integration to volume calculation. For these applied problems, the most difficult part is to correctly formulate the integration. The general integration function to calculate 3D volume is V=∫z1z2A(z)dz\displaystyle V=\int_{z_1}^{z_2}A(z)dz where A(z)A(z) is the cross-sectional area of the solid cut by a plane perpendicular to the zz-axis at coordinate zz. The key here is to find the right expression for cross-sectional area AA as a function of zz.

Figure 3.1 gives us a clue. If you cut the intersection by a horizontal plane, the cut will be a square with side-length (2r)2−(2z)2\sqrt{(2r)^2-(2z)^2}. Taking advantage of symmetry, we can calculate the total volume as

2×∫0r[(2r)2−(2z)2]dz=8×[r2z−z3/3]0r=16/3r3=16/3.2\times\int_0^r\left[(2r)^2-(2z)^2\right]dz=8\times\left[r^2z-z^3/3\right]_0^r=16/3r^3=16/3.

An alternative approach requires even better 3D imagination. Let’s imagine a sphere that is inscribed inside both cylinders, so it is inscribed inside the intersection as well. The sphere should have a radius of r/2r/2. At each cut perpendicular to the zz-axis, the circle from the sphere is inscribed in the square from the intersection as well. So Acircle=π4AsquareA_{circle}=\frac{\pi}{4}A_{square}. Since it’s true for all zz values, we have

Vsphere=43π(r2)3=π4Vintersection⇒Vintersection=16/3r3=16/3.V_{sphere}=\frac43\pi\left(\frac r2\right)^3=\frac\pi4 V_{intersection}\Rightarrow V_{intersection}=16/3r^3=16/3. 39
Two perpendicular intersecting cylinders, with axes x pointing down and right, y pointing right, and z pointing upward.
Figure 3.1 Interaction of two cylinders

B. The snow began to fall some time before noon at a constant rate. The city of Cambridge sent out a snow plow at noon to clear Massachusetts Avenue from MIT to Harvard. The plow removed snow at a constant volume per minute. At 1 pm, it had moved 2 miles and at 2 pm, 3 miles. When did the snow begin to fall?

Solution: Let’s denote noon as time 0 and assume snow began to fall TT hours before noon. The speed at which the plow moves is inversely related to the vertical cross-sectional area of the snow: v=c1/A(t)v=c_1/A(t), where vv is the speed of the plow, c1c_1 is a constant representing the volume of snow that the plow can remove every hour and A(t)A(t) is the cross-sectional area of the snow. If tt is defined as the time after noon, we also have A(t)=c2(t+T)A(t)=c_2(t+T), where c2c_2 is the rate of cross-sectional area increase per hour (since the snow falls at a constant rate). So v=c1c2(t+T)=ct+T\displaystyle v=\frac{c_1}{c_2(t+T)}=\frac{c}{t+T} where c=c1c2\displaystyle c=\frac{c_1}{c_2}. Taking the integration, we have

∫01cT+tdt=cln⁡(1+T)−cln⁡T=cln⁡(1+TT)=2,\int_0^1\frac{c}{T+t}dt=c\ln(1+T)-c\ln T=c\ln\left(\frac{1+T}{T}\right)=2, ∫02cT+tdt=cln⁡(2+T)−cln⁡T=cln⁡(2+TT)=3\int_0^2\frac{c}{T+t}dt=c\ln(2+T)-c\ln T=c\ln\left(\frac{2+T}{T}\right)=3

From these two equations, we get

(1+TT)3=(2+TT)2⇒T2−T+1=0⇒T=(5−1)/2.\left(\frac{1+T}{T}\right)^3=\left(\frac{2+T}{T}\right)^2\Rightarrow T^2-T+1=0\Rightarrow T=(\sqrt5-1)/2. 40

Overall, this question, although fairly straightforward, tests analytical skills, integration knowledge and algebra knowledge.

Expected value using integration

Integration is used extensively to calculate the unconditional or conditional expected value of continuous random variables. In Chapter 4, we will demonstrate its value in probability and statistics. Here we just use one example to show its application:

If XX is a standard normal random variable, X∼N(0,1)X\sim N(0,1), what is E[X∣X>0]E[X\mid X>0]?

Solution: Since X∼N(0,1)X\sim N(0,1), the probability density function of xx is f(x)=12πe−1/2x2\displaystyle f(x)=\frac1{\sqrt{2\pi}}e^{-1/2x^2} and we have E[X∣X>0]=∫0∞xf(x)dx=∫0∞x12πe−1/2x2dx\displaystyle E[X\mid X>0]=\int_0^\infty xf(x)dx=\int_0^\infty x\frac1{\sqrt{2\pi}}e^{-1/2x^2}dx.

Because d(−1/2x2)=−xd(-1/2x^2)=-x and ∫eudy=eu+c\displaystyle\int e^u dy=e^u+c, where cc is an arbitrary constant, it is obvious that we can use integration by substitution by letting u=−1/2x2u=-1/2x^2. Replace e−1/2x2e^{-1/2x^2} with eue^u and xdxxdx with −du-du, we have

∫0∞x12πe−1/2x2dx=∫0−∞−12πeudu=−12π[eu]0−∞=−12π(0−1)=12π,\int_0^\infty x\frac1{\sqrt{2\pi}}e^{-1/2x^2}dx=\int_0^{-\infty}-\frac1{\sqrt{2\pi}}e^u du=-\frac1{\sqrt{2\pi}}[e^u]_0^{-\infty}=-\frac1{\sqrt{2\pi}}(0-1)=\frac1{\sqrt{2\pi}},

where [eu]0−∞[e^u]_0^{-\infty} is determined by x=0⇒u=0x=0\Rightarrow u=0 and x=∞⇒u=−∞x=\infty\Rightarrow u=-\infty.

∴E[X∣X>0]=1/2π\therefore\quad E[X\mid X>0]=1/\sqrt{2\pi}