SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 2.3.1 Power, constant and sum rulesConcept · 25 min
      2. 2.3.2 Product and quotient rulesConcept · 25 min
      3. 2.3.3 The chain ruleConcept · 30 min
      4. 2.3.4 Derivatives of exponentials and logarithmsConcept · 30 min
      5. 2.3.5 Derivatives of sine and cosineConcept · 35 min
      6. 2.3.6 Practice set: differentiationPractice set · 25 min
      7. 2.3.7 Case study: modified duration and elasticityCase study · 30 min

Level 2, Single-variable calculus 2.3 Differentiation rules Lesson 4 of 7

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

Derivatives of exponentials and logarithms

exe^x is its own slope

At every point, the slope of exe^x equals its height there. At x=1x = 1 the height is e≈2.718282e \approx 2.718282, and central differences (lesson 2.2.2) settle on the same number.

gap hh0.10.010.001
central difference at 12.7228152.7183272.718282

A picture shows what this means. Every tangent to exe^x meets the xx-axis exactly 1 unit to the left of its point. So the run is 1 and the rise is the height, and the slope is the height divided by 1.

Tangents to y=exy = e^x at −1-1, 0 and 1. Each runs 1 along the axis and rises by the height of its point, so its slope is that height: 0.37, 1 and e≈2.72e \approx 2.72.

Rule: Derivative of the exponential

ddx ex=ex\frac{d}{dx}\,e^x = e^x

The slope of exe^x at every point equals its value there. The value is always positive, so exe^x always rises, and the higher it is, the faster it rises.

By the constant rule, any multiple cexce^x is its own slope too: ddx5ex=5ex\frac{d}{dx}5e^x = 5e^x. No other exponential bxb^x is.

Slide the point along exe^x below. The slope traced underneath is the same curve again.

Explore

Slide the point along the curve. Its tangent shows the slope there, and the lower graph plots that slope for every x: the derivative.

−2−10120246

The slope of y = eˣ, which is eˣ

−2−10120246
Point
(0, 1)
Slope there
1
The curve is
rising: the slope is positive, so the slope graph is above zero

Why ee is the natural base

Every exponential bxb^x has a slope proportional to its height. The factor is its slope at 0, which depends on the base.

base bb2ee3
slope of bxb^x at 00.69314711.098612

ee is the one base whose slope at 0 is exactly 1, so the factor disappears. That is the sense in which lesson 1.4.2 called ee natural. The section on other bases below says where 0.693147 and 1.098612 come from.

Try it

The loop prints central differences of exe^x at 1, next to ee itself.

The last lines estimate the slope at 0 of 2x2^x, exe^x and 3x3^x with a tiny gap, h=0.00001h = 0.00001.

⌘/Ctrl + Enter runs the cell

ekxe^{kx} and the chain rule

With the chain rule of lesson 2.3.3, the exponent becomes an inner function. Its slope comes out in front, and the exponential stays as it is.

Rule: Exponential of a function

ddx ekx=k ekxddx eg(x)=g′(x) eg(x)\begin{gathered} \frac{d}{dx}\,e^{kx} = k\,e^{kx} \\[4pt] \frac{d}{dx}\,e^{g(x)} = g'(x)\,e^{g(x)} \end{gathered}

The slope of an exponential is the exponential itself, times the slope of its exponent.

The sign of kk decides the shape.

  • k>0k > 0, growth. e3xe^{3x} has slope 3e3x3e^{3x}.
  • k<0k < 0, decay. e−2xe^{-2x} has slope −2e−2x-2e^{-2x}. The slope is negative, and it shrinks as the curve shrinks.
  • k=0k = 0. e0=1e^{0} = 1 is a constant, with slope 0.

Divide the slope of ekxe^{kx} by its value and you get kk, whatever xx is. This is the relative rate: the change per unit of xx as a fraction of the current size.

So e0.05te^{0.05t}, with tt in years, always grows at 0.05 of its size per year. Case study 2.3.7 uses this for continuous discounting.

The exponent need not be linear. ex2e^{x^2} has slope 2xex22xe^{x^2}. The bell-shaped e−x2/2e^{-x^2/2} has slope −xe−x2/2-xe^{-x^2/2}, which is about −0.606531-0.606531 at x=1x = 1; it returns in lesson 2.6.3.

With the product rule, xexxe^x has slope 1⋅ex+x⋅ex=(1+x)ex1 \cdot e^x + x \cdot e^x = (1 + x)e^x. It is 1 at x=0x = 0 and 0 at x=−1x = -1, where the curve is flat for an instant.

