1.2.3 · D4Calculus & Optimization Basics

Exercises — Partial derivatives

2,405 words11 min readBack to topic

Level 1 — Recognition

Can you read a partial derivative and apply the freeze rule to simple terms?

Recall Solution 1.1

Freeze to find . The term has slope in ; the term has no , so its -slope is . Each variable's coefficient is just its own slope — a flat plane tilts by a fixed amount in each direction.

Recall Solution 1.2

Differentiate normally (); has no so vanishes. Notice the two answers are completely decoupled — no cross terms exist, so each depends on only its own variable.


Level 2 — Application

Products, powers, and the chain rule where one variable is a constant multiplier.

Recall Solution 2.1

: freeze , so is a constant multiplier. , carried along by : : freeze , so is a constant multiplier. :

Recall Solution 2.2

: is a frozen multiplier on , and ; the lone gives : : freeze , so is a constant multiplier on , giving ; the term has no so vanishes:

Recall Solution 2.3

Let the inside be . Outer: . Then multiply by the inner partial. (freeze ), so (freeze ), so The exponential never disappears — it's always ; only the inner factor changes with which variable you moved.


Level 3 — Analysis

Interpret partials geometrically and evaluate at a point.

The figure below plots as contour rings (each ring is one fixed height; the numbers are the values ). The yellow dot is the point from Exercise 3.1. Watch the two coloured arrows leaving it: the blue arrow points east and shows the -slope (uphill, crossing to higher rings), the pink arrow points north and shows the -slope (downhill, toward a lower ring). The dashed yellow arrow is , the steepest way down — always perpendicular to the ring it starts on.

Figure — Partial derivatives
Recall Solution 3.1

and . At : Reading the signs (blue and pink arrows in the figure above): means stepping east uphill (surface rises), and it is steep. means stepping north goes downhill, less steeply. So from the fastest way down the bowl is to move west and slightly north — exactly the dashed direction .

Recall Solution 3.2

and .

  • At : both are — the surface is momentarily flat in both axis directions (a saddle passing through here).
  • At : (uphill east), (flat north). Why the difference: the -slope of is the height of — the more north you already are, the steeper the east–west tilt. This is the hallmark of a coupled function: one variable's slope depends on the other's value.
Recall Solution 3.3

Nothing depends on any input, so nudging any variable changes nothing. The gradient is the zero vector — a critical point at every location. This is the limiting "totally flat" case that anchors your intuition: no slope, no direction to descend.


Level 4 — Synthesis

Assemble partials into a gradient and connect to the ML loss.

Recall Solution 4.1

Differentiate once per variable, freezing the other two each time:

  • (only has an )
  • (; ; has no )
  • (; ) Stacking these three slopes into a vector gives the direction of steepest ascent — recall the gradient definition from the parent note. See 1.2.04-Gradient-and-directional-derivatives.
Recall Solution 4.2

Let the residual . Chain rule: , with and . Evaluate: residual . Both negative raising or would lower the loss right now (residual is , prediction too small). This is exactly the update signal Linear-regression uses.


Level 5 — Mastery

Do the whole loop: gradient, evaluate, take a gradient-descent step, prove from first principles.

The figure below shows this journey on the same contour rings of . The yellow dots are the successive points ; each blue arrow is one update , always pointing inward (perpendicular to the ring) toward the pink star at the minimum . Notice the steps shrink as the slope flattens near the bottom.

Figure — Partial derivatives
Recall Solution 5.1

Gradient: . At : . Step (subtract gradient because we descend — 1.3.01-Gradient-descent): so . Confirm loss dropped: ✅. The point slid toward the bowl's bottom — this is the first blue arrow in the figure above.

Recall Solution 5.2

Here we nudge , so while stays put: Why this step: the definition perturbs only ; is untouched. Why this step: the terms cancel, factors out and cancels, then leaves . Shortcut check: treat as a constant multiplier on ; . ✅ Match.

Recall Solution 5.3

Residual . Each partial is times the inner factor (, , ): Feature is twice as large, so its weight's gradient is twice as strong — the model's slope in that direction is amplified by its input. This is the multivariable pattern that scales up to real networks via 1.2.05-Chain-rule-multivariable.


Connections