Calculus/Chain Rule

The chain rule is a method to compute the derivative of the functional composition of two or more functions.

If a function $$f$$ depends on a variable $$u$$, which in turn depends on another variable $$x$$ , that is $$f=y\bigl(u(x)\bigr)$$ , then the rate of change of $$f$$ with respect to $$x$$ can be computed as the rate of change of $$y$$ with respect to $$u$$ multiplied by the rate of change of $$u$$ with respect to $$x$$.

The method is called the "chain rule" because it can be applied sequentially to as many functions as are nested inside one another. For example, if $$f$$ is a function of $$g$$ which is in turn a function of $$h$$, which is in turn a function of $$x$$ , that is
 * $$f\bigl(g(h(x))\bigr)$$

the derivative of $$f$$ with respect to $$x$$ is given by
 * $$\frac{df}{dx}=\frac{df}{dg}\cdot\frac{dg}{dh}\cdot\frac{dh}{dx}$$ and so on.

A useful mnemonic is to think of the differentials as individual entities that can be canceled algebraically, such as
 * $$\frac{df}{dx}=\frac{df}{\cancel{dg}}\cdot\frac{\cancel{dg}}{\cancel{dh}}\cdot\frac{\cancel{dh}}{dx}$$

However, keep in mind that this trick comes about through a clever choice of notation rather than through actual algebraic cancellation.

The chain rule has broad applications in physics, chemistry, and engineering, as well as being used to study related rates in many disciplines. The chain rule can also be generalized to multiple variables in cases where the nested functions depend on more than one variable.

Example I
Suppose that a mountain climber ascends at a rate of $$0.5\frac{km}{h}$$. The temperature is lower at higher elevations; suppose the rate by which it decreases is $$6^\circ C$$ per kilometer. To calculate the decrease in air temperature per hour that the climber experiences, one multiplies $$\frac{6^\circ C}{km}$$ by $$0.5\frac{km}{h}$$, to obtain $$\frac{3^\circ C}{h}$$. This calculation is a typical chain rule application.

Example II
Consider the function $$f(x)=(x^2+1)^3$$. It follows from the chain rule that

Example III
In order to differentiate the trigonometric function
 * $$f(x)=\sin(x^2)$$

one can write:

Example IV: absolute value
The chain rule can be used to differentiate $$|x|$$, the absolute value function:

Example V: three nested functions
The method is called the "chain rule" because it can be applied sequentially to as many functions as are nested inside one another. For example, if $$f\bigl(g(h(x))\bigr)=e^{\sin(x^2)}$$, sequential application of the chain rule yields the derivative as follows (we make use of the fact that $$\frac{d}{dx}e^x=e^x$$ , which will be proved in a later section):

Chain Rule in Physics
Because one physical quantity often depends on another, which, in turn depends on others, the chain rule has broad applications in physics. This section presents examples of the chain rule in kinematics and simple harmonic motion. The chain rule is also useful in electromagnetic induction.

Physics Example I: relative kinematics of two vehicles


For example, one can consider the kinematics problem where one vehicle is heading west toward an intersection at 80mph while another is heading north away from the intersection at 60mph. One can ask whether the vehicles are getting closer or further apart and at what rate at the moment when the northbound vehicle is 3 miles north of the intersection and the westbound vehicle is 4 miles east of the intersection.

Big idea: use chain rule to compute rate of change of distance between two vehicles.


 * Plan
 * 1) Choose coordinate system
 * 2) Identify variables
 * 3) Draw picture
 * 4) Big idea: use chain rule to compute rate of change of distance between two vehicles
 * 5) Express $$c$$ in terms of $$x$$ and $$y$$ via Pythagorean theorem
 * 6) Express $$\frac{dc}{dt}$$ using chain rule in terms of $$\frac{dx}{dt}$$ and $$\frac{dy}{dt}$$
 * 7) Substitute in $$x,y,\frac{dx}{dt},\frac{dy}{dt}$$
 * 8) Simplify.

Choose coordinate system: Let the $$y$$-axis point north and the x-axis point east.

