3.4. Derivatives of Multivariable Functions#

3.4.1. Learning goals:#

After working through these notes, you will be able to:

  1. Define what a multivariable function is

  2. Identify at least one multivariable function

  3. Determine partial derivatives of multivariable functions

  4. Write out the total differential of a multivariable function

  5. Determine total derivatives of multivariable functions

3.4.2. Coding concepts:#

No coding concepts are used in this notebook.

3.4.3. Multivariable Functions#

Multivariable functions relate a dependent variable (e.g. \(f(x,y)\)) to at least two independent variables. These types of functions are more common than you might think. The elevation of the surface of the earth, for example, is a function of two variables, the latitude and longitude. A common example in chemistry is the ideal gas law:

(3.48)#\[\begin{equation} PV = nRT \end{equation}\]

This can be rewritten as

(3.49)#\[\begin{equation} P(\rho,T) = \rho RT, \end{equation}\]

where \(\rho=n/V\) is the concentration or molar density of the gas. This form of the equation makes it clear that the pressure, \(P\), depends on the concentration and temperature of the gas.

3.4.4. Derivatives of Multivariable Functions#

Taking derivatives of multivariable functions is not as straightforward as derivatives in 1D. This is simply because we can differentiate with respect to one or more of the independent variables. Partial derivatives are the derivatives of a multivariable function along one independent variable while holding the others constant and Total derivatives are derivatives of the function while allowing the other variables to vary.

3.4.4.1. Partial Derivatives#

Partial derivatives are the derivatives of a multivariable function along one independent variable while holding the others constant. Let’s consider an example function of two variables

(3.50)#\[\begin{equation} f(x,y) = x^2 + 2xy + 3 \end{equation}\]

If we consider taking the derivative of this function we must ask the question “derivative with respect to which variable?” We can do either and when we do so and hold the other constant we call these partial derivatives. Partial derivatives are distinguished from total derivatives by their squigly-backed ds.

Let’s take the partial derivative of \(f(x,y)\) w.r.t \(x\):

(3.51)#\[\begin{align} \frac{\partial f}{\partial x} = 2x + 2y \end{align}\]

We see that the same rules apply when we do partial derivatives and normal derivatives in 1D. When we take the partial derivative with respect to \(x\) we treat \(y\) as a constant. Similarly for the partial derivative with respect to \(y\):

(3.52)#\[\begin{align} \frac{\partial f}{\partial y} = 2x \end{align}\]

Partial derivatives of multivariable functions are about as easy as derivatives of 1D functions. We just need to remember the rules of differentiation in 1D and to treat all other variables as constants.

3.4.4.2. Total Derivatives#

If we consider the derivative of a function to be the slope of that function at a given point, the slope of a 2D function should itself be 2D. If you are at the top of the mountain, for example, the slope may be different in front of you than to your left. The quantity that represents the total change of the function is called the total differential. For a function, \(f(x,y)\), of two variables the total differential is given by

(3.53)#\[\begin{equation} df = \left(\frac{\partial f}{\partial x} \right)dx + \left( \frac{\partial f}{\partial y}\right)dy \end{equation}\]

This equation states that the change in \(f\), \(df\), will be the slope in \(x\), \(\frac{\partial f}{\partial x}\), times the change in \(x\), \(dx\), plus the slope in \(y\), \(\frac{\partial f}{\partial y}\), times the change in \(y\), \(dy\). That is, if I am standing at a particular latitute and longitude and take a step (\((dx,dy)\)), then the change in elevation that I went through is equal to the slope along the latitude times my change in latitude plut the slope along the longitude times my change in longitude.

One can also determine total derivatives in \(x\) and \(y\) from the above equation (or using the chain rule). The total derivative of \(f\) with respect to \(x\) can be determined by effectively dividing both sides of the above equation by \(dx\) to yield:

(3.54)#\[\begin{equation} \frac{df}{dx} = \left(\frac{\partial f}{\partial x} \right) + \left( \frac{\partial f}{\partial y}\right)\frac{dy}{dx} \end{equation}\]

An analagous equation can be determined for the total derivative with respect to \(y\). We see that the total derivative is equivalent to the partial derivative if \(x\) and \(y\) are independent (i.e. \(\frac{dy}{dx}=0\)).

3.4.4.3. Total and Partial Derivatives of the Ideal Gas Law#

Let’s use the ideal gas law to determine some total and partial derivatives. We will use the form

(3.55)#\[\begin{equation} P(\rho,T) = \rho RT, \end{equation}\]

The partial derivatives of \(P\) with respect to \(\rho\) and \(T\) are:

(3.56)#\[\begin{align} \frac{\partial P}{\partial \rho} &= RT \\ \frac{\partial P}{\partial T} &= \rho R \end{align}\]

The total differential of \(P\) is given by

(3.57)#\[\begin{align} dP &= \frac{\partial P}{\partial \rho}d\rho + \frac{\partial P}{\partial T}dT \\ &= RTd\rho + \rho R dT \end{align}\]

Finally, the total derivatives of \(P\) are

(3.58)#\[\begin{align} \frac{d P}{d \rho} &= RT + \rho R\frac{dT}{d\rho} \\ \frac{d P}{d T} &= RT\frac{d\rho}{dT} + \rho R \end{align}\]

In this case, we would expect the molar density of the gas to be temperature dependent and thus \(\frac{d\rho}{dT} \neq 0\). This implies that the total derivatives and partial derivatives are not equivalent in this case.