NapkinCalc

Multivariable Calculus — Vectors & Gradients

Partial derivatives & the gradient

continues from lesson 2 — values defined earlier in the course stay live here

ELI5: a partial derivative wiggles one variable while holding the others still — the slope in just that direction. We measure them numerically below. Bundle the partials together and you get the gradient, the arrow pointing steepest uphill.

dfdx=f2(2+0.000001,3)f2(2,3)0.000001df_{dx} = \frac{\mathrm{f2}\left(2 + 0.000001, 3\right) - \mathrm{f2}\left(2, 3\right)}{0.000001} = 4.00004.0000 ∂f/∂x at (2,3): should be 2x = 4
dfdy=f2(2,3+0.000001)f2(2,3)0.000001df_{dy} = \frac{\mathrm{f2}\left(2, 3 + 0.000001\right) - \mathrm{f2}\left(2, 3\right)}{0.000001} = 6.00006.0000 ∂f/∂y at (2,3): should be 2y = 6
✓ pass abs(dfdx4)<1e3andabs(dfdy6)<1e3abs(df_{dx} - 4) < 1e-3 and abs(df_{dy} - 6) < 1e-3 both partials match the hand-calculated slopes

Real-world hook: the gradient is the workhorse of machine learning — "gradient descent" repeatedly steps downhill on the error landscape to train a model. It's also heat flow (down the temperature gradient) and a hiker's steepest path.

Try it yourself: for g(x, y) = x²·y, find ∂g/∂x at (3, 2). (By hand that's 2xy = 2·3·2.)

g3(x,y)=x2yg3\left(x, y\right) = x^{2} \cdot y
gxyou=12gx_{you} = 12 ✏️ Your turn: find ∂g/∂x of x²y at (3, 2). The check compares your value to the true partial slope.
✓ pass abs(gxyoug3(3+0.000001,2)g3(3,2)0.000001)<0.01\mathrm{abs}\left(gx_{you} - \frac{\mathrm{g3}\left(3 + 0.000001, 2\right) - \mathrm{g3}\left(3, 2\right)}{0.000001}\right) < 0.01 green when it matches the measured partial derivative