Total Derivative
A partial derivative freezes everything but one input. The total derivative unfreezes them all and reports what actually happens when everything moves.
Why Does This Exist?
Partials lie by omission, politely. tells you what happens when moves and nothing else does. But in any model worth training, nothing else stays still: and are both computed from shared upstream parameters, so nudging one dial turns several gears. Optimizers, sensitivity analyses, and hyperparameter studies all need the honest number, the one counting every gear.
The total derivative is that number. It is the multivariable chain rule viewed as an accounting identity: each dependency is a route, each route contributes, and the total is the sum. Confusing it with a partial is one of the quietest bugs in ML mathematics, because the wrong answer looks exactly like the right one with a smaller value.
The one idea you need first
A partial derivative holds all other direct inputs fixed. The total derivative holds nothing fixed: it follows through every variable touches. Same function, different question. One asks about an isolated nudge, the other about a coordinated move, and only the second describes what happens during training.
Think of It Like This
Rent when both price and flat size change
Your rent is price per square metre times area. The landlord raises the unit price and you also move to a bigger flat in the same month. Asking how much of the bill change came from the price alone is the partial question. Asking what your new bill actually is needs both changes plus their interaction.
The total derivative does that full accounting. It takes the price route (new price on the old area), the area route (old price on the new area), and adds them. Skip either route and your budget is wrong in exactly the direction you ignored. The estimate stops working only for large moves, where the interaction term the linear sum drops starts to matter.
How It Actually Works
For with and both functions of :
In plain words: pushes through and through , and the total push is both pushes added. When only one variable depends on , the other term is zero and the total collapses to a single product. When neither does, both terms vanish, which is the formal way of saying a constant does not move.
The differential form says the same thing for small steps: . Each term pairs a frozen sensitivity with the actual movement of its variable. Gradient descent lives on this identity: the loss change over a step is approximately the gradient dotted with the step, which is the total derivative along the step direction.
Worked example
Take with and , at .
Position first: , , . The frozen partial . If you stopped there, you would predict that raising nudges gently.
The total says otherwise. Via : . Via : . Total: , more than five times the partial. Direct check: , so . The partial missed the route entirely.
Code
Two routes to the same number: the route-by-route total and the substituted direct derivative.
def total_rate(t: float) -> float: x = t**2 y = t + 1 return y * 2 * t + x * 1 # x route plus y route
def direct(t: float) -> float: return 3 * t**2 + 2 * t # from f(t) = t^3 + t^2
print(total_rate(2.0)) # -> 16.0print(direct(2.0)) # -> 16.0Both print 16. The first line inside total_rate is the definition in code: each term is one dependency route, and deleting either term reproduces the classic bug.
Watch Out For
Reporting the partial as the answer in a coupled system
In a network every activation depends on shared weights, so almost no variable moves alone. Quoting where belongs understates sensitivities, misranks feature importance, and mistunes step sizes. The symptom is a sensitivity analysis that disagrees with finite differences. The fix is mechanical: list every variable the input touches and sum the routes.
Detaching a variable and deleting its route in code
Calling .detach() or stop_gradient on a tensor severs a dependency route: the value flows forward but no gradient flows back through it. Used deliberately it implements fixed targets and alternating optimization. Used accidentally, say on a tensor reused downstream, it silently zeroes a term of the total derivative and the model trains on a censored gradient. If a loss stops responding to a parameter it used to track, check for a stray detach before doubting the architecture.
The Quick Version
- The partial freezes every other input; the total follows the parameter through all of them.
- Total equals the sum over dependency routes of frozen partial times variable rate.
- For with both factors driven by , the total 16 dwarfs the partial 3.
- The differential is the same identity for small steps.
- Detaching a tensor in code deletes a route from the total, silently and by design or by accident.