The chain and product rules


Two rules from your calculus class will turn out to be very important in our applications of calculus to physics. In part, this is because in physics we have to correct our equations so the units come our right and this inserts constant into our functions. We can handle this with the chain rule. We also often have to deal with multiple physical effects happening at once and this can require that we understand how to apply the product rule.

The chain rule

The chain rule is the rule you use when you have a function of a function — something like when $y = f(g(x))$. The rule is this:

$$\frac{d}{dx}f(g(x)) = \frac{dg}{dx} \frac{df}{dg}.$$

This sort of makes sense. In this case, $g$ is a function of $x$ so when $x$ changes, $g$ changes. But $f$ is a function of $g$ so when $g$ changes, so does $f$. So although it makes sense that both derivatives of $f$ and $g$ are involved, it's not really obvious that it should be the product. Let's work it through.

A useful chain rule example

Let's do an example to see how this works. 

In some case, the physics leads to an effect which falls of exponentially. If $x$ represents a distance, we might want to write a function $f(x) = e^{-x}$ (WRONG). I've written "wrong" since we can only take the exponential of a number, not of anything with units. (See Powers and exponentials.)

The way to fix this is to multiple $x$ by some parameter that set the dimensional scale of the problem — something with dimensionality of 1/L: call it $\lambda$. Our exponential function would then be

$$f(x) = e^{-\lambda x}$$

(This will occur in a number of interesting examples, such as the screening of a charge in an ionic fluid.)

What if we want to take the derivative of $f$ with respect to $x$? The presence of $\lambda$ means that we can't use the derivative in our list of simple derivatives. But we can use the chain rule. Let's take

$$g(x) = -\lambda x \quad \quad f(g) = e^g.$$

Then we have that $f(x) = e^{-\lambda x}$ as required. Now let's apply the chain rule to get the derivative:

$$\frac{df(g(x))}{dx} = \frac{df}{dg} \frac{dg}{dx}$$

Since it's a simple exponential of a pure number

$$\frac{df}{dg} = f(g) = e^g.$$

The derivative of $g$ with respect to $x$ is easy:

$$\frac{dg}{dx} = \frac{d}{dx}(-\lambda x) = -\lambda.$$

Putting the two results together and putting in the explicit function $g$ gives the useful result

$$\frac{d(e^{-\lambda x})}{dx} = -\lambda e^{-\lambda x}.$$

The product rule

Another useful rule is when we have the product of two functions: something like $f(x)g(x).$ Although this seems conceptually easier than a function of a function, it's a bit messier.

The result is

$$\frac{d}{dx}(f(x)g(x)) = \frac{df(x)}{dx}g(x) + f(x)\frac{dg(x)}{dx} $$

A useful product rule example

The chain and product rules are not only useful in calculating derivatives. They're also useful in setting up equations from the physics.

When we consider an oscillation, like the ringing of a bell, we know that it dies out. Our simple model of an oscillation (Mass on a spring) says that the system should oscillate as a function of time like

$$x(t) = A_0 \cos{(\omega t)}$$ 

where $A_0$ and $\omega$ are constants. But this would have it oscillate forever and we know that it dies out. So let's suggest that while it still oscillates, the amplitude dies. This would suggest that we replace $A_0$ by a function of time, $A(t)$. The behavior of the system is controlled by Newton's 2nd law, which says that the acceleration of a system, $d^2x/dt^2$, is controlled by the forces on the system. So to build a mathematical model of the damped oscillation (which we won't do here) we have to be able to calculate the second derivative of $x(t)$

$$\frac{d^2x}{dt^2} = \frac{d^2}{dt^2} \bigg(A(t) \cos{(\omega t)}\bigg).$$

Let's only calculate the first derivative now to show the use of the product rule:

$$\frac{d}{dt} \bigg(A(t) \cos{(\omega t)}\bigg) = \frac{dA}{dt}\cos{(\omega t)} + A(t) \frac{d}{dt}\cos{(\omega t)} $$

Using the chain rule on the derivative of cosine to get

$$\frac{d}{dt}\cos{(\omega t)} = -\omega \sin{(\omega t)}$$

our result is

$$\frac{d}{dt} \bigg(A(t) \cos{(\omega t)}\bigg) = \frac{dA}{dt}\cos{(\omega t)} +  \omega A(t)\sin{(\omega t)} $$

Once we do this again, we can get an expression to put into Newton's second law. This gives a differential equation that can be solved for $A(t)$.

Joe Redish 5/27/19


Article 678
Last Modified: May 27, 2019