1.2.5 · D3Calculus & Optimization Basics

Worked examples — The Jacobian matrix

2,958 words13 min readBack to topic

The scenario matrix

Before working anything, let us list every case class a Jacobian problem can fall into. This is a checklist, not just decoration — read it like this:

  • The # column gives each case a short letter name (A through I). We only use these letters as bookmarks so that each worked example can say "this one covers case A."
  • The Case class column (in bold) is the plain-English name of the situation.
  • The What makes it special column is the one idea to remember for that case.
  • The Covered by column tells you exactly which worked example below drills that case, so you can jump straight to it.
# Case class What makes it special Covered by
A Square, generic point () exists → area/volume scaling Ex 1, Ex 3
B Non-square, tall () no determinant; column-space is a surface Ex 2
C Non-square, wide () no determinant; nullspace = directions that don't move output Ex 4
D Singular point () map locally squashes area to zero Ex 3
E Zero / degenerate input partials blow up or vanish; check the definition survives Ex 5
F Elementwise / diagonal off-diagonals vanish → cheap Jacobian (softmax-ish) Ex 6
G Chain / composition , order matters Ex 7
H Word problem (real units) interpret entries as physical rates Ex 8
I Exam twist trick: transpose / shape / commutativity trap Ex 9

Every cell A–I is hit at least once below.


Example 1 — square, generic point, with area scaling (Cell A)

Step 1 — Take all four partials. Why this step? By definition : differentiate output w.r.t. input , holding the other input fixed.

Step 2 — Assemble the matrix. Why this step? Rows = outputs, columns = inputs. Plugging in the point turns symbolic slopes into the concrete local linear map.

Step 3 — Area factor via the determinant. Why this step? For a square Jacobian, is the local area-scaling factor — how much a tiny patch's area is multiplied.

The figure below shows this. On the left, a small coral (red) unit square sits at the input point . On the right is its image after the linear map : a lavender (blue) parallelogram whose area is times bigger. Notice the parallelogram is both stretched and rotated — the two effects that packs into one matrix.

Figure — The Jacobian matrix
Recall Verify

A tiny square of side near has area . Its image is a parallelogram with area . So it grows by a factor of . (For the general factor is . ✔) Sanity: , always — this map never flips orientation except at the origin.


Example 2 — non-square TALL map, a surface in 3D (Cell B)

Step 1 — Shape first. Inputs , outputs , so is a matrix. Why this step? Rows are outputs (3), columns are inputs (2). must send to : . ✔

Step 2 — Partials. Why this step? Each column tells you the 3D velocity of the surface point as you push one input. Column 1 = ; column 2 = . These two columns span the tangent plane to the surface.

Step 3 — Determinant? No. needs a square matrix (). Here , so there is no determinant. Why this step? Determinant measures how one -volume maps to another -volume; that only makes sense when input- and output-dimension match.

Recall Verify

The two columns and are linearly independent (neither is a multiple of the other), so the tangent plane is genuinely 2D — the surface isn't degenerate at . Rank . ✔


Example 3 — square but SINGULAR point (Cells A + D)

Step 1 — Plug in. Why this step? from Ex 1, which is only at the origin.

Step 2 — Interpret . The local linear map crushes every input direction to (nearly) zero — a tiny patch's first-order area collapses. Why this step? is the area factor; a factor of means the linear approximation flattens the neighbourhood. (The true map actually doubles angles and squishes near — the linear part just can't see that curvature.)

The figure below contrasts the two behaviours side by side. On the left, a small coral square sits right at the origin. On the right, its image under is squished almost to a point — unlike the fat parallelogram we saw in Example 1, here the area is driven toward zero because .

Figure — The Jacobian matrix
Recall Verify

Points near : , size . The output shrinks faster than the input — consistent with zero linear scaling. A point where is called a singular (or critical) point. ✔


Example 4 — non-square WIDE map with a nullspace (Cell C)

Step 1 — Shape. , is a matrix, a row vector. Why this step? Scalar output ⇒ single row. This is the gradient transposed: .

Step 2 — Entries. Why this step? .

Step 3 — Nullspace = "silent" directions. means . Any on that plane changes nothing to first order. Why this step? ; if , the output holds still. Example: gives . ✔

Recall Verify

. Moving along keeps constant — that's a direction inside a level set, perpendicular to the gradient. ✔ The nullspace here is 2-dimensional ().


