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

Product and quotient rules

The derivative of a product is not the product of the derivatives. The geometric reason why, the rule that comes out of it, and one more for division.

0 / 0

The wrong rule, made obvious

The sum rule was so obliging — derivative of a sum is the sum of derivatives — that you might expect the same for products. Surely the derivative of a product is the product of the derivatives?

It is not. The cleanest disproof is one line. Take f(x)=xxf(x) = x \cdot x. The wrong rule predicts f(x)=11=1f'(x) = 1 \cdot 1 = 1. The right answer (you already know) is f(x)=2xf'(x) = 2x.

So whatever the rule for products is, it has to recover 2x2x from xxx \cdot x. We are about to derive it geometrically, and the answer will write itself.

Two strips plus a vanishing corner

A product uvu \cdot v is the area of a rectangle with sides uu and vv. Drag the parameter tt below. Both u(t)u(t) and v(t)v(t) grow a little. The new area shows up as three pieces, not two.

u = 1.92+ du = 0.26v = 1.58+ dv = 0.25
u · v = 3.05 old area
u · dv = 0.47 top strip (height grows)
v · du = 0.41 right strip (width grows)
du · dv = 0.06 corner — vanishes faster than dt

The change in area is u·dv + v·du + du·dv. Divide by dt: two finite slopes plus one tiny piece. Send dt → 0; the corner dies. What is left is (uv)' = u·v' + v·u'.

  • A top strip of width uu and height dvdv. Area: udvu \cdot dv.
  • A right strip of height vv and width dudu. Area: vduv \cdot du.
  • A tiny corner square of size dudvdu \cdot dv.

Now shrink dtdt. The two strips shrink linearly with dtdt. The corner shrinks quadratically — it has both dudu and dvdv in it, each going to zero. In the limit, the corner vanishes and the two strips survive.

The product rule

Divide the change in area by dtdt and send dt0dt \to 0:

  (uv)  =  uv  +  uv  \boxed{\;(uv)' \;=\; u' \, v \;+\; u \, v'\;}

Read it as: derivative of the first times the second, plus the first times the derivative of the second. The “plus” matters. The wrong rule misses the second term entirely.

Sanity-check it on f(x)=xxf(x) = x \cdot x with u=v=xu = v = x, so u=v=1u' = v' = 1:

(xx)  =  1x+x1  =  2x.(x \cdot x)' \;=\; 1 \cdot x + x \cdot 1 \;=\; 2x. \quad\checkmark

And on a real example, f(x)=x2sinxf(x) = x^2 \sin x:

ddx(x2sinx)  =  2xsinx  +  x2cosx.\frac{d}{dx}\bigl(x^2 \sin x\bigr) \;=\; 2x \cdot \sin x \;+\; x^2 \cdot \cos x.

Both terms have to be there.

A product, at a point

Differentiate f(x)=x2sinxf(x) = x^2 \sin x using the product rule.

What is f(0)f'(0)?

Quotients

Division is just multiplication by a reciprocal. One quick-and-dirty option is to write f/g=fg1f/g = f \cdot g^{-1} and use the product rule with the power rule (Karpathy’s micrograd does exactly this and never needs a dedicated division op). But there is also a direct rule worth knowing:

(fg)  =  fg    fgg2.\left(\frac{f}{g}\right)' \;=\; \frac{f' \, g \;-\; f \, g'}{g^2}.

The mnemonic is centuries old: low d-high minus high d-low, square the bottom and away we go. The order in the numerator matters — flip fgf'g and fgfg' and you get the negative of the right answer.

A quotient, at a point

Let f(x)=x2+1x3f(x) = \dfrac{x^2 + 1}{x - 3}.

Compute f(0)f'(0) to three decimals.

Two more rules in the bag

You now have:

(uv)=uv+uv(uv)=uvuvv2.(uv)' = u' v + u v' \qquad \left(\frac{u}{v}\right)' = \frac{u' v - u v'}{v^2}.

These let you differentiate any product or ratio of the elementary functions from the previous lesson. What you cannot yet do is differentiate a composition — a function inside another, like sin(x2)\sin(x^2) or ex2e^{-x^2} or the sigmoid 1/(1+ex)1/(1 + e^{-x}) that every neural network in the world is built on.

That is the chain rule, and it is the load-bearing piece of this entire module.

Lesson complete

Nice tinkering.