Skip to content

Derivatives of \(e^x\), \(\ln x\), \(\sin x\) and \(\cos x\)

Change and motion · level 8, lesson 2 of 7

A question to start

Is there a function that is its own derivative? A graph whose slope at every point is exactly equal to its height?

The zero function works, but that is cheating. A real example would be strange: at height 1 its slope would be 1; at height 10 its slope would be 10; at height 1000, slope 1000. The higher it gets, the faster it climbs, faster and faster without end.

Such a function exists, and there is exactly one of them that passes through \((0, 1)\). It is \(e^x\), where \(e = 2.71828\ldots\) is one of the most important numbers in mathematics. This lesson shows where \(e\) comes from, and then finds the derivatives of the other famous functions, the logarithm, sine and cosine, each from a real reason.

The idea

Exponential functions: the slope is proportional to the height

Take any base \(b > 0\) and the function \(f(x) = b^x\). From first principles, using the exponent law \(b^{x + h} = b^x b^h\):

\[\frac{b^{x + h} - b^x}{h} = \frac{b^x b^h - b^x}{h} = b^x \cdot \frac{b^h - 1}{h}.\]

The factor \(b^x\) does not involve \(h\), so it waits outside the limit:

\[\frac{d}{dx}\,b^x = b^x \cdot L(b), \qquad \text{where } L(b) = \lim_{h \to 0} \frac{b^h - 1}{h}.\]

So the derivative of \(b^x\) is \(b^x\) times a constant. The slope is proportional to the height. And the constant \(L(b)\) is just the slope of \(b^x\) at \(x = 0\) (put \(x = 0\) in the formula). You estimated \(L(2) \approx 0.693\) in level 7, lesson 1. Here are more, each worked out with a tiny \(h\):

Base \(b\) 2 2.5 2.7 2.72 3
Slope at 0, \(L(b)\) 0.6931 0.9163 0.9933 1.0006 1.0986

The bigger the base, the steeper the curve at 0. Somewhere between 2.7 and 2.72 there is a base whose slope at 0 is exactly 1. That base is called \(e\):

\[e = 2.718281828\ldots, \qquad \lim_{h \to 0} \frac{e^h - 1}{h} = 1.\]

With \(b = e\) the constant is 1, so

\[\frac{d}{dx}\,e^x = e^x.\]

This is why \(e\), and not 10 or 2, is "the natural" base: it is the only one that makes the constant disappear.

The same \(e\) as compound interest

You may have met \(e\) in Ratio: continuous growth and e as the limit of \(\left(1 + \frac1n\right)^n\). It is the same number. The fact \(\frac{e^h - 1}{h} \to 1\) says that for tiny \(h\), \(e^h \approx 1 + h\), so \(e \approx (1 + h)^{1/h}\). Put \(h = \frac1n\): \(e \approx \left(1 + \frac1n\right)^n\), which gets better as \(n\) grows (\(n = 1000\) gives \(2.7169\); \(n = 1\,000\,000\) gives \(2.718280\)).

The natural logarithm

The natural logarithm \(\ln x\) is the inverse of \(e^x\): \(y = \ln x\) means \(e^y = x\) (for \(x > 0\)). To find its derivative, start from \(e^y = x\) and differentiate both sides with respect to \(x\), using the chain rule on the left:

\[e^y \cdot \frac{dy}{dx} = 1 \quad\Longrightarrow\quad \frac{dy}{dx} = \frac{1}{e^y} = \frac{1}{x}.\]
\[\frac{d}{dx}\,\ln x = \frac{1}{x}.\]

The picture. The graph of \(\ln x\) is the graph of \(e^x\) reflected in the line \(y = x\). Reflecting swaps rise and run, so every slope turns into its reciprocal. At the point \((1, e)\) on \(e^x\) the slope is \(e\); at the mirror point \((e, 1)\) on \(\ln x\) the slope is \(\frac{1}{e}\), which is \(\frac1x\) there. ✓

12341234xy (1, e) (e, 1) eˣ ln x y = x

