1.2.3 · D2Calculus & Optimization Basics

Visual walkthrough — Partial derivatives

1,804 words8 min readBack to topic

Everything here uses one running function: We will compute — the east–west slope — and get , exactly as the parent note claims, but this time picture by picture.


Step 1 — The output is a HEIGHT above a floor

WHAT. Two inputs and live on a flat floor (think east and north). The function gives one number: how high the surface floats above the point . We call that height .

WHY. Before any calculus, we must know what "the answer changes" even means. Here it means the height goes up or down. A partial derivative will end up being a slope, and slope only makes sense once we have a height to be sloped.

PICTURE. The floor is the flat plane; every point on the floor sends a vertical stick up to the curved sheet above. The sheet is our surface .

Figure — Partial derivatives

Step 2 — Freeze : slice the hill with a wall

WHAT. Pick one fixed north value, say . Slide a vertical wall along that line . Where the wall cuts the surface, we get a single curved line — a 1-D curve, no longer a 2-D sheet.

WHY. A partial derivative asks "nudge only ." If is not allowed to move, then is stuck at forever. Geometrically, " stuck at " is the wall. Standing on that wall, we have gone from a hard 2-input problem to an easy 1-input curve — and a 1-input curve has an ordinary slope we already know how to find (see 1.2.02-Derivatives-single-variable).

PICTURE. The magenta wall at slices the sheet. The bright curve on the wall is our sliced height, which now depends on alone.

Figure — Partial derivatives

On this slice, substitute into :

  • ::: the only piece that changes as we walk east — is now just a number multiplier.
  • ::: a flat constant height — it has no , so it lifts the whole curve up but never tilts it.

Step 3 — Take one tiny step to the east

WHAT. From position , step a small amount to the right, landing at . Read the new height . Keep where it was.

WHY. Slope means "rise over run." To measure rise we need two heights: one here, one a little over. The little run is . We keep identical in both readings — that is the whole trick of "partial."

PICTURE. Two vertical sticks on the same wall: one at (height ), one at (height ). The gap between the stick-tops is the rise; the floor gap is the run .

Figure — Partial derivatives

  • ::: the rise — how much taller (or shorter) we became.
  • ::: the run — the size of the step. Notice the same sits inside both height terms.

Step 4 — Plug in the actual function and watch pieces cancel

WHAT. Substitute into that rise-over-run fraction.

WHY. Now it is pure algebra. Any term that appears identically in both height readings will subtract to zero — because it didn't change when we stepped. Watch which survives.

Expand :

Colour-track each survivor and each casualty:

  • appears twice with opposite sign → cancels. (It was the same at both sticks.)
  • appears twice with opposite sign → cancels. (No inside — flat — never tilted.)
  • and survive — they are the only pieces carrying an .

PICTURE. The two "before/after" bars split into stacked blocks; the identical blocks (, ) grey out and disappear, leaving only the -blocks that made the height change.

Figure — Partial derivatives


Step 5 — Cancel the run, then shrink the step to zero

WHAT. Every surviving term has a factor of . Divide it out, then let shrink toward .

WHY. Dividing by turns "rise over run" into "slope so far." Letting answers the real question: at the exact point (not over a fat step), how steep is it? This shrinking is the limit — the tool we borrow precisely because it converts an average slope over a step into an instant slope at a point. No smaller tool can do that: algebra alone can't reach "infinitely close."

  • ::: survives the shrink — it has no leftover , so it is the true instantaneous slope.
  • ::: has a lonely , so as it vanishes — the fat-step error melts away.

PICTURE. The two sticks slide together. The slanted "secant" line (through both stick-tops) rotates until it just kisses the curve — the tangent. Its steepness settles on .

Figure — Partial derivatives


Step 6 — Now freeze the OTHER variable (the symmetric case)

WHAT. Repeat everything, but this time freeze and nudge . The wall now runs the other way, along const.

WHY. A partial derivative comes in one flavour per input. We must show both so no reader hits a case we skipped. The mechanics are identical — just swap which wall we stand on.

Freeze , differentiate in (here and are the frozen numbers):

  • ::: the -term's partner in ; with frozen it's a constant slope-per-unit-.
  • ::: now does tilt (it has a !), giving slope — the mirror of Step 4, where it was flat.

PICTURE. Two walls on the same hill: the magenta wall (Step 2) gives ; the orange wall (this step) gives . Different slices, different slopes.

Figure — Partial derivatives

Step 7 — Degenerate & edge cases (so nothing surprises you)

WHAT & WHY. We check the corners where formulas often break.

  • Flat direction, . At : for every . The slice at is — a dead-flat line, zero slope everywhere. Consistent.
  • A term with no chosen variable. Any constant-in- term (like , or a bare ) always dies in : two equal heights subtract to before we even divide. This is why the parent says "treat as ruthlessly as the number ."
  • The single-input limit. If secretly depends on only one variable, its partial is the ordinary derivative — the wall slices nothing away. Partial derivatives contain single-variable derivatives as a special case, never contradict them.
  • Stacking both slopes. Put the two answers side by side and you have built the gradient: This vector is what steepest ascent and gradient descent actually consume; Example 3 in the parent is exactly the linear-regression version.
Figure — Partial derivatives

The one-picture summary

Figure — Partial derivatives

One hill, two walls, two tangent lines, one gradient arrow — the entire walkthrough in a single frame: freeze one input → slice → measure rise over a step → shrink the step → read the tangent slope → repeat for each input → stack into .

Recall Feynman: tell it to a 12-year-old

You're standing on a curvy hill. Your height depends on how far east you are () and how far north you are (). First, promise not to move north — that's like standing against an invisible wall. Now your hill has become a single curvy path running east. Take one baby step east and see how much your head went up; divide that height-gain by how big the step was — that's your steepness "so far." Take smaller and smaller steps and the number settles down to one exact value: that's the east-slope, . Notice a funny thing: the part of your height that had nothing to do with east (the part) never changed as you stepped, so it added zero to the slope — it just quietly disappeared. Now turn to face north, put up the other wall, and do it all again to get the north-slope, . Two slopes together tell you exactly which way is downhill fastest — and "downhill fastest" is precisely how a computer learns.


Connections