Sign in

Libre University uses your GitHub account. Signing in is only needed to sit a final test, so the score is kept on your profile.

The chain rule

A quantity that depends on several variables, each of which is itself changing, changes at a rate that no single partial derivative supplies.

The pressure of a gas depends on its temperature and its volume, and when a gas is heated in a cylinder with a moving piston both change at once. The temperature felt by a weather balloon depends on where the balloon is, and where it is depends on time. The previous lesson ended by noticing that most functions met in practice are compositions of this kind and that its total differential, dz=fxdx+fydy, looks as if it wants to be divided by dt. This lesson proves that it can be, extends the result to inner functions of several variables, and uses it twice: to rewrite partial derivatives in polar coordinates, and to reduce the implicit differentiation of Calculus I to a single formula. It assumes partial derivatives and the definition of differentiability as the existence of a tangent plane whose error shrinks faster than the distance.

The rate along a path

Suppose z=f(x,y), and the point (x,y) moves along a path, so that x=x(t) and y=y(t) are differentiable functions of time. Then z(t)=f(x(t),y(t)) is an ordinary function of one variable, and the question is its derivative. Take f to be differentiable at the point (a,b)=(x(t0),y(t0)), and let time move from t0 to t0+Δt. The inputs move by Δx=x(t0+Δt)-x(t0) and by a similar Δy, and the definition of differentiability says exactly how much z moves:

Δz=fxΔx+fyΔy+E

with both partials evaluated at (a,b) and with an error E satisfying E/d→0, where d=Δx2+Δy2 is the distance the point has moved. Dividing through by Δt gives

ΔzΔt=fxΔxΔt+fyΔyΔt+EΔt

As Δt→0 the first two quotients tend to x′(t0) and y′(t0). The last term is the one to control, and the trick is to route it through the distance: E/Δt=(E/d)(d/Δt). The factor d/|Δt| equals (Δx/Δt)2+(Δy/Δt)2, which tends to the finite speed x′(t0)2+y′(t0)2. The factor E/d tends to 0, because x and y are continuous and so d→0. (When d happens to be 0 the point has not moved and E is 0 as well, so nothing is lost.) A bounded factor times one that vanishes vanishes, and the result is the chain rule along a path:

dzdt=∂z∂xdxdt+∂z∂ydydt

It is the total differential divided by dt, and the derivation is what licenses the division. Each term has a plain meaning: the rate at which z would change if only x were moving, plus the rate if only y were moving. Near a point of differentiability those two contributions simply add, which is the additivity the tangent plane guarantees. With three inputs, as for the weather balloon's T(x,y,z), the same argument gives three terms, one per input.

Differentiability is not a technicality here. Take f(x,y)=x2y/(x2+y2) with f(0,0)=0. It is continuous at the origin, since |f|≤|y|, and it vanishes on both axes, so fx(0,0)=fy(0,0)=0. Along the path x=t, y=t the function equals t/2, so dz/dt=12 at t=0, while the formula would give 0×1+0×1=0. The two partials exist but no tangent plane does, and the chain rule needs the plane.

A gas that heats and expands

The ideal gas law gives the pressure of n moles of gas as P=nRT/V, with R=8.314 J/(mol K). When a piston lets a warming gas expand, temperature pushes the pressure up and volume pulls it down, and the chain rule says which wins.

Example. One mole of gas is at 300 K in a volume of 0.025 m³. It is being heated at 0.5 K per second while the piston withdraws so that the volume grows by 0.0002 m³ per second. Is the pressure rising or falling, and how fast?

The partials of P=RT/V are ∂P/∂T=R/V and ∂P/∂V=-RT/V2. At this state they are 8.314/0.025=332.56 and -8.314×300/0.0252=-3990720, in pascals per kelvin and pascals per cubic metre. The chain rule gives

dPdt=332.56×0.5-3990720×0.0002=166.28-798.14=-631.86

so the pressure, about 99.8 kPa at this moment, is falling at about 632 Pa per second. Heating alone would raise it by 166 Pa each second, but the expansion lowers it by nearly five times as much. As a check, write the state as explicit functions of time, T=300+0.5t and V=0.025+0.0002t, so that P(t)=8.314(300+0.5t)/(0.025+0.0002t). The quotient rule at t=0 gives 8.314(0.5×0.025-300×0.0002)/0.0252=-631.86, the same number by a longer road.

The chain rule is the better road for two reasons. It never needed the formulas for T(t) and V(t), only their rates at the instant, which is what an experiment usually measures. And it splits the answer into contributions that can be read separately, which the single quotient rule computation hides.