Two prizes follow at once.

  • Any base. Since \(b = e^{\ln b}\), we have \(b^x = e^{x \ln b}\), and the chain rule gives \(\frac{d}{dx}b^x = \ln b \cdot b^x\). So the mystery constant is \(L(b) = \ln b\), and indeed \(\ln 2 = 0.693147\ldots\)
  • The power rule for every power. For \(x > 0\), \(x^n = e^{n \ln x}\), so its derivative is \(e^{n \ln x} \cdot \frac{n}{x} = x^n \cdot \frac{n}{x} = n x^{n-1}\). This is the proof promised in level 7, and it works for \(n = \pi\) as well as \(n = 3\).

Sine and cosine: the key limit

For sine and cosine, angles must be in radians (Geometry: radians and the unit circle). Everything rests on one limit:

\[\lim_{h \to 0} \frac{\sin h}{h} = 1.\]

A table first: \(\frac{\sin 0.1}{0.1} = 0.998334\), \(\frac{\sin 0.01}{0.01} = 0.999983\). Now a proof. Take a circle of radius 1 and a small angle \(h\) (between 0 and \(\frac{\pi}{2}\)) at its centre \(O\).

OAPTh1sin htan h

Compare three areas, each inside the next:

  • the triangle \(OAP\), with base \(OA = 1\) and height \(\sin h\): area \(\frac12 \sin h\);
  • the sector \(OAP\): a fraction \(\frac{h}{2\pi}\) of the whole circle, so area \(\frac{h}{2\pi} \cdot \pi = \frac12 h\);
  • the triangle \(OAT\), with base 1 and height \(\tan h\): area \(\frac12 \tan h\).

So \(\frac12 \sin h \le \frac12 h \le \frac12 \tan h\). Multiply by \(\frac{2}{\sin h}\) (positive) and flip everything upside down (which reverses the inequalities):

\[\cos h \le \frac{\sin h}{h} \le 1.\]

As \(h \to 0\), \(\cos h \to 1\). The fraction is squeezed between something heading to 1 and 1 itself, so it must tend to 1 too. (For negative \(h\), \(\frac{\sin(-h)}{-h} = \frac{\sin h}{h}\), so the same holds.) This argument is called the squeeze theorem.

A second limit follows. Multiply top and bottom by \(\cos h + 1\) and use \(\cos^2 h - 1 = -\sin^2 h\):

\[\frac{\cos h - 1}{h} = \frac{-\sin^2 h}{h(\cos h + 1)} = -\frac{\sin h}{h} \cdot \frac{\sin h}{\cos h + 1} \;\longrightarrow\; -1 \cdot \frac{0}{2} = 0.\]

The derivative of \(\sin x\)

Use the addition formula \(\sin(x + h) = \sin x \cos h + \cos x \sin h\):

\[\frac{\sin(x + h) - \sin x}{h} = \sin x \cdot \frac{\cos h - 1}{h} + \cos x \cdot \frac{\sin h}{h} \;\longrightarrow\; \sin x \cdot 0 + \cos x \cdot 1.\]
\[\frac{d}{dx}\,\sin x = \cos x, \qquad \frac{d}{dx}\,\cos x = -\sin x.\]

(The second comes the same way from \(\cos(x + h) = \cos x \cos h - \sin x \sin h\).) Check against the graph of \(\sin x\): at \(x = 0\) it climbs with slope 1 \(= \cos 0\); at \(x = \frac{\pi}{2}\) it is at its peak, slope 0 \(= \cos\frac{\pi}{2}\); at \(x = \pi\) it falls with slope \(-1 = \cos \pi\).

Why radians? In degrees the key limit is not 1: \(\frac{\sin(0.1°)}{0.1} \approx 0.017453\), which is \(\frac{\pi}{180}\). Every derivative would carry that ugly factor. Radians are the unit that makes the constant 1, just as \(e\) is the base that makes the constant 1.

The table to remember

