TL;DR
A function of several inputs has one slope for each input. The partial derivative with respect to one input is the slope you see when you move only that input and freeze all the others. You write it , with a curly in place of the plain of an ordinary derivative.
Stacking all the partial derivatives into a list gives the Gradient, which points in the direction the function grows fastest.
Where you'll see it: in the gradient descent step that trains a neural network, in the normal equations of linear regression, and in the rule for how a change in one input ripples through a computation.
Intuition
A hill with two directions
Stand on a hillside. The ground rises to the north and falls to the east. If you walk due north, the slope under your feet is one number. If you walk due east, it is a different number. Neither number alone describes the hill, but together they say how steep it is in every direction.
A function of two variables, , is exactly a hill: and are your position on the map, and is the height. The partial derivative with respect to answers "how steep is it if I move east while my north-south position stays put?" The partial derivative with respect to answers the same question for moving north.
The reason we need the idea is that most real quantities depend on many things at once. A bill depends on the price of each item. A loss depends on every weight in a model. To learn how one of those things affects the result, we have to isolate it. Freezing everything else is how we do that, and it turns a many-input problem into a sequence of one-input problems we already know how to solve with the ordinary Derivative.
- y = 0
- y = 1
- y = 2
Freeze, then differentiate
The recipe is always the same. Pick the input you care about. Treat every other input as a constant. Differentiate the resulting one-variable expression as usual. The answer is a new function that still depends on the remaining inputs.
That last point matters. The partial derivative is not a single number in general. It is a function, evaluated at a point where all the inputs are known.
The math
Definition
For a function of real variables, the partial derivative with respect to at a point is
whenever this limit exists.
Here is the point where we measure the slope, and is a small step taken along the axis only. Every other coordinate stays at its value in . The formula is the ordinary Derivative definition applied to the one-variable function that you get by freezing all the other inputs. The curly symbol is a reminder that the other inputs are being held still.
In practice you almost never use the limit directly. You use the rule: differentiate with respect to , pretend every other variable is a constant, and apply the usual rules of calculus.
Computing by hand
Take .
- To get , treat as a constant. The term is times , so it differentiates to . The term has no in it, so it differentiates to . Therefore .
- To get , treat as a constant. The term is a constant times , so it differentiates to . The term differentiates to . Therefore .
Nothing new happened beyond the ordinary rules. The only skill is remembering which letter is frozen.
Key results
Mixed partials commute. If the second partial derivatives are continuous, the order of differentiation does not matter:
This is sometimes called Clairaut's theorem or Schwarz's theorem. It means a function's curvature in the direction is well defined, and it is why the second-order information in optimisation is a symmetric matrix.
Linearity. Partial differentiation respects sums and constant multiples, exactly like ordinary differentiation: for constants and .
Local linear approximation. Near a point , if is differentiable there (for example, if its partial derivatives are continuous), the function is well approximated by a plane whose slopes are the partial derivatives:
This is the multivariable version of the tangent line, and it is the reason a small step in the gradient direction lowers a smooth function.
Worked examples
Let and evaluate the partial derivative with respect to at the point .
- Freeze . The function becomes .
- Differentiate in : .
- Evaluate at : .
Interpretation: at the point , moving east by a tiny amount raises the height about twice as fast as the horizontal distance you moved. The value does not depend on here, because has no in it. Check the other direction too: , so . Moving north is steeper at this spot.
Linear regression fits a line to data by minimising the mean squared error. For three points = , , , the loss is
Evaluate the partial derivatives at , .
- Compute the residuals : , , .
- The loss is .
- Differentiate with respect to , freezing . Each term contributes , so .
- Substitute: , so .
- Differentiate with respect to , freezing . Each term contributes , so .
- Substitute: , so .
Interpretation: both partials are negative, so increasing or a little lowers the loss. A gradient descent step moves each parameter in the opposite direction of its partial, so and both go up. The two partials tell you the steering for each knob separately, and the gradient bundles them together.
Tradeoffs and failure modes
Partial derivatives describe behaviour along coordinate axes only. They can mislead when the directions that matter are not aligned with the axes.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Steepest direction is diagonal | Each partial looks small, but the combined step is large | Use the gradient, which combines all partials into one direction |
| Function is not differentiable at the point | The limit does not exist, so the partial is undefined | Use subgradients or smoothing, as in the absolute-value kink |
| Inputs are strongly correlated | Changing one input alone is not physically meaningful | Use directional derivatives along the real direction of change |
| Need the full curvature | Second partials are many numbers to track | Use the Hessian matrix, or an approximation |
| Partials exist but the function is not smooth | Existence of partials does not imply the function is locally linear | Check continuity of the partials, or use a different analysis |
A common trap is assuming that existing partial derivatives means the function is well behaved. A function can have both partials at a point and still fail to be smooth there. The partials only check the axis directions.
History
Partial derivatives grew out of the calculus that Newton and Leibniz developed in the late 1600s. In the 1700s Leonhard Euler, Jean le Rond d'Alembert and Joseph-Louis Lagrange used them to study vibrating strings, fluids and mechanics. The curly was introduced by Adrien-Marie Legendre in the 1780s, fell out of use, and was revived by Carl Jacobi in the 1840s, after which it became standard.
They caught on because physics kept needing them. Heat flow, waves and fluid motion all depend on several variables at once, and the equations that govern them are written in partial derivatives. In the twentieth century the same tool became central to statistics and machine learning, where training a model means taking partial derivatives of a loss with respect to every parameter.
Check yourself
QuestionFor , what is ?Show answer
Treat as a constant. The function is times , so the derivative with respect to is the constant . The answer is . Note that it still depends on , as partial derivatives generally do.
QuestionFor , compute at the point .Show answer
Differentiate in , treating as a constant. The term has no , so it contributes . The term contributes . So . At this is . The answer is .
QuestionWhy do we freeze the other variables when taking a partial derivative, instead of letting them move too?Show answer
Freezing isolates the effect of one input. If every input moved at once, the observed change would mix together the effects of all of them, and you could not say how much of it came from a single input. The partial derivative answers the narrow question "what does this one input do, holding the rest fixed?" Moving all inputs at once is what the gradient and the total derivative describe.
QuestionA function has continuous second partial derivatives. Does it matter whether you differentiate first in and then in , or the other way round?Show answer
It does not matter. When the mixed second partials are continuous, the order of differentiation can be swapped without changing the result. This is the symmetry of mixed partials. It holds for the smooth functions that appear in most applications, which is why we can talk about the curvature in the direction without specifying an order.
QuestionIn a model with 10,000 parameters, roughly how many partial derivatives do you compute for one gradient, and what does training do with them?Show answer
One partial derivative per parameter, so about 10,000. Gradient descent collects them into a vector and takes a small step in the opposite direction, lowering the loss a little. Each partial tells you how that single parameter should move, given all the others stay where they are for that instant.