Now you. A beetle crosses a metal plate whose temperature is T(x,y)=80-x2-2y2 degrees Celsius, with x and y in metres. At time t seconds it is at x=1+2t, y=3-t. How fast is the temperature it feels changing at t=0?

Answer

At t=0 the beetle is at (1,3), where Tx=-2x=-2 and Ty=-4y=-12. Its velocity is dx/dt=2, dy/dt=-1. The chain rule gives dT/dt=(-2)(2)+(-12)(-1)=-4+12=8, so the temperature it feels is rising at 8 degrees per second: moving in x cools it, but moving towards smaller y warms it more.

Two independent variables

Often the intermediate variables depend on more than one thing. Suppose z=f(x,y) with x=g(s,t) and y=h(s,t), so that z is ultimately a function of s and t. The partial derivative ∂z/∂s holds t fixed, and with t fixed the point (x,y) simply moves along a path parametrised by s. The rule of the first section applies word for word, with s in the role of time and ordinary derivatives replaced by partials:

∂z∂s=∂z∂x∂x∂s+∂z∂y∂y∂s

and the same with t in place of s gives ∂z/∂t. Nothing new had to be proved.

The bookkeeping is easiest to hold as a tree of dependencies. Put z at the top. It depends on x and on y, so two branches lead down from it. Each of x and y depends on s and on t, so two branches lead down from each of them, four in all. To find ∂z/∂s, follow every route from z down to s: there are two, one through x and one through y. Along each route multiply the derivatives on its branches, and add the routes. The same recipe handles any number of layers and variables. With w depending on three intermediate variables that each depend on four independent ones, every partial of w has three terms, one per route.

Take z=x2y with x=s2+t and y=st, at (s,t)=(1,2), where x=3 and y=2. The top level gives zx=2xy=12 and zy=x2=9. The lower level gives xs=2s=2, xt=1, ys=t=2 and yt=s=1. Following the routes, ∂z/∂s=12×2+9×2=42 and ∂z/∂t=12×1+9×1=21. Substituting first gives z=(s2+t)2st, and differentiating that directly at (1,2) produces 42 and 21 again.

One warning about notation. The symbols ∂z/∂x and ∂x/∂s look like fractions that should cancel to ∂z/∂s, and they do not, because each carries a different variable held fixed: the first holds y fixed, the second holds t fixed. The product along one route is only part of the answer, and the other route supplies the rest. In one variable the tree has a single route, which is why the chain rule of Calculus I has a single product and fractions seem to cancel.

Polar coordinates

The most common change of variables in the plane is to polar coordinates, x=rcosθ and y=rsinθ. A function given as f(x,y) becomes a function of r and θ, and its partials in the new variables follow from the tree with s and t renamed. The inner partials are ∂x/∂r=cosθ, ∂y/∂r=sinθ, ∂x/∂θ=-rsinθ and ∂y/∂θ=rcosθ, so

fr=fxcosθ+fysinθ,fθ=-fxrsinθ+fyrcosθ

The first is the rate of change of f as the point moves straight out from the origin at unit speed. The second is the rate per radian as the point swings round a circle of radius r; since a radian of turn covers a distance r, the rate per unit of distance along the circle is fθ/r. A quick sanity check is f=x2+y2, which is r itself. Its partials are x/r=cosθ and y/r=sinθ, and the formulas give fr=cos2θ+sin2θ=1 and fθ=-rcosθsinθ+rsinθcosθ=0, exactly what the derivatives of r with respect to r and θ should be.

Example. For f(x,y)=x2y, find fr and fθ at the point (3,4), and check them by rewriting f in polar form.

The point has r=5, cosθ=0.6 and sinθ=0.8. The Cartesian partials are fx=2xy=24 and fy=x2=9. Since rsinθ=y=4 and rcosθ=x=3, the formulas give fr=24×0.6+9×0.8=14.4+7.2=21.6 and fθ=-24×4+9×3=-96+27=-69. For the check, substitute to get f=r3cos2θsinθ. Then fr=3r2cos2θsinθ=3×25×0.36×0.8=21.6, and the product rule gives fθ=r3(cos3θ-2cosθsin2θ)=125(0.216-0.768)=-69. Both agree.

The two descriptions measure the same steepness in different frames. The sum fx2+fy2=576+81=657 equals fr2+(fθ/r)2=466.56+190.44=657, because the radial and circular directions are perpendicular unit directions just as the x and y directions are, a fact the next lesson explains.

Now you. For f(x,y)=x2-y2, find fr and fθ at the point (4,3), and check them against the polar form f=r2cos2θ.

Answer