\(f(x)\) \(e^x\) \(e^{kx}\) \(b^x\) \(\ln x\) \(\sin x\) \(\cos x\) \(\tan x\)
\(f'(x)\) \(e^x\) \(k e^{kx}\) \(\ln b \cdot b^x\) \(\frac1x\) \(\cos x\) \(-\sin x\) \(\frac{1}{\cos^2 x}\)

Worked examples

1. Product with \(e^x\). Differentiate \(y = x^2 e^x\) and find where the tangent is flat.

\(y' = 2x e^x + x^2 e^x = e^x(x^2 + 2x) = x(x + 2)e^x\). Since \(e^x\) is never 0, the tangent is flat at \(x = 0\) and \(x = -2\).

2. Logarithm with the chain rule. Differentiate \(y = \ln(x^2 + 1)\).

Outside \(\ln u\) has derivative \(\frac1u\); inside has derivative \(2x\). So \(y' = \dfrac{2x}{x^2 + 1}\).

3. Trig with the chain rule. Differentiate (a) \(\sin(x^2)\) and (b) \(\sin^2 x\).

(a) Outside is sine, inside is \(x^2\): \(\cos(x^2) \cdot 2x\). (b) \(\sin^2 x\) means \((\sin x)^2\). Outside is squaring, inside is \(\sin x\): \(2 \sin x \cos x\). These two are easy to mix up; say out loud which function is on the outside.

4. Growth at a rate proportional to size. A population is \(P(t) = 500e^{0.03t}\) after \(t\) years.

\(P'(t) = 500 \cdot 0.03\, e^{0.03t} = 0.03\,P(t)\). The population grows at 3% of its current size per year: at \(t = 0\), by 15 per year; when it reaches 1000, by 30 per year. This is the "rate proportional to amount" you met in level 6, now as an equation. It is the start of differential equations.

5. Tangent from sine and cosine. \(\tan x = \dfrac{\sin x}{\cos x}\). Quotient rule:

\[\frac{\cos x \cdot \cos x - \sin x \cdot (-\sin x)}{\cos^2 x} = \frac{\cos^2 x + \sin^2 x}{\cos^2 x} = \frac{1}{\cos^2 x}.\]

Try it

  1. Differentiate \(y = 5e^x - 3\ln x\).
  2. Differentiate \(y = e^{-2x}\). Is the graph going up or down?
  3. Differentiate \(y = \ln(3x)\). Why is the answer the same as for \(\ln x\)?
  4. Differentiate \(y = x \ln x\).
  5. Differentiate \(y = \cos(3x)\).
  6. Differentiate \(y = e^x \sin x\).
  7. Find the slope of \(y = \sin x\) at \(x = \frac{\pi}{3}\), and the equation of the tangent there.
  8. Use a calculator to work out \(\dfrac{3^h - 1}{h}\) for \(h = 0.001\). Compare it with \(\ln 3\).
Answers
  1. \(y' = 5e^x - \dfrac{3}{x}\).
  2. Chain rule: \(y' = -2e^{-2x}\), always negative, so the graph always goes down (exponential decay).
  3. Chain rule: \(\dfrac{1}{3x} \cdot 3 = \dfrac1x\). Same as \(\ln x\), because \(\ln(3x) = \ln 3 + \ln x\): the graph is just \(\ln x\) slid up by \(\ln 3\), and sliding does not change slopes.
  4. Product rule: \(1 \cdot \ln x + x \cdot \dfrac1x = \ln x + 1\).
  5. \(-\sin(3x) \cdot 3 = -3\sin(3x)\).
  6. \(e^x \sin x + e^x \cos x = e^x(\sin x + \cos x)\).
  7. Slope \(\cos\frac{\pi}{3} = \frac12\). The point is \(\left(\frac{\pi}{3}, \frac{\sqrt3}{2}\right)\). Tangent: \(y = \frac{\sqrt3}{2} + \frac12\left(x - \frac{\pi}{3}\right)\), about \(y = 0.5x + 0.342\).
  8. \(3^{0.001} \approx 1.0010992\), so the fraction is about 1.0992. \(\ln 3 \approx 1.0986\). Very close, as the lesson predicts (\(L(3) = \ln 3\)); a smaller \(h\) gets closer still.

Common mistake

Using the power rule on \(e^x\). \(e^x\) is not a power of \(x\); the variable is in the exponent. Its derivative is not \(x e^{x-1}\). The power rule is for \(x^n\) (fixed power, variable base); the exponential rule is for \(b^x\) (fixed base, variable power).

Working in degrees. \(\frac{d}{dx}\sin x = \cos x\) is true only in radians. Set your calculator to radians for calculus.

Where it leads