Single-variable Calculus: Derivatives & the Chain Rule · 14 min

Differentiation rules

One rule for powers, one for sums, one for constants, plus the derivatives of sine, cosine, the exponential, and the logarithm. Memorize seven lines, differentiate ninety percent of the functions you will ever meet.

0 / 0

The pattern hiding in x², x³, x⁴

You already have two derivatives, earned the long way through limits:

ddxx2  =  2xddxx3  =  3x2\frac{d}{dx}\,x^2 \;=\; 2x \qquad \frac{d}{dx}\,x^3 \;=\; 3x^2

Look at the exponents. Two becomes one. Three becomes two. The old exponent comes out the front as a multiplier. If the pattern holds, then

ddxx4  =  4x3ddxx5  =  5x4.\frac{d}{dx}\,x^4 \;=\; 4x^3 \qquad \frac{d}{dx}\,x^5 \;=\; 5x^4.

It holds. Not just for whole numbers either: it holds for 1-1, for 1/21/2, for π\pi.

A picture for why

Take the square with side xx. Its area is x2x^2. Now grow the side by a tiny amount dxdx. The new area is (x+dx)2(x + dx)^2, and the change in area is everything that just got added: two thin strips along the existing sides, each of size xdxx \cdot dx, plus a tiny corner square of size dxdxdx \cdot dx.

(x+dx)2x2  =  2xdx  +  (dx)2.(x + dx)^2 - x^2 \;=\; 2 x\,dx \;+\; (dx)^2.

Divide by dxdx to get the rate of change of area per unit of side:

(x+dx)2x2dx  =  2x  +  dx.\frac{(x + dx)^2 - x^2}{dx} \;=\; 2x \;+\; dx.

Send dx0dx \to 0. The corner square vanishes; the two strips survive. The rate is 2x2x. That is d/dxx2d/dx\,x^2, derived from a picture instead of an algebraic limit.

The same picture works in three dimensions for x3x^3: a cube grows three thin slabs of area x2x^2, giving 3x23 x^2. In general, xnx^n grows nn “slabs” each of size xn1x^{n-1}, hence nxn1n \cdot x^{n-1}.

The power rule

For any real number nn:

  ddxxn  =  nxn1  \boxed{\;\frac{d}{dx}\,x^n \;=\; n\,x^{n-1}\;}

That is one line. It handles every power you will ever take, positive or negative, integer or fraction or irrational.

ddx1x  =  ddxx1  =  1x2  =  1x2ddxx  =  ddxx1/2  =  12x1/2  =  12x\begin{aligned} \frac{d}{dx}\,\frac{1}{x} \;=\; \frac{d}{dx}\,x^{-1} \;&=\; -1 \cdot x^{-2} \;=\; -\frac{1}{x^2} \\[3pt] \frac{d}{dx}\,\sqrt{x} \;=\; \frac{d}{dx}\,x^{1/2} \;&=\; \tfrac{1}{2}\,x^{-1/2} \;=\; \frac{1}{2\sqrt{x}} \end{aligned}

No new tricks. The same shape, every time.

Power, drilled

What is ddx(5x3)\dfrac{d}{dx}\,\bigl(5x^3\bigr) at x=1x = 1?

Constants and sums

Two rules so obvious they barely need a name. The derivative is linear: it slides through addition, and it slides past constant multipliers.

ddx[c]=0ddx[cf(x)]=cf(x)ddx[f(x)+g(x)]=f(x)+g(x).\frac{d}{dx}\bigl[c\bigr] = 0 \qquad \frac{d}{dx}\bigl[c \cdot f(x)\bigr] = c \cdot f'(x) \qquad \frac{d}{dx}\bigl[f(x) + g(x)\bigr] = f'(x) + g'(x).

In words: a constant has zero slope (it never changes), a scalar multiplier passes straight through, and the derivative of a sum is the sum of the derivatives.

Combine those with the power rule and you can differentiate any polynomial by inspection:

ddx(3x45x2+7)  =  12x310x.\frac{d}{dx}\bigl(3x^4 - 5x^2 + 7\bigr) \;=\; 12 x^3 - 10 x.

The 77 dies (it is a constant). Each remaining term loses one exponent and picks up the old exponent as a coefficient.

Polynomial, by inspection

Differentiate f(x)=3x45x2+7f(x) = 3x^4 - 5x^2 + 7 term by term, then evaluate the derivative at x=1x = 1.

What is f(1)f'(1)?

Sine and cosine, derived from the unit circle

Two more derivatives, neither of which you can get from the power rule:

ddxsinx  =  cosxddxcosx  =  sinx.\frac{d}{dx}\,\sin x \;=\; \cos x \qquad \frac{d}{dx}\,\cos x \;=\; -\sin x.

You already saw this in the previous lesson when you swept across sinx\sin x on the tracer and the slope-curve was cosx\cos x. The geometric reason: sin\sin and cos\cos are the height and width of a point spinning on the unit circle. A tiny rotation dtdt moves that point by dtdt along the circle, perpendicular to its current direction. The change in height (i.e., in sin\sin) is cos(angle)dt\cos(\text{angle}) \cdot dt. The change in width (in cos\cos) is sin(angle)dt-\sin(\text{angle}) \cdot dt. The minus sign is the same minus sign you see in the formula.

If you want the full geometric derivation, it lives in module 3. For now the two formulas are tools to use.

The slope of cosine at the start

Use the rule above.

What is the slope of cosx\cos x at x=0x = 0?

The exponential e is the function that is its own derivative

There is one function in mathematics whose derivative is itself:

ddxex  =  ex.\frac{d}{dx}\,e^x \;=\; e^x.

That is the property that distinguishes e2.71828e \approx 2.71828\ldots from every other base. For any other base bb,

ddxbx  =  (lnb)bx.\frac{d}{dx}\,b^x \;=\; (\ln b) \cdot b^x.

For b=2b = 2, the multiplier ln20.693\ln 2 \approx 0.693. For b=3b = 3, ln31.099\ln 3 \approx 1.099. There is exactly one base where the multiplier is exactly 11, and the derivative becomes the function itself. That base is ee.

You can hunt for it by eye. Drag the base bb on the right panel below until the tangent at x=0x = 0 has slope 11. The left panel shows (1+1/n)n(1 + 1/n)^n climbing to the same number from a completely different direction.

the limit

(1 + 1/n)n

22.22.42.62.83
value 2.00000

the slope-1 base

y = bx

-2-112123
slope at x=0 ln(b) = 0.6931

drag n toward one million on the left, drag b until the slope locks at 1 on the right

The two paths meet at ee. That is not a coincidence. It is one constant earning its name from two definitions at once.

Find the slope-1 base

On the widget above, drag bb on the right panel until the slope of bxb^x at x=0x = 0 equals exactly 11.

What value of bb makes this happen? (Round to two decimals.)

The logarithm

One more, also new:

ddxlnx  =  1x,x>0.\frac{d}{dx}\,\ln x \;=\; \frac{1}{x}, \qquad x > 0.

The justification will be cleanest after we have the chain rule, but the intuition is short. The natural logarithm ln\ln is the inverse of exe^x. Inverses reflect across the line y=xy = x, which swaps “input” and “output” everywhere. If exe^x at the point (0,1)(0, 1) has slope 11, then ln\ln at the reflected point (1,0)(1, 0) also has slope 11. Repeat at (ln2,2)(\ln 2, 2) on the exponential — slope 22 — and at the reflected point (2,ln2)(2, \ln 2) on the logarithm — slope 1/21/2. The slopes are reciprocals of each other. At xx, ln\ln has slope 1/x1/x.

What you have

Seven differentiation rules. With these, you can take the derivative of every elementary function you will meet in this course except those built by multiplying functions together or composing them. Those two cases — products and compositions — get their own rules next.

ddx[c]=0ddx[xn]=nxn1ddx[sinx]=cosxddx[cosx]=sinxddx[ex]=exddx[lnx]=1x\begin{aligned} \frac{d}{dx}[c] &= 0 & \frac{d}{dx}[x^n] &= n\,x^{n-1} \\[3pt] \frac{d}{dx}[\sin x] &= \cos x & \frac{d}{dx}[\cos x] &= -\sin x \\[3pt] \frac{d}{dx}[e^x] &= e^x & \frac{d}{dx}[\ln x] &= \frac{1}{x} \end{aligned}

And the sum/scalar rules that glue them together. Most of the “differentiation” that runs inside a neural-network library is, ultimately, these seven formulas applied a trillion times.

Lesson complete

Nice tinkering.