A Practical Guide to Quantitative Finance Interviews
Contents
33

Chapter 3
Calculus and Linear Algebra

Calculus and linear algebra lay the foundation for many advanced math topics used in quantitative finance. So be prepared to answer some calculus or linear algebra problems—many of them may be incorporated into more complex problems—in quantitative interviews. Since most of the tested calculus and linear algebra knowledge is easy to grasp, the marginal benefit far outweighs the time you spend brushing up your knowledge on key subjects. If your memory of calculus or linear algebra is a little rusty, spend some time reviewing your college textbooks!

Needless to say, it is extremely difficult to condense any calculus/linear algebra books into one chapter. Neither is it my intention to do so. This chapter focuses only on some of the core concepts of calculus/linear algebra that are frequently occurring in quantitative interviews. And unless necessary, it does so without covering the proof, details or even caveats of these concepts. If you are not familiar with any of the concepts, please refer to your favorite calculus/linear algebra books for details.

3.1 Limits and Derivatives

Basics of derivatives

Let’s begin with some basic definitions and equations used in limits and derivatives. Although the notations may be different, you can find these materials in any calculus textbook.

Derivative: Let y=f(x)y=f(x), then

f′(x)=dydx=lim⁡Δx→0ΔyΔx=lim⁡Δx→0f(x+Δx)−f(x)Δxf'(x)=\frac{dy}{dx}=\lim_{\Delta x\to0}\frac{\Delta y}{\Delta x}=\lim_{\Delta x\to0}\frac{f(x+\Delta x)-f(x)}{\Delta x}

The product rule: If u=u(x)u=u(x) and v=v(x)v=v(x) and their respective derivatives exist,

d(uv)dx=udvdx+vdudx,(uv)′=u′v+uv′\frac{d(uv)}{dx}=u\frac{dv}{dx}+v\frac{du}{dx},\quad(uv)'=u'v+uv'

The quotient rule:

ddx(uv)=(vdudx−udvdx)/v2,(uv)′=u′v−uv′v2\frac{d}{dx}\left(\frac{u}{v}\right)=\left(v\frac{du}{dx}-u\frac{dv}{dx}\right)\big/v^2,\quad\left(\frac{u}{v}\right)'=\frac{u'v-uv'}{v^2}

The chain rule: If y=f(u(x))y=f(u(x)) and u=u(x)u=u(x), then dydx=dydududx\displaystyle\frac{dy}{dx}=\frac{dy}{du}\frac{du}{dx}

The generalized power rule: dyndx=nyn−1dydx\displaystyle\frac{dy^n}{dx}=ny^{n-1}\frac{dy}{dx} for ∀n≠0\forall n\ne0

Some useful equations:

34 ax=exln⁡aln⁡(ab)=ln⁡a+ln⁡bex=lim⁡n→∞(1+xn)na^x=e^{x\ln a}\qquad\ln(ab)=\ln a+\ln b\qquad e^x=\lim_{n\to\infty}\left(1+\frac{x}{n}\right)^n lim⁡x→0sin⁡xx=1lim⁡x→0(1+x)k=1+kx for any k\lim_{x\to0}\frac{\sin x}{x}=1\qquad\lim_{x\to0}(1+x)^k=1+kx\text{ for any }k lim⁡x→∞(ln⁡x/xr)=0 for any r>0lim⁡x→∞xre−x=0 for any r\lim_{x\to\infty}(\ln x/x^r)=0\text{ for any }r>0\qquad\lim_{x\to\infty}x^re^{-x}=0\text{ for any }r ddxeu=eududxdaudx=(auln⁡a)dudxddxln⁡u=1ududx=u′u\frac{d}{dx}e^u=e^u\frac{du}{dx}\qquad\frac{da^u}{dx}=(a^u\ln a)\frac{du}{dx}\qquad\frac{d}{dx}\ln u=\frac{1}{u}\frac{du}{dx}=\frac{u'}{u} ddxsin⁡x=cos⁡x,ddxcos⁡x=−sin⁡x,ddxtan⁡x=sec⁡2x\frac{d}{dx}\sin x=\cos x,\quad\frac{d}{dx}\cos x=-\sin x,\quad\frac{d}{dx}\tan x=\sec^2x

What is the derivative of y=ln⁡xln⁡xy=\ln x^{\ln x}?1

Solution: This is a good problem to test your knowledge of basic derivative formulas—specifically, the chain rule and the product rule.

Let u=ln⁡y=ln⁡(ln⁡xln⁡x)=ln⁡x×ln⁡(ln⁡x)u=\ln y=\ln(\ln x^{\ln x})=\ln x\times\ln(\ln x). Applying the chain rule and the product rule, we have

dudx=d(ln⁡y)dx=1ydydx=d(ln⁡x)dx×ln⁡(ln⁡x)+ln⁡x×d(ln⁡(ln⁡x))dx=ln⁡(ln⁡x)x+ln⁡xxln⁡x,\frac{du}{dx}=\frac{d(\ln y)}{dx}=\frac{1}{y}\frac{dy}{dx}=\frac{d(\ln x)}{dx}\times\ln(\ln x)+\ln x\times\frac{d(\ln(\ln x))}{dx}=\frac{\ln(\ln x)}{x}+\frac{\ln x}{x\ln x},

To derive d(ln⁡(ln⁡x))dx\displaystyle\frac{d(\ln(\ln x))}{dx}, we again use the chain rule by setting v=ln⁡xv=\ln x:

d(ln⁡(ln⁡x))dx=d(ln⁡v)dvdvdx=1v×1x=1xln⁡x.\frac{d(\ln(\ln x))}{dx}=\frac{d(\ln v)}{dv}\frac{dv}{dx}=\frac{1}{v}\times\frac{1}{x}=\frac{1}{x\ln x}. ∴ 1ydydx=ln⁡(ln⁡x)x+ln⁡xxln⁡x⇒dydx=yx(ln⁡(ln⁡x)+1)=ln⁡xln⁡xx(ln⁡(ln⁡x)+1).\therefore\ \frac{1}{y}\frac{dy}{dx}=\frac{\ln(\ln x)}{x}+\frac{\ln x}{x\ln x}\Rightarrow\frac{dy}{dx}=\frac{y}{x}(\ln(\ln x)+1)=\frac{\ln x^{\ln x}}{x}(\ln(\ln x)+1).

Transcription note: The exponent in footnote 1 is degraded in the scan; it is transcribed here as zz.

Maximum and minimum

Derivative f′(x)f'(x) is essentially the slope of the tangent line to the curve y=f(x)y=f(x) and the instantaneous rate of change (velocity) of yy with respect to xx. At point x=cx=c, if 35 f′(c)>0f'(c)>0, f(x)f(x) is an increasing function at cc; if f′(c)<0f'(c)\lt 0, f(x)f(x) is a decreasing function at cc.

Local maximum or minimum: suppose that f(x)f(x) is differentiable at cc and is defined on an open interval containing cc. If f(c)f(c) is either a local maximum value or a local minimum value of f(x)f(x), then f′(c)=0f'(c)=0.

Second Derivative test: Suppose the secondary derivative of f(x)f(x), f′′(x)f''(x), is continuous near cc. If f′(c)=0f'(c)=0 and f′′(c)>0f''(c)>0, then f(x)f(x) has a local minimum at cc; if f′(c)=0f'(c)=0 and f′′(c)<0f''(c)\lt 0, then f(x)f(x) has a local maximum at cc.

Without calculating the numerical results, can you tell me which number is larger, eπe^\pi or πe\pi^e?2

Solution: Let’s take natural logs of eπe^\pi and πe\pi^e. On the left side we have πln⁡e\pi\ln e, on the right side we have eln⁡πe\ln\pi. If eπ>πee^\pi>\pi^e, eπ>πe⇔π×ln⁡e>e×ln⁡π⇔ln⁡ee>ln⁡ππ\displaystyle e^\pi>\pi^e\Leftrightarrow\pi\times\ln e>e\times\ln\pi\Leftrightarrow\frac{\ln e}{e}>\frac{\ln\pi}{\pi}.

Is it true? That depends on whether f(x)=ln⁡xx\displaystyle f(x)=\frac{\ln x}{x} is an increasing or decreasing function from ee to π\pi. Taking the derivative of f(x)f(x), we have f′(x)=1/x×x−ln⁡xx2=1−ln⁡xx2\displaystyle f'(x)=\frac{1/x\times x-\ln x}{x^2}=\frac{1-\ln x}{x^2}, which is less than 0 when x>ex>e (ln⁡x>1\ln x>1). In fact, f(x)f(x) has global maximum when x=ex=e for all x>0x>0. So ln⁡ee>ln⁡ππ\displaystyle\frac{\ln e}{e}>\frac{\ln\pi}{\pi} and eπ>πee^\pi>\pi^e.

Alternative approach: If you are familiar with the Taylor’s series, which we will discuss in Section 3.4, you can apply Taylor’s series to exe^x: ex=∑n=0∞1n!=1+x1!+x22!+x33!+⋯\displaystyle e^x=\sum_{n=0}^{\infty}\frac{1}{n!}=1+\frac{x}{1!}+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots. So ex>1+x, ∀x>0e^x>1+x,\ \forall x>0. Let x=π/e−1x=\pi/e-1, then eπ/e/e>π/e⇔eπ/e>π⇔eπ>πee^{\pi/e}/e>\pi/e\Leftrightarrow e^{\pi/e}>\pi\Leftrightarrow e^\pi>\pi^e.

L’Hospital’s rule

Suppose that functions f(x)f(x) and g(x)g(x) are differentiable at x→ax\to a and that lim⁡x→ag′(a)≠0\lim_{x\to a}g'(a)\ne0. Further suppose that lim⁡x→af(a)=0\lim_{x\to a}f(a)=0 and lim⁡x→ag(a)=0\lim_{x\to a}g(a)=0 or that lim⁡x→af(a)→±∞\lim_{x\to a}f(a)\to\pm\infty and 36 lim⁡x→ag(a)→±∞\lim_{x\to a}g(a)\to\pm\infty, then lim⁡x→af(x)g(x)=lim⁡x→af′(x)g′(x)\displaystyle\lim_{x\to a}\frac{f(x)}{g(x)}=\lim_{x\to a}\frac{f'(x)}{g'(x)}. L’Hospital’s rule converts the limit from an indeterminate form to a determinate form.

What is the limit of ex/x2e^x/x^2 as x→∞x\to\infty, and what is the limit of x2ln⁡xx^2\ln x as x→0+x\to0^+?

Solution: lim⁡x→∞exx2\displaystyle\lim_{x\to\infty}\frac{e^x}{x^2} is a typical example of L’Hospital’s rule since lim⁡x→∞ex=∞\lim_{x\to\infty}e^x=\infty and lim⁡x→∞x2=∞\lim_{x\to\infty}x^2=\infty. Applying L’Hospital’s rule, we have

lim⁡x→af(x)g(x)=lim⁡x→∞exx2=lim⁡x→∞f′(x)g′(x)=lim⁡x→∞ex2x.\lim_{x\to a}\frac{f(x)}{g(x)}=\lim_{x\to\infty}\frac{e^x}{x^2}=\lim_{x\to\infty}\frac{f'(x)}{g'(x)}=\lim_{x\to\infty}\frac{e^x}{2x}.

The result still has the property that lim⁡x→∞f(x)=lim⁡x→∞ex=∞\lim_{x\to\infty}f(x)=\lim_{x\to\infty}e^x=\infty and lim⁡x→∞g(x)=lim⁡x→∞2x=∞\lim_{x\to\infty}g(x)=\lim_{x\to\infty}2x=\infty, so we can apply the L’Hospital’s rule again:

lim⁡x→∞f(x)g(x)=lim⁡x→∞exx2=lim⁡x→∞f′(x)g′(x)=lim⁡x→∞ex2x=lim⁡x→∞d(ex)/dxd(2x)/dx=lim⁡x→∞ex2=∞.\lim_{x\to\infty}\frac{f(x)}{g(x)}=\lim_{x\to\infty}\frac{e^x}{x^2}=\lim_{x\to\infty}\frac{f'(x)}{g'(x)}=\lim_{x\to\infty}\frac{e^x}{2x}=\lim_{x\to\infty}\frac{d(e^x)/dx}{d(2x)/dx}=\lim_{x\to\infty}\frac{e^x}{2}=\infty.

At first look, L’Hospital’s rule does not appear to be applicable to lim⁡x→0+x2ln⁡x\lim_{x\to0^+}x^2\ln x since it’s not in the format of lim⁡x→af(x)g(x)\displaystyle\lim_{x\to a}\frac{f(x)}{g(x)}. However, we can rewrite the original limit as lim⁡x→0+ln⁡xx−2\displaystyle\lim_{x\to0^+}\frac{\ln x}{x^{-2}} and it becomes obvious that lim⁡x→0+x−2=∞\lim_{x\to0^+}x^{-2}=\infty and lim⁡x→0+ln⁡x=−∞\lim_{x\to0^+}\ln x=-\infty. So we can now apply L’Hospital’s rule:

lim⁡x→0+x2ln⁡x=lim⁡x→0+ln⁡xx−2=lim⁡x→0+d(ln⁡x)/dxd(x−2)/dx=lim⁡x→0+1/x−2/x3=lim⁡x→0+x2−2=0\lim_{x\to0^+}x^2\ln x=\lim_{x\to0^+}\frac{\ln x}{x^{-2}}=\lim_{x\to0^+}\frac{d(\ln x)/dx}{d(x^{-2})/dx}=\lim_{x\to0^+}\frac{1/x}{-2/x^3}=\lim_{x\to0^+}\frac{x^2}{-2}=0