Here r=5, cosθ=0.8, sinθ=0.6, fx=2x=8 and fy=-2y=-6. So fr=8×0.8-6×0.6=2.8 and fθ=-8×3+(-6)×4=-48. From the polar form, cos2θ=0.64-0.36=0.28 and sin2θ=2×0.8×0.6=0.96, so fr=2rcos2θ=2.8 and fθ=-2r2sin2θ=-48.

Implicit differentiation in one line

Calculus I found the slope of a curve such as x2+y2=25 by differentiating both sides with y treated as an unknown function of x, then solving for dy/dx. The chain rule explains why that works and compresses it into a formula. Write the curve as F(x,y)=0, and suppose that near some point on it the curve is the graph of a differentiable function y=y(x). Then F(x,y(x))=0 for every x nearby. The left side is a composition of exactly the kind this lesson handles: a path through the plane parametrised by x itself, with dx/dx=1. Its derivative is zero, because it is constantly zero, and the chain rule gives

Fx⋅1+Fydydx=0,sodydx=-FxFy

wherever Fy≠0. For the circle, F=x2+y2-25 gives dy/dx=-2x/2y=-x/y, which at (3,4) is -34, perpendicular to the radius of slope 43 as a tangent to a circle must be.

The argument assumed the curve is a graph near the point. The implicit function theorem, whose proof belongs to analysis, guarantees it: if F has continuous partials and Fy≠0 at a point of the curve, then near that point the curve is the graph of a differentiable function of x. Where Fy=0 but Fx≠0, the roles swap, dx/dy=-Fy/Fx=0, and the tangent is vertical. Where both vanish, the formula says nothing, and the curve may do something other than pass smoothly through.

The same reasoning works one dimension up. A surface F(x,y,z)=0 defines z implicitly as a function of x and y, and holding y fixed turns it into the case just done, so ∂z/∂x=-Fx/Fz and ∂z/∂y=-Fy/Fz wherever Fz≠0.

The folium of Descartes

The curve x3+y3=6xy is the folium, or leaf, of Descartes. He proposed it in 1638 as a challenge to Pierre de Fermat, who had announced a method for finding tangents, and Fermat found them without difficulty. It has a loop in the first quadrant with its tip at (3,3), since 27+27=54=6×9, and two tails running off towards the line x+y=-2.

Example. Verify that (43,83) lies on the folium x3+y3=6xy, and find the slope of the curve there.

On the curve: x3+y3=6427+51227=57627=643, and 6xy=6×329=643. With F=x3+y3-6xy, the partials are Fx=3x2-6y and Fy=3y2-6x, so

dydx=-3x2-6y3y2-6x=2y-x2y2-2x

At the point, 2y-x2=163-169=329 and y2-2x=649-83=409, so the slope is 3240=0.8. The Calculus I route, differentiating x3+y3=6xy term by term to get 3x2+3y2y′=6y+6xy′ and solving for y′, lands on the same expression after two more lines of algebra. The formula skips those lines.

At the tip (3,3) the same expression gives (6-9)/(9-6)=-1, as the symmetry of the curve under swapping x and y demands. The loop has a vertical tangent where Fy=0, that is where y2=2x, and substituting into the curve locates it at (25/3,24/3), about (3.17,2.52). At the origin both Fx and Fy vanish, the formula reads 0/0, and the theorem's hypothesis fails for a visible reason: the curve crosses itself there, passing through twice, once tangent to each axis, so it has two tangents and is not the graph of any single function.

Now you. Check that (2,1) lies on the curve x2+xy+y2=7, find the slope there, and write the tangent line.

Answer

The point gives 4+2+1=7. With F=x2+xy+y2-7, Fx=2x+y=5 and Fy=x+2y=4, so dy/dx=-54=-1.25. The tangent line is y-1=-1.25(x-2), that is y=3.5-1.25x.

Slopes in other directions

The chain rule came straight out of the tangent plane: divide the linear approximation by a small change in the underlying variable and let the error vanish. It gives the rate of change along any path, extends to any tree of dependencies by adding one product per route, converts partial derivatives between coordinate systems, and differentiates curves and surfaces defined implicitly.

Look again at what the ingredients measure. On a hill whose height is z=f(x,y), fx is the slope for a walker heading due east and fy for one heading due north. Polar coordinates added fr, the slope for a walker heading straight away from the origin, but that direction too was chosen by a coordinate system. A walker setting off north east, or on any bearing at all, wants the slope in that direction, and no partial derivative supplies it.

The chain rule already holds the raw material. Walking in a straight line at unit speed is a path, and the rate of change along it depends only on fx, fy and the direction of travel. Turning that into the slope in every direction at once, finding which direction is steepest, and seeing why the pair fx, fy behaves like a vector are the work of the next lesson, on the gradient.