Identify variables: Define $$y(t)$$ to be the distance of the vehicle heading north from the origin and $$x(t)$$ to be the distance of the vehicle heading west from the origin.

Express $$c$$ in terms of $$x$$ and $$y$$ via Pythagorean theorem:
 * $$c=(x^2+y^2)^\frac{1}{2}$$

Express $$\frac{dc}{dt}$$ using chain rule in terms of $$\frac{dx}{dt}$$ and $$\frac{dy}{dt}$$ :

Substitute in $$x=4\ mi\ ,\ y=3\ mi\ ,\ \frac{dx}{dt}=-80\ \frac{mi}{h}\ ,\ \frac{dy}{dt}=60\ \frac{mi}{h}$$ and simplify


 * $$\frac{dc}{dt}$$
 * $$=\frac{4\ mi\cdot\left(-80\ \frac{mi}{h}\right)+3\ mi\cdot\left(60\ \frac{mi}{h}\right)}{\sqrt{(4\ mi)^2+(3\ mi)^2}}$$
 * $$=\frac{-320\ \frac{mi^2}{h}+180\ \frac{mi^2}{h}}{\sqrt{25\ mi}}$$
 * $$=\frac{-140\ \frac{mi^2}{h}}{5\ mi}$$
 * $$=-28\ \frac{mi}{h}$$
 * }
 * $$=\frac{-140\ \frac{mi^2}{h}}{5\ mi}$$
 * $$=-28\ \frac{mi}{h}$$
 * }
 * $$=-28\ \frac{mi}{h}$$
 * }
 * }

Consequently, the two vehicles are getting closer together at a rate of $$=28\ \frac{mi}{h}$$.

Physics Example II: harmonic oscillator


If the displacement of a simple harmonic oscillator from equilibrium is given by $$x$$, and it is released from its maximum displacement $$A$$ at time $$t=0$$ , then the position at later times is given by
 * $$x(t)=A\cos(\omega t)$$

where $$\omega=\frac{2\pi}{T}$$ is the angular frequency and $$T$$ is the period of oscillation. The velocity, $$v$$, being the first time derivative of the position can be computed with the chain rule:

The acceleration is then the second time derivative of position, or simply $$\frac{dv}{dt}$$.

From Newton's second law, $$\vec F=m\vec a$$, where $$\vec F$$ is the net force and $$m$$ is the object's mass.

Thus it can be seen that these results are consistent with the observation that the force on a simple harmonic oscillator is a negative constant times the displacement.

Chain Rule in Chemistry
The chain rule has many applications in Chemistry because many equations in Chemistry describe how one physical quantity depends on another, which in turn depends on another. For example, the ideal gas law describes the relationship between pressure, volume, temperature, and number of moles, all of which can also depend on time.

Chemistry Example I: Ideal Gas Law


Suppose a sample of $$n$$ moles of an ideal gas is held in an isothermal (constant temperature, $$T$$) chamber with initial volume $$V_0$$. The ideal gas is compressed by a piston so that its volume changes at a constant rate so that $$V(t)=V_0-kt$$, where $$t$$ is the time. The chain rule can be employed to find the time rate of change of the pressure. The ideal gas law can be solved for the pressure, $$P$$ to give:
 * $$P(t)=\frac{nRT}{V(t)}$$

where $$P(t)$$ and $$V(t)$$ have been written as explicit functions of time and the other symbols are constant. Differentiating both sides yields
 * $$\frac{dP(t)}{dt}=nRT\cdot\frac{d}{dt}\left(\frac{1}{V(t)}\right)$$

where the constant terms $$n,R,T$$ have been moved to the left of the derivative operator. Applying the chain rule gives
 * $$\frac{dP}{dt}=nRT\cdot\frac{d}{dV}\left(\frac{1}{V(t)}\right)\frac{dV}{dt}=nRT\left(-\frac{1}{V^2}\right)\frac{dV}{dt}$$

where the power rule has been used to differentiate $$\frac{1}{V}$$, Since $$V(t)=V_0-kt$$ , $$\frac{dV}{dt}=-k$$. Substituting in for $$V$$ and $$\frac{dV}{dt}$$ yields $$\frac{dP}{dt}$$.
 * $$\frac{dP}{dt}=-\frac{nRTk}{(V_0-kt)^2}$$