Try it

SymPy writes exe^x as exp(x). The loop differentiates each example of this section.

The last lines check the relative rate of ekxe^{kx}, the bell curve's slope at 1, and xexxe^x at −1-1 and 0.

⌘/Ctrl + Enter runs the cell

ln⁡x\ln x has slope 1x\frac{1}{x}

ln⁡x\ln x undoes exe^x, so its graph is the mirror image of exe^x in the line y=xy = x (lessons 1.1.3 and 1.4.3). A mirror in y=xy = x swaps every run with its rise. So it turns a slope mm into 1m\frac{1}{m}.

On exe^x, the point at height 2 sits at x=ln⁡2≈0.69x = \ln 2 \approx 0.69, and its slope is its height, 2. The mirror image is the point (2,0.69)(2, 0.69) on ln⁡x\ln x, so the slope there is 12\frac{1}{2}.

The mirror in y=xy = x swaps run and rise. The tangent to exe^x at height 2 runs 0.5 and rises 1; its image on ln⁡x\ln x at x=2x = 2 runs 1 and rises 0.5.

The same happens at every point. The slope of ln⁡x\ln x at xx is one over the height of exe^x at the mirror point, and that height is xx.

Rule: Derivative of the logarithm

ddx ln⁡x=1x(x>0)\frac{d}{dx}\,\ln x = \frac{1}{x} \qquad (x > 0)

The slope is large for small xx and shrinks as xx grows. It is always positive, so ln⁡x\ln x always rises, more and more slowly.

xx0.5124
slope 1x\frac{1}{x}210.50.25

Central differences at 2 give 0.500417, 0.500004 and 0.5 for gaps 0.1, 0.01 and 0.001.

Logs of functions

With the chain rule and the outer function ln⁡u\ln u, whose slope is 1u\frac{1}{u}, the log of a function has a neat derivative.

Rule: Log of a function

