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), then f′(x)=dxdy=limΔx→0ΔxΔy=limΔx→0Δxf(x+Δx)−f(x)
The product rule: If u=u(x) and v=v(x) and their respective derivatives exist,
dxd(uv)=udxdv+vdxdu,(uv)′=u′v+uv′
The quotient rule: dxd(vu)=(vdxdu−udxdv)/v2,(vu)′=v2u′v−uv′
The chain rule: If y=f(u(x)) and u=u(x), then dxdy=dudydxdu
The generalized power rule: dxdyn=nyn−1dxdy for ∀n=0
Some useful equations:
34
ax=exlnaln(ab)=lna+lnbex=n→∞lim(1+nx)n
x→0limxsinx=1x→0lim(1+x)k=1+kxfor any k
x→∞lim(lnx/xr)=0for any r>0x→∞limxre−x=0for any r
dxdeu=eudxdudxdau=(aulna)dxdudxdlnu=u1dxdu=uu′
dxdsinx=cosx,dxdcosx=−sinx,dxdtanx=sec2x
What is the derivative of y=lnxlnx?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=lny=ln(lnxlnx)=lnx×ln(lnx). Applying the chain rule and the product rule, we have
dxdu=dxd(lny)=y1dxdy=dxd(lnx)×ln(lnx)+lnx×dxd(ln(lnx))=xln(lnx)+xlnxlnx,
To derive dxd(ln(lnx)), we again use the chain rule by setting v=lnx:
dxd(ln(lnx))=dvd(lnv)dxdv=v1×x1=xlnx1.
∴ y1dxdy=xln(lnx)+xlnxlnx⇒dxdy=xy(ln(lnx)+1)=xlnxlnx(ln(lnx)+1).
Maximum and minimum
Derivative f′(x) is essentially the slope of the tangent line to the curve y=f(x) and the instantaneous rate of change (velocity) of y with respect to x. At point x=c, if 35f′(c)>0, f(x) is an increasing function at c; if f′(c)<0, f(x) is a decreasing function at c.
Local maximum or minimum: suppose that f(x) is differentiable at c and is defined on an open interval containing c. If f(c) is either a local maximum value or a local minimum value of f(x), then f′(c)=0.
Second Derivative test: Suppose the secondary derivative of f(x), f′′(x), is continuous near c. If f′(c)=0 and f′′(c)>0, then f(x) has a local minimum at c; if f′(c)=0 and f′′(c)<0, then f(x) has a local maximum at c.
Without calculating the numerical results, can you tell me which number is larger, eπ or πe?2
Solution: Let’s take natural logs of eπ and πe. On the left side we have πlne, on the right side we have elnπ. If eπ>πe, eπ>πe⟺π×lne>e×lnπ⟺elne>πlnπ.
Is it true? That depends on whether f(x)=xlnx is an increasing or decreasing function from e to π. Taking the derivative of f(x), we have f′(x)=x21/x×x−lnx=x21−lnx, which is less than 0 when x>e (lnx>1). In fact, f(x) has global maximum when x=e for all x>0. So elne>πlnπ and eπ>π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 ex: ex=n=0∑∞n!1=1+1!x+2!x2+3!x3+⋯. So ex>1+x, ∀x>0. Let x=π/e−1, then eπ/e/e>π/e⟺eπ/e>π⟺eπ>πe.
L’Hospital’s rule
Suppose that functions f(x) and g(x) are differentiable at x→a and that limx→ag′(a)=0. Further suppose that limx→af(a)=0 and limx→ag(a)=0 or that limx→af(a)→±∞ and 36limx→ag(a)→±∞, then limx→ag(x)f(x)=limx→ag′(x)f′(x). L’Hospital’s rule converts the limit from an indeterminate form to a determinate form.
What is the limit of ex/x2 as x→∞, and what is the limit of x2lnx as x→0+?
Solution: limx→∞x2ex is a typical example of L’Hospital’s rule since limx→∞ex=∞ and limx→∞x2=∞. Applying L’Hospital’s rule, we have
x→alimg(x)f(x)=x→∞limx2ex=x→∞limg′(x)f′(x)=x→∞lim2xex.
The result still has the property that limx→∞f(x)=limx→∞ex=∞ and limx→∞g(x)=limx→∞2x=∞, so we can apply the L’ Hospital’s rule again:
x→∞limg(x)f(x)=x→∞limx2ex=x→∞limg′(x)f′(x)=x→∞lim2xex=x→∞limd(2x)/dxd(ex)/dx=x→∞lim2ex=∞.
At first look, L’Hospital’s rule does not appear to be applicable to limx→0+x2lnx since it’s not in the format of limx→ag(x)f(x). However, we can rewrite the original limit as limx→0+x−2lnx and it becomes obvious that limx→0+x−2=∞ and limx→0+lnx=−∞. So we can now apply L’Hospital’s rule:
x→0+limx2lnx=x→0+limx−2lnx=x→0+limd(x−2)/dxd(lnx)/dx=x→0+lim−2/x31/x=x→0+lim−2x2=0