Chemistry Example II: Kinetic Theory of Gases


A second application of the chain rule in Chemistry is finding the rate of change of the average molecular speed, $$v$$, in an ideal gas as the absolute temperature $$T$$ , increases at a constant rate so that $$T=T_0+at$$ , where $$T_0$$ is the initial temperature and $$t$$ is the time. The kinetic theory of gases relates the root mean square of the molecular speed to the temperature, so that if $$v(t)$$ and $$T(t)$$ are functions of time,
 * $$v(t)=\sqrt{\frac{3R\cdot T(t)}{M}}$$

where $$R$$ is the ideal gas constant, and $$M$$ is the molecular weight.

Differentiating both sides with respect to time yields:
 * $$\frac{d}{dt}v(t)=\frac{d}{dt}\left(\sqrt{\frac{3R\cdot T(t)}{M}}\right)$$

Using the chain rule to express the right side in terms of the with respect to temperature, $$T$$, and time, $$t$$ , respectively gives
 * $$\frac{dv}{dt}=\frac{d}{dT}\left(\sqrt{\frac{3RT}{M}}\right)\cdot\frac{dT}{dt}$$

Evaluating the derivative with respect to temperature, $$T$$, yields
 * $$\frac{dv}{dt}=\frac{1}{2}\sqrt{\frac{M}{3RT}}\cdot\frac{d}{dT}\left(\frac{3RT}{M}\right)\cdot\frac{dT}{dt}$$

Evaluating the remaining derivative with respect to $$T$$, taking the reciprocal of the negative power, and substituting $$T=T_0+at$$ , produces
 * $$\frac{dv}{dt}=\frac{1}{2}\sqrt{\frac{M}{3R(T_0+at)}}\cdot\frac{3R}{M}\cdot\frac{d}{dt}\left(T_0+at\right)$$

Evaluating the derivative with respect to $$t$$ yields
 * $$\frac{dv}{dt}=\frac{1}{2}\sqrt{\frac{M}{3R(T_0+at)}}\cdot\frac{3R}{M}a$$

which simplifies to
 * $$\frac{dv}{dt}=\frac{a}{2}\sqrt{\frac{3R}{M(T_0+at)}}$$

Proof of the chain rule
Suppose $$y$$ is a function of $$u$$ which is a function of $$x$$ (it is assumed that $$y$$ is differentiable at $$u$$ and $$x$$, and $$u$$ is differentiable at $$x$$ . To prove the chain rule we use the definition of the derivative.
 * $$\frac{dy}{dx}=\lim_{\Delta x\to0}\frac{\Delta y}{\Delta x}$$

We now multiply $$\frac{\Delta y}{\Delta x}$$ by $$\frac{\Delta u}{\Delta u}$$ and perform some algebraic manipulation.
 * $$\lim_{\Delta x\to0}\frac{\Delta y}{\Delta x}=\lim_{\Delta x\to0}\frac{\Delta y}{\Delta u}\cdot\frac{\Delta u}{\Delta x}=\lim_{\Delta x\to0}\frac{\Delta y}{\Delta u}\cdot\lim_{\Delta x\to0}\frac{\Delta u}{\Delta x}=\lim_{\Delta x\to0}\frac{\Delta y}{\Delta u}\cdot\frac{du}{dx}$$

Note that as $$\Delta x$$ approaches $$0$$, $$\Delta u$$ also approaches $$0$$. So taking the limit as of a function as $$\Delta x$$ approaches $$0$$ is the same as taking its limit as $$\Delta u$$ approaches $$0$$. Thus
 * $$\lim_{\Delta x\to0}\frac{\Delta y}{\Delta u}=\lim_{\Delta u\to0}\frac{\Delta y}{\Delta u}=\frac{dy}{du}$$

So we have
 * $$\frac{dy}{dx}=\frac{dy}{du}\cdot\frac{du}{dx}$$

Exercises
Solutions