Partial Derivatives and the Multivariable Chain Rule
Learning Objectives
- Define the partial derivatives and as limits, compute them by freezing the other variable, and read each as the slope of a slice of the graph.
- State the equality of mixed partials with its hypothesis, and recognize a function where it fails.
- Build the tangent plane as the linear approximation of , and explain why differentiability asks for more than the existence of partial derivatives.
- Apply the multivariable chain rule for one and two parameters, including the implicit slope of a level curve.
- Use the chain rule to differentiate a small computation graph, the idea behind backpropagation.
Context & Motivation
A function of several variables has no single slope at a point: the slope depends on which way you walk. The simplest way to tame this is to walk along one coordinate axis at a time, holding every other variable fixed. The result is a partial derivative, which is an ordinary single-variable derivative applied to a slice of the surface from functions-of-several-variables-and-level-curves. The existing lesson gradients-extending-derivatives-to-several-variables uses partial derivatives informally, as "how fast changes if you nudge one variable". Here the limit definition comes back, together with the question that informal treatment skips: when does the list of partial derivatives actually describe how behaves in every direction?
The second half of the lesson is the chain rule. Real computations are compositions: a loss depends on a prediction, which depends on a score, which depends on weights. Every derivative needed to train such a model comes from the chain rule applied through intermediate variables. The single-variable version is in differentiation-rules-and-the-chain-rule, and the new difficulty is that an intermediate quantity can depend on the input through several routes at once.
Core Theory
Partial derivatives
For at ,
when the limits exist. Geometrically, is the slope at of the curve where the vertical plane cuts the graph. In practice, differentiate with respect to one variable and treat the other as a constant. Other notations are and . Notice what the definition uses: along two lines through the point and nothing else. On a contour map, can be estimated by stepping east from the point to the next level curve: the change in height divided by the distance walked. Contours packed closely along the east-west direction mean a large , and the sign says whether the surface rises or falls as you go east.
Mixed partials
Differentiating twice gives , and the mixed partials and . Clairaut's theorem: if is defined on a disk around and both and are continuous on that disk, then . Polynomials, exponentials, sines and their compositions meet the hypothesis everywhere. Also keep the notation straight: means differentiate in first, then in , and some books write the opposite order. Example 3 shows what happens when it fails.
Differentiability and the tangent plane
The right generalization of "differentiable" is linear approximability. is differentiable at if there are numbers and with
If this holds, then and , and the plane
is the tangent plane, the best linear approximation: the error shrinks faster than the distance to the point. A differentiable function is continuous. The existence of and is not enough, since they only see two directions. A usable sufficient condition: if and exist in a neighborhood of and are continuous at , then is differentiable there. Functions with continuous first partials are called . In terms of the approximation, the change of a differentiable function is for small steps, and the right-hand side is the differential . It is what turns a measurement error in and into an error in .
The chain rule
Let be differentiable at , with and differentiable at . Then is differentiable at and
With two parameters, and , each parameter gets its own sum:
Here is why differentiability is the right hypothesis. For a small step in , the linear approximation gives with and . Dividing by and letting gives the formula. If only has partials, the first approximation is not available. The rule is: add one product for every route from to the parameter, multiplying the derivatives along the route.
Implicit slope. Suppose defines as a differentiable function of near a point where is and . Differentiating with the chain rule gives , so . This is the slope of the level curve from the previous lesson. Where the formula breaks, and the level curve may have a vertical tangent.
Worked Examples
Example 1: linear approximation of a distance
Let , the distance from the origin, at where . Then and there, so
At : , and the true value is , an error of about . The numbers also have a meaning: stepping east raises the distance by per unit, less than because east is not straight away from the origin. Stepping straight away, in the direction , changes it at rate , as it must for a distance. The next lesson explains this combination. Halving the displacement should quarter the error, and it does:
textdisplacement (d, -d) true f L error d = 0.1 4.981967 4.980000 0.001967 d = 0.05 4.990491 4.990000 0.000491 d = 0.025 4.995123 4.995000 0.000123
Example 2: mixed partials
Let . Then and . Differentiating again,
Both are continuous everywhere, so Clairaut applies and the equality is guaranteed, not a coincidence.
Example 3: a function where mixed partials differ
Let for and . For , tends to as , and , so for all . Symmetrically for all . Therefore
A numerical check with an inner step of and an outer step of gives and (the value is for inner step and outer step , so equal steps would give exactly ). Both mixed partials exist but are not continuous at the origin, which is exactly the hypothesis that Clairaut needs.
Example 4: the chain rule with two parameters
Let with and , at , where and .
Substituting first gives , so and . A centered finite difference agrees.
Example 5: the chain rule through a neuron
A single sigmoid neuron has score , output and loss . The route from to passes through and , so
Take , , , . Then , , , and
Centered finite differences give and . Both are negative: increasing or lowers the loss here. Backpropagation is this same product of local derivatives, computed from the loss backward and reused across all the routes.
The finite-difference check is also a standard debugging tool: compare the analytic derivative with . The centered form has error of order , but it costs two evaluations of the loss per parameter, which is why it is used to test a gradient and not to compute one for a model with millions of parameters.
Example 6: the implicit slope, and a broken chain rule
For at : and , so and the tangent line is .
Now the hypothesis. Take with . Its partials at the origin are both , because . Along , the composite is for and , which is not even continuous at , yet the formula would produce . The chain rule failed because is not differentiable at the origin.
Common Misconceptions & Pitfalls
- "If both partials exist, is differentiable (or at least continuous)." The function of Example 6 has both partials at the origin and is not continuous there.
- "Mixed partials are always equal." Only under the continuity hypothesis. Example 3 gives and .
- "The symbols cancel like fractions." Writing and cancelling drops the route through . The chain rule is a sum over routes, not a single product.
- "The tangent plane approximates well everywhere." It is a local statement. The error is small near the point and grows away from it.
- "The chain rule only needs the partial derivatives to exist." It needs to be differentiable at the point, which is what fails in Example 6. Continuous first partials are the usual way to guarantee it.
- " and are interchangeable." Use when the quantity depends on a single variable, and when the other variables are held fixed.
Summary
A partial derivative is a single-variable derivative along one coordinate axis, the slope of a slice. Mixed partials agree when both are continuous near the point, and can differ otherwise. Differentiability, meaning a linear approximation whose error vanishes faster than the distance, defines the tangent plane and is guaranteed by continuous first partials, but not by the mere existence of partials. For a differentiable composed with differentiable inner functions, the chain rule sums one product per route, which gives the implicit slope of a level curve and the derivatives of a neuron's loss. The next lesson, directional-derivatives-and-the-direction-of-steepest-ascent, assembles the partials into the gradient and uses the chain rule to read off slopes in every direction.
Documentation Links
- OpenStax Calculus Volume 3, 4.3 Partial Derivatives
- OpenStax Calculus Volume 3, 4.4 Tangent Planes and Linear Approximations
- OpenStax Calculus Volume 3, 4.5 The Chain Rule
- Active Calculus Multivariable, First-Order Partial Derivatives
- Active Calculus Multivariable, The Multivariable Chain Rule
- MIT OCW 18.02SC, Unit 2 Part B: Chain Rule, Gradient and Directional Derivatives