ddx ln⁡(g(x))=g′(x)g(x)where g(x)>0\begin{gathered} \frac{d}{dx}\,\ln\big(g(x)\big) = \frac{g'(x)}{g(x)} \\[4pt] \text{where } g(x) > 0 \end{gathered}

The slope of the inside divided by the inside: its relative rate.

  • ln⁡(1+x2)\ln(1 + x^2) has slope 2x1+x2\frac{2x}{1 + x^2}.
  • ln⁡(5x)\ln(5x) has slope 55x=1x\frac{5}{5x} = \frac{1}{x}, the same as ln⁡x\ln x. By the log rule of lesson 1.4.3, ln⁡(5x)=ln⁡5+ln⁡x\ln(5x) = \ln 5 + \ln x, and the constant ln⁡5\ln 5 has slope 0.
  • ln⁡(x2)\ln(x^2) has slope 2xx2=2x\frac{2x}{x^2} = \frac{2}{x}.
  • (ln⁡x)2(\ln x)^2 is different: its outer function is u2u^2, so its slope is 2ln⁡x⋅1x=2ln⁡xx2\ln x \cdot \frac{1}{x} = \frac{2\ln x}{x}.

Because g′g\frac{g'}{g} is a relative rate, a log turns relative change into an ordinary slope. For example, ln⁡(ekx)=kx\ln(e^{kx}) = kx has slope kk, the relative rate of ekxe^{kx}.

Negative inputs, and where ln⁡\ln breaks

ln⁡x\ln x exists only for x>0x > 0, so it has no slope at 0 or below. As xx shrinks towards 0, the slope 1x\frac{1}{x} grows without limit: 10 at 0.1, 100 at 0.01, 1000 at 0.001. The curve plunges down the yy-axis.

ln⁡∣x∣\ln|x| is defined for negative xx as well: it is ln⁡x\ln x mirrored in the yy-axis. Its slope is also 1x\frac{1}{x}, on both sides of 0. At x=−2x = -2 it is −0.5-0.5, because there the curve falls.

Lesson 2.5.2 uses this to undo 1x\frac{1}{x}.

Try it

The first loop prints central differences of ln⁡x\ln x at 2, and the second the slope 1x\frac{1}{x} near 0. A central difference of ln⁡∣x∣\ln|x| at −2-2 follows.

SymPy writes ln⁡\ln as log. Declaring xx positive lets it simplify ln⁡(5x)\ln(5x) and ln⁡(x2)\ln(x^2).

⌘/Ctrl + Enter runs the cell

Other bases

Lesson 1.4.3 gives b=eln⁡bb = e^{\ln b}, so bx=exln⁡bb^x = e^{x \ln b}. The chain rule, with inner function xln⁡bx\ln b and inner slope ln⁡b\ln b, then gives the slope of bxb^x. Change of base, log⁡bx=ln⁡xln⁡b\log_b x = \frac{\ln x}{\ln b}, gives the slope of log⁡bx\log_b x.

Rule: Other bases

ddx bx=bxln⁡bddx log⁡bx=1xln⁡b\begin{gathered} \frac{d}{dx}\,b^x = b^x \ln b \\[4pt] \frac{d}{dx}\,\log_b x = \frac{1}{x \ln b} \end{gathered}

For b=eb = e, ln⁡e=1\ln e = 1 and both rules reduce to the ones above. The factor ln⁡b\ln b is the slope of bxb^x at 0, from the table earlier.

  • 2x2^x has slope 2xln⁡2≈0.693147×2x2^x \ln 2 \approx 0.693147 \times 2^x.
  • A base below 1 has a negative log. (12)x\left(\frac{1}{2}\right)^x has slope −(12)xln⁡2-\left(\frac{1}{2}\right)^x \ln 2: it decays.
  • log⁡10x\log_{10} x has slope 1xln⁡10\frac{1}{x \ln 10}, which is about 0.434294 at x=1x = 1.

Power, exponential or constant?

Three look-alikes take three different rules. Ask where the variable is.

functionthe variable isrulederivative
xex^ein the basepower rulee xe−1e\,x^{e - 1}
exe^xin the exponentexponential ruleexe^x
eee^enowhereconstant0

Try it

SymPy differentiates each example of this section. It writes ee as E and ln⁡\ln as log.

sp.log(x, 10) is log⁡10x\log_{10} x, which SymPy turns into log(x)/log(10) by change of base. It writes −(12)xln⁡2-\left(\frac{1}{2}\right)^x \ln 2 as -log(2)/2**x.

⌘/Ctrl + Enter runs the cell

These derivatives, read backwards, give the antiderivatives of lesson 2.5.2. Case study 2.3.7 uses ddye−yt=−te−yt\frac{d}{dy}e^{-yt} = -te^{-yt} to find a bond's duration exactly.

Common mistakes

  1. exe^x is not a power of xx. The power rule does not apply: ddxex≠xex−1\frac{d}{dx}e^x \neq xe^{x - 1}.
  2. Keep the chain factor. e−2xe^{-2x} gives −2e−2x-2e^{-2x}, and ex2e^{x^2} gives 2xex22xe^{x^2}, not e2xe^{2x}.
  3. ln⁡\ln of a sum is not a sum of logs. ln⁡(1+x)\ln(1 + x) has slope 11+x\frac{1}{1 + x}, not 1+1x1 + \frac{1}{x}.
  4. A constant inside ln⁡\ln drops out. ln⁡(5x)\ln(5x) has slope 1x\frac{1}{x}, not 5x\frac{5}{x} or 15x\frac{1}{5x}.
  5. (ln⁡x)2(\ln x)^2 is not ln⁡(x2)\ln(x^2). Their slopes are 2ln⁡xx\frac{2\ln x}{x} and 2x\frac{2}{x}.
  6. Other bases need ln⁡b\ln b. 2x2^x gives 2xln⁡22^x \ln 2, not x⋅2x−1x \cdot 2^{x - 1}.
  7. ln⁡\ln needs a positive input. For negative xx, use ln⁡∣x∣\ln|x|, whose slope is also 1x\frac{1}{x}.

Exponentials and logarithms

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

  • ddxex=ex\frac{d}{dx}e^x = e^x: the slope equals the height. ee is the base whose slope at 0 is 1.
  • ddxeg(x)=g′(x)eg(x)\frac{d}{dx}e^{g(x)} = g'(x)e^{g(x)}; so ddxekx=kekx\frac{d}{dx}e^{kx} = ke^{kx}, a constant relative rate kk.
  • ddxln⁡x=1x\frac{d}{dx}\ln x = \frac{1}{x} for x>0x > 0: the mirror of exe^x swaps rise and run. ln⁡∣x∣\ln|x| also has slope 1x\frac{1}{x}.
  • ddxln⁡(g(x))=g′(x)g(x)\frac{d}{dx}\ln(g(x)) = \frac{g'(x)}{g(x)}, the relative rate of gg.
  • ddxbx=bxln⁡b\frac{d}{dx}b^x = b^x \ln b and ddxlog⁡bx=1xln⁡b\frac{d}{dx}\log_b x = \frac{1}{x \ln b}.

Free further reading

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