Chain rule

The chain rule in calculus is a fundamental formula used when performing differentiation of compound functions in one or multiple variables. For real-valued functions of several variables, the chain rule extends to an equation involving partial derivatives.

Chain rule in one independent variable

Suppose \(z\) is a differentiable function in \(x\) and \(y\), and both \(x\) and \(y\) are differentiable functions in \(t\). Then \(z\) will also be a differentiable function in \(t\), and

\[ \frac{dz}{dt} = \frac{\partial z}{\partial x} \frac{dx}{dt} + \frac{\partial z}{\partial y} \frac{dy}{dt}. \]

This is the multivariate version of the familiar chain rule.

Caution

Here, the differentiability assumptions are important. When this assumption is violated, the partial derivatives and derivatives can interact in very complicated ways.

Distance to a point

Suppose the trajectory of a moving particle is given by the parametric equations \[ \left\{ \begin{aligned} x &= \cos{\left(t \right)} \\ y &= \sin{\left(t \right)} \\ \end{aligned} \right. \] Let \(z\) be the distance between this particle and the point \((3,4)\). Is \(z\) a differentiable function in \(t\)? If yes, compute the derivative \(\frac{dz}{dt}\).

By the distance formula,

\[ z = \sqrt{ (x - 3)^2 + (y - 4)^2 } \]

which is differentiable everywhere except at the origin \((0,0)\). But the image of \(x(t)\) and \(y(t)\) never passes through the origin, so \(z\) is indeed a differentiable function in \(t\).

We can compute that \[ \begin{aligned} \frac{\partial z}{\partial x} &= \frac{x - 3}{\sqrt{\left(x - 3\right)^{2} + \left(y - 4\right)^{2}}} & \frac{d x}{d t} &= - \sin{\left(t \right)} \\ \frac{\partial z}{\partial y} &= \frac{y - 4}{\sqrt{\left(x - 3\right)^{2} + \left(y - 4\right)^{2}}} & \frac{d y}{d t} &= \cos{\left(t \right)} \end{aligned} \]

Via chain rule, we can compute that

\[ \begin{aligned} \frac{dz}{dt} &= \frac{\partial z}{\partial x} \frac{dx}{dt} + \frac{\partial z}{\partial y} \frac{dy}{dt} \\ &= \left( \frac{x - 3}{\sqrt{\left(x - 3\right)^{2} + \left(y - 4\right)^{2}}} \right) \left( - \sin{\left(t \right)} \right) + \left( \frac{y - 4}{\sqrt{\left(x - 3\right)^{2} + \left(y - 4\right)^{2}}} \right) \left( \cos{\left(t \right)} \right) \\ &= - \frac{\left(x - 3\right) \sin{\left(t \right)}}{\sqrt{\left(x - 3\right)^{2} + \left(y - 4\right)^{2}}} + \frac{\left(y - 4\right) \cos{\left(t \right)}}{\sqrt{\left(x - 3\right)^{2} + \left(y - 4\right)^{2}}} \end{aligned} \]

Alternatively, we can perform a simple substitution. By the distance formula,

\[ z = \sqrt{ (x - 3)^2 + (y - 4)^2 } \]

Substituting in the formulae for \(x(t)\) and \(y(t)\) into this equation, we get

\[ z = \sqrt{\left(\sin{\left(t \right)} - 4\right)^{2} + \left(\cos{\left(t \right)} - 3\right)^{2}} \]

which is indeed differentiable for all \(t\). We can directly compute that.

\[ \frac{dz}{dt} = \frac{\left(\sin{\left(t \right)} - 4\right) \cos{\left(t \right)} - \left(\cos{\left(t \right)} - 3\right) \sin{\left(t \right)}}{\sqrt{\left(\sin{\left(t \right)} - 4\right)^{2} + \left(\cos{\left(t \right)} - 3\right)^{2}}} \]

While it may look like this is different from the answer we got from application of chain rule. These answer are indeed equivalent.

Distance between two moving points

Suppose the trajectories of two moving particles are given by the parametric equations \[ \begin{aligned} & \left\{ \begin{aligned} x_1 &= \cos{\left(3 t \right)} \\ y_1 &= \sin{\left(3 t \right)} \\ \end{aligned} \right. &&\text{and} & \left\{ \begin{aligned} x_2 &= 2 \cos{\left(t \right)} \\ y_2 &= 2 \sin{\left(t \right)} \\ \end{aligned} \right. \end{aligned} \]

Express the instantaneous rate of change of the distance between the two moving particles as a function of \(t\).

First we compute the partial derivatives

\[ \begin{aligned} \frac{{dz}}{{d x_{1}}} &= \frac{x_{1} - x_{2}}{\sqrt{\left(x_{1} - x_{2}\right)^{2} + \left(y_{1} - y_{2}\right)^{2}}} \\ \frac{{dz}}{{d y_{1}}} &= \frac{y_{1} - y_{2}}{\sqrt{\left(x_{1} - x_{2}\right)^{2} + \left(y_{1} - y_{2}\right)^{2}}} \\ \frac{{dz}}{{d x_{2}}} &= \frac{- x_{1} + x_{2}}{\sqrt{\left(x_{1} - x_{2}\right)^{2} + \left(y_{1} - y_{2}\right)^{2}}} \\ \frac{{dz}}{{d y_{2}}} &= \frac{- y_{1} + y_{2}}{\sqrt{\left(x_{1} - x_{2}\right)^{2} + \left(y_{1} - y_{2}\right)^{2}}} \end{aligned} \]

Note that each of these partial derivatives are defined and continuous away from configurations where \(x_1 = x_2\) and \(y_1 = y_2\). In other words, as long as the two particles do not run into each other, these partial derivatives are defined and continuous. Under that assumption, \(z\) is a differentiable function in \(x_1,y_1,x_2,y_2\). This assumption is indeed valid: Notice that the two particles circle around the origin from different distance and will therefore never collide. We can also compute that

\[ \begin{aligned} \frac{{d x_{1}}}{{dt}} &= - 3 \sin{\left(3 t \right)} \\ \frac{{d y_{1}}}{{dt}} &= 3 \cos{\left(3 t \right)} \\ \frac{{d x_{2}}}{{dt}} &= - 2 \sin{\left(t \right)} \\ \frac{{d y_{2}}}{{dt}} &= 2 \cos{\left(t \right)} \end{aligned} \]

which are all defined for all \(t\) values. By chain rule, \(z\) is a differentiable function of \(t\). Moreover,

\[ \begin{aligned} &\frac{dz}{dt} \\ &= \left( \frac{x_{1} - x_{2}}{\sqrt{\left(x_{1} - x_{2}\right)^{2} + \left(y_{1} - y_{2}\right)^{2}}} \right) \cdot \left( - 3 \sin{\left(3 t \right)} \right) \\ &+ \left( \frac{y_{1} - y_{2}}{\sqrt{\left(x_{1} - x_{2}\right)^{2} + \left(y_{1} - y_{2}\right)^{2}}} \right) \cdot \left( 3 \cos{\left(3 t \right)} \right) \\ &+ \left( \frac{- x_{1} + x_{2}}{\sqrt{\left(x_{1} - x_{2}\right)^{2} + \left(y_{1} - y_{2}\right)^{2}}} \right) \cdot \left( - 2 \sin{\left(t \right)} \right) \\ &+ \left( \frac{- y_{1} + y_{2}}{\sqrt{\left(x_{1} - x_{2}\right)^{2} + \left(y_{1} - y_{2}\right)^{2}}} \right) \cdot \left( 2 \cos{\left(t \right)} \right) \\ &= \frac{3 \left(- x_{1} + x_{2}\right) \sin{\left(3 t \right)} + 2 \left(x_{1} - x_{2}\right) \sin{\left(t \right)} + 2 \left(- y_{1} + y_{2}\right) \cos{\left(t \right)} + 3 \left(y_{1} - y_{2}\right) \cos{\left(3 t \right)}}{\sqrt{\left(x_{1} - x_{2}\right)^{2} + \left(y_{1} - y_{2}\right)^{2}}} \end{aligned} \]

Resistors in a parallel circuit

2024-03-06T17:21:53.594385 image/svg+xml Matplotlib v3.8.3, https://matplotlib.org/

The total resistance \(R\) (in ohms) of two resistors connected in parallel is given by

\[ \frac{1}{R} = \frac{1}{R_1} + \frac{1}{R_2} \tag{1}\]

Suppose the resistance of both resistors are changing and their values are given by the functions

\[ \begin{aligned} R_1 &= 2 t + 10 & R_2 &= t + 15 \end{aligned} \]

where \(t \ge 0\) represent time (measured in seconds). Is \(R\) a differentiable function of \(t\)? If yes, compute the derivative \(\frac{dR}{dt}\).

From (Equation 1), we get

\[ R = \frac{1}{\frac{1}{R_{2}} + \frac{1}{R_{1}}} \]

and we can compute its partial derivatives

\[ \begin{aligned} \frac{\partial R}{\partial R_1} &= \frac{1}{R_{1}^{2} \left(\frac{1}{R_{2}} + \frac{1}{R_{1}}\right)^{2}} & \frac{\partial R}{\partial R_2} &= \frac{1}{R_{2}^{2} \left(\frac{1}{R_{2}} + \frac{1}{R_{1}}\right)^{2}} \end{aligned} \]

Since both partial derivatives are defined and continuous for \(R_1,R_2 > 0\), \(R\) (as defined in (Equation 1)) is indeed differentiable. Moreover, \(R_1,R_2\) are both differentiable in \(t\), so \(R\) is also a differentiable function in \(t\). Indeed, by chain rule,

\[ \begin{aligned} \frac{dR}{dt} &= \frac{\partial R}{\partial R_1} \frac{dR_1}{dt} + \frac{\partial R}{\partial R_2} \frac{dR_2}{dt} \\ &= \left( \frac{1}{R_{1}^{2} \left(\frac{1}{R_{2}} + \frac{1}{R_{1}}\right)^{2}} \right) \left( 2 \right) + \left( \frac{1}{R_{2}^{2} \left(\frac{1}{R_{2}} + \frac{1}{R_{1}}\right)^{2}} \right) \left( 1 \right) \\ &= \frac{R_{1}^{2} + 2 R_{2}^{2}}{\left(R_{1} + R_{2}\right)^{2}} \end{aligned} \]