1.2.2Calculus & Optimization Basics

Derivatives and rules (product, quotient, chain)

1,829 words8 min readdifficulty · medium

1. What a derivative actually is (first principles)

WHY this definition? Slope = rise/run = ΔyΔx\frac{\Delta y}{\Delta x}. Over a finite interval hh this is only an average slope. To get the slope at a single point we shrink the run h0h\to 0. The limit turns "average over a window" into "instantaneous rate."

The power rule (general): ddxxn=nxn1\dfrac{d}{dx}x^n = n x^{n-1}. It comes from the same binomial expansion — only the (n1)xn1h\binom{n}{1}x^{n-1}h term survives after dividing by hh and taking h0h\to0.


2. The three combination rules

You rarely differentiate raw powers. Real functions are built by multiplying, dividing, and composing. Each rule handles one construction.

2.1 Product rule

Derivation (WHY it's a sum of two terms). Nudge xx by hh. The product changes from uvuv to (u+Δu)(v+Δv)(u+\Delta u)(v+\Delta v): Δ(uv)=(u+Δu)(v+Δv)uv=vΔu+uΔvfirst order+ΔuΔvtiny\Delta(uv)=(u+\Delta u)(v+\Delta v)-uv = \underbrace{v\,\Delta u + u\,\Delta v}_{\text{first order}} + \underbrace{\Delta u\,\Delta v}_{\text{tiny}} Divide by hh and let h0h\to0: Δu/hu\Delta u/h \to u', Δv/hv\Delta v/h\to v', and ΔuΔv/h0\Delta u\,\Delta v/h \to 0 (product of two shrinking things). Hence uv+uvu'v+uv'.

2.2 Quotient rule

Derivation. Write q=u/vq=u/v, so u=qvu = q\,v. Differentiate with the product rule: u=qv+qvu' = q'v + qv'. Solve for qq': q=uqvv=uuvvv=uvuvv2q' = \frac{u' - qv'}{v} = \frac{u' - \frac{u}{v}v'}{v} = \frac{u'v - uv'}{v^2} So the quotient rule is not new — it's the product rule solved backwards.

2.3 Chain rule

Derivation (WHY multiply?). Rates multiply. If uu changes 3× as fast as xx, and yy changes 2× as fast as uu, then yy changes 2×3=62\times3 = 6× as fast as xx: ΔyΔx=ΔyΔuΔuΔx\frac{\Delta y}{\Delta x} = \frac{\Delta y}{\Delta u}\cdot\frac{\Delta u}{\Delta x} The Δu\Delta u cancels formally, and taking h0h\to0 gives the exact product of derivatives.

Figure — Derivatives and rules (product, quotient, chain)

3. Worked examples


4. Common mistakes (steel-manned)


5. Flashcards

Definition of derivative as a limit
f(x)=limh0f(x+h)f(x)hf'(x)=\lim_{h\to0}\frac{f(x+h)-f(x)}{h} — the slope of the tangent line.
Power rule
ddxxn=nxn1\frac{d}{dx}x^n = nx^{n-1}.
Product rule
(uv)=uv+uv(uv)' = u'v + uv' (two rectangle strips).
Quotient rule
(uv)=uvuvv2\left(\frac{u}{v}\right)' = \frac{u'v - uv'}{v^2}.
Chain rule
For f(g(x))f(g(x)): f(g(x))g(x)f'(g(x))\cdot g'(x) — rates (gear ratios) multiply.
Why does the product rule have two terms?
A rectangle of sides u,vu,v grows on both sides; each side adds an area strip (vΔuv\Delta u and uΔvu\Delta v).
Where does the quotient rule come from?
Apply the product rule to u=qvu=qv and solve for qq'.
Derivative of sigmoid σ(x)\sigma(x)
σ(x)=σ(x)(1σ(x))\sigma'(x)=\sigma(x)(1-\sigma(x)).
Common product-rule error and fix
(uv)uv(uv)'\ne u'v'; correct is uv+uvu'v+uv'.
What does the chain rule correspond to in neural nets?
Backpropagation — gradients multiply layer by layer.

Recall Feynman: explain to a 12-year-old

A derivative is just speed. If your car's position is a curve, the derivative tells you how fast you're going right now.

  • Product rule: Imagine a photo that gets both wider AND taller at once. Its area grows for TWO reasons — so you add up two growths.
  • Chain rule: Gears! If a small gear spins a big gear that spins a huge gear, the total spin is all the gear ratios multiplied together.
  • Quotient rule: Sharing a pizza. If the pizza (top) grows you get more; if the number of friends (bottom) grows you get less — that "less" is the minus sign.

Connections

Concept Map

shrink h to 0

equals

drives

binomial expansion

combination rules

combination rules

u prime v + u v prime

solved backwards

u prime v - u v prime over v^2

handles nesting

Limit of rise over run

Derivative f prime x

Slope of tangent line

ML training gradient

Power rule n x^n-1

Product rule

Chain rule

Rectangle area intuition

Quotient rule

Denominator growth shrinks fraction

Composed functions

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, derivative ka matlab bas ek cheez hai: agar input ko thoda sa hilaao, toh output kitna aur kis direction mein badalta hai. Yeh curve ka local slope hai. ML mein yeh sabse important cheez hai — model train karna matlab baar-baar poochhna "weights ko kis taraf push karun taaki loss kam ho?" — aur woh direction hi derivative (gradient) hai.

Ab teen rules. Product rule: (uv)=uv+uv(uv)' = u'v + uv' — do terms kyun? Socho ek rectangle jiski sides uu aur vv hain. Agar dono sides badhte hain, toh area do strips se badhta hai, isliye do terms. Quotient rule: uvuvv2\frac{u'v - uv'}{v^2} — yeh koi naya rule nahi, product rule ko ulta solve karke aata hai. Minus sign isliye kyunki denominator badhne se fraction chhota hota hai. Chain rule: f(g(x))g(x)f'(g(x))\cdot g'(x) — rates multiply hote hain, bilkul gears ki tarah. Yeh exactly backpropagation hai neural networks mein.

Sabse common galti: log sochte hain (uv)=uv(uv)' = u'v' — yeh galat hai, kyunki linearity sirf addition ke liye hai, multiplication ke liye nahi. Doosri galti: chain rule mein andar wala derivative bhoolna — jaise (3x2+1)5(3x^2+1)^5 mein 6x\cdot 6x lagana zaroori hai warna galat answer.

Yaad rakhne ka tareeka: Product = "pehla ka derivative into doosra, plus pehla into doosre ka derivative." Quotient = "Lo D-Hi minus Hi D-Lo, over Lo-Lo." Chain = "bahar se andar" — pehle bahar wala differentiate karo, phir andar wale se multiply. Sigmoid ka derivative σ(1σ)\sigma(1-\sigma) — yeh clean form isliy ML mein bahut use hota hai.

Go deeper — visual, from zero

Test yourself — Calculus & Optimization Basics

Connections