Example 5 — zero / degenerate input where a partial misbehaves (Cell E)

Step 1 — Write the full Jacobian. Why this step? We need every entry visible before we can see which part collapses. Column 1 is and column 2 is .

Step 2 — Determinant. At : . Why this step? At the area factor vanishes — a singular point.

Step 3 — Why it's degenerate. Set in the matrix: The entire second column is zero for every . So the -direction carries no information: at every angle maps to the same point , and the map isn't locally one-to-one. Why this step? (equivalently, a zero column ⇒ rank not ) is the algebraic signal that the local linear map is not invertible — the whole -column of information collapses.

Step 4 — Away from the origin it's fine. For any , : invertible, orientation-preserving. Why this step? Confirms the degeneracy is isolated to , which is why polar integration writes the factor as — the vanishing at the origin is a genuine feature, not a bug.

Recall Verify

Column 2 of at : . Zero column ⇒ ⇒ rank . ✔


Example 6 — elementwise / diagonal Jacobian: softmax's cheaper cousin (Cell F)

Step 1 — Off-diagonals vanish. depends only on , so for . Why this step? Elementwise activations have no cross-talk between coordinates → Jacobian is diagonal, which is why frameworks store it as a vector, not a full matrix.

Step 2 — Diagonal entries. . So

Step 3 — Numbers. . . Why this step? Each diagonal entry is the slope of the activation at that coordinate — its local gain in backprop.

Recall Verify

; . And at the slope of is exactly . ✔ Off-diagonals are exactly . ✔


Example 7 — chain rule, order matters (Cell G)

Step 1 — Inner Jacobian. (since ). Why this step? Differentiating a linear map returns the matrix itself.

Step 2 — Evaluate . . Why this step? We need to evaluate the activation's slopes. Both entries are , where .

Step 3 — Outer (diagonal) Jacobian. .

Step 4 — Compose, outer on the LEFT (see The chain rule (multivariable)). Why this step? . The outer function's Jacobian multiplies on the left; the reversed product would still be defined here but is wrong in general.

Recall Verify

At the activation is transparent (), so the composite Jacobian equals exactly. ✔


Example 8 — real-world word problem, with units (Cell H)

Step 1 — Jacobian symbolically. Why this step? Column 1 = "response of every output to a nudge in machine time" — exactly what the question asks.

Step 2 — Evaluate at . Why this step? ; .

Step 3 — Nudge machine time by hr, . So widgets and kJ heat per extra hour. Why this step? Multiplying by the input-change vector picks out column 1 — the machine-time column.

Recall Verify (units + exact)

Widgets: is linear, so exactly units/hr — the linear estimate is exact here. Heat: kJ. ✔ Units check: is (units)/(hr), consistent. ✔


Example 9 — exam twist: the transpose / commutativity trap (Cell I)

Step 1 — Fix the shape error. has , so its Jacobian is a row, not a column: Why this step? Rows = outputs. One scalar output ⇒ one row. The column the student wrote is the gradient; the Jacobian is its transpose.

Step 2 — Get the composition order right. The composite is , meaning "apply first, then ." The chain rule puts the outer function's Jacobian on the LEFT: Check the shapes conform: takes a scalar and returns 2 outputs, so is ; is . The product is . The reversed order would be — the wrong shape, so order genuinely matters. Why this step? Matrix multiplication is not commutative; only the outer-on-the-left order has conforming inner dimensions.

Step 3 — Evaluate the inner scalar. . Why this step? We must feed 's output value into before differentiating the outer map.

Step 4 — Outer Jacobian at . , so Why this step? ; the second output's slope is .

Step 5 — Multiply, outer on the left. Why this step? An column times a row is an outer product, giving the full Jacobian of the composite.

Recall Verify

; ; top row . ✔ , so bottom row . Shapes: . ✔


Active-recall

When is defined and what does it measure?
Only when is square (); is the local area/volume-scaling factor.
For a scalar function, is the Jacobian a row or a column?
A row () — it is ; the gradient is the column.
In , which Jacobian goes on the left?
The outer function's, : .
What does mean geometrically?
A singular point — the local linear map collapses area to zero and is not invertible there.
Why is an elementwise activation's Jacobian diagonal?
Each output depends only on its own input, so all off-diagonal partials are zero.