Differential calculus of several variables
With several variables, the derivative becomes a vector: the gradient, which points in the direction in which the function grows fastest and is perpendicular to the level curves.
01Partial derivatives: moving one variable at a time
With several variables, “the” derivative is not enough: you have to say with respect to which one. The partial derivative is computed by holding the others fixed, as if they were constants:
A partial derivative is a sensitivity: how much the output changes per unit change in one component, with the others held still. If P = V²/R, then ∂P/∂V = 2V/R and ∂P/∂R = −V²/R². Doubling the voltage quadruples the power; doubling the resistance cuts it in half. That, which we know by heart, is exactly what the two partials say.
The second derivatives include the mixed ones, ∂²f/∂x∂y. Schwarz’s theorem guarantees that, if they are continuous, the order does not matter: ∂²f/∂x∂y = ∂²f/∂y∂x.
02Tangent plane, differential and error propagation
Just as in one variable the tangent line approximated the curve, here the tangent plane approximates the surface:
V = 10 V ±0.1 V and R = 100 Ω ±1 Ω are measured, and P = V²/R = 1 W is computed.
dP = (2V/R)dV + (−V²/R²)dR = 0.2·(±0.1) + (−0.01)·(±1). In the worst case the errors add up in absolute value: |ΔP| ≤ 0.02 + 0.01 = 0.03 W, that is, 3%.
It is the same 3% given by the rule of thumb “relative error of P = twice that of V plus that of R”: 2·1% + 1% = 3%. That rule comes from the total differential.
03The gradient
The two partial derivatives together form a vector that concentrates all the information about how f changes:
1. The gradient points in the direction of maximum increase, and its magnitude is that
maximum slope.
2. It is perpendicular to the level curves. That is why the electric field, which is −∇V, crosses
the equipotentials at right angles.
3. At a local extremum, the gradient is zero: it is the several-variable version of
f′ = 0.
Tap the map to choose a point and rotate the direction arrow. The directional derivative is maximum when the direction coincides with the gradient.
04The chain rule
If the variables in turn depend on another one —for example, on time— the contributions add up:
This is what happens when a resistor changes value while the voltage also varies: the power changes for both reasons at once, and the chain rule adds them up, weighted by each sensitivity.
05Extrema: free and constrained
The candidates for an extremum are the critical points, where ∇f = 0. To classify them we use the Hessian, which is the matrix of second derivatives:
It is the same symmetric matrix as in quadratic forms, and the test is the one on the signs of its eigenvalues, written with determinants.
When the maximum is sought subject to a constraint —optimizing with a condition g(x, y) = 0—, at the optimum the gradients are parallel: ∇f = λ∇g. You solve the system formed by that equality and the constraint.
It is the method used to prove, for example, maximum power transfer with a dissipation constraint, or the minimum-cost design that meets a specification.
06What it is good for in electronics
- Tolerances and sensitivity. ∂(output)/∂(component) tells you which resistor is worth buying at 1% and which can be 5%. It is sensitivity analysis, and it is computed with partial derivatives.
- Field and potential. E = −∇V: the electric field is minus the gradient of the potential. All of the electrostatics of Physics II rests on this.
- Design optimization. Maximum gain with limited consumption, minimum noise for a given bandwidth: these are constrained extrema.
- Model fitting. Least-squares methods and the training of neural networks look for the minimum of a function of many variables by following the gradient downhill: this is gradient descent.
- Maximum power point. In a solar panel, the power depends on voltage and current; the MPPT tracker climbs the gradient up to the maximum.
07In the lab
For a resistive divider, compute ∂Vout/∂R₁ and ∂Vout/∂R₂. Then replace each resistor with another that differs by 5% and verify that the measured change matches the one predicted by the differential.
Measure the voltage and current of a load with their uncertainties and compute the power with its error, using the total differential. Compare with the error reported by a wattmeter.
With the lab in section 3, choose a point and find by hand the direction of maximum increase; verify that it coincides with the gradient and that the directional derivative is zero in the perpendicular direction, which is that of the level curve.
08Common mistakes
- Differentiating with respect to one variable without holding the others fixed.
- Believing that the existence of the partial derivatives implies continuity. In several variables it does not.
- Forgetting to normalize the direction when computing the directional derivative: û has to be a unit vector.
- Confusing a zero gradient with an extremum: it can also be a saddle point.
- Using the Hessian test when D = 0, where it decides nothing.
- Adding errors with their signs when propagating uncertainties: in the worst case the absolute values are added.
09Self-assessment
For f(x,y) = x²y + 3y, find the two partial derivatives.
fx = 2xy and fy = x² + 3.
What direction does the gradient have relative to the level curves?
It is perpendicular to them, and points toward increasing values.
Classify the critical point of f(x,y) = x² − y² at the origin.
fxx = 2, fyy = −2, fxy = 0, so D = −4 < 0: it is a saddle point.
I = 2 A ±2% and R = 10 Ω ±1% are measured. What is the error of P = I²R?
The relative error is 2·2% + 1% = 5%, on P = 40 W: ±2 W.
What condition does a constrained optimum satisfy, according to Lagrange?
That the gradients are parallel: ∇f = λ∇g, together with the constraint itself, g = 0.
Why is E = −∇V?
Because the field points toward where the potential decreases fastest, and its magnitude is that maximum variation per unit of length.
10Further reading
- James Stewart. Multivariable Calculus. 7th ed. (Spanish edition, “Cálculo de varias variables. Trascendentes tempranas”), Cengage Learning, 2012. Chapter 14 covers partial derivatives, gradient, tangent plane, extrema and Lagrange with many applications.
- Jerrold E. Marsden and Anthony J. Tromba. Vector Calculus. 5th ed. (Spanish edition, “Cálculo vectorial”), W. H. Freeman, 2003. Treats the gradient with the care it deserves and connects it to conservative fields.
- John R. Taylor. An Introduction to Error Analysis. 2nd ed. (Spanish edition, “Introducción al análisis de errores”), University Science Books, 1997. Propagation of uncertainties, which is the most immediate application of the total differential in the lab.