Skip to main content

Chapter 4 CA4: Partial Differentiation

Section 4.1 Partial Differentiation

Firstly, let’s recall some of the important things that we know about the derivative of the function of one variable, \(f(x)\text{.}\)
  1. At any given point \(x_0\text{,}\) \(f'(x_0)\) gives the slope of the tangent to the graph of the function at that point.
    Figure 4.1. Plot of \(y=f(x)\) (blue) and the tangent line (red) at \(x=x_0\text{.}\)
  2. At any given point \(x_0\text{,}\) \(f'(x_0)\) gives the instantaneous rate of change of the function at that point.
  3. The derivative \(f'(x)\) is itself a function of one variable, when it exists.
For a function of two variables, \(f(x,y)\text{,}\) the rate at which the function is changing at any point as we vary the independent variables depends upon the direction in which we vary those variables.

Example 4.2.

Consider the function \(f(x,y) = x^2-y^2\text{.}\) The graph of this function is shown below. At \((x,y)=(0,0)\text{,}\) \(f=0\text{.}\) As we can see by looking at the graph, as we move away from the origin along the positive \(x\)-axis the value of \(f\) is increasing, i.e. the rate of change of the function will be positive. However, if we move away from the origin along the positive \(y\)-axis the value of \(f\) is decreasing, i.e. the rate of change of the function will be negative.
Figure 4.3. 3D plot of \(f(x,y)= x^2-y^2\text{.}\)
As a first step to analyzing more formally how a function of two variables can change with respect to its independent variables we will first consider the cases where we vary only one variable at a time.

Example 4.4.

Consider the function \(f(x,y) = 5 - \dfrac{x^2+y^2}{2}\) at the point \((2,1)\text{.}\)
Firstly, let’s look at the instantaneous rate of change of \(f\) in the direction of the positive \(x\)-axis. As shown in the diagram below, if we hold \(y\) constant at and vary \(x\) we are actually moving along the curve
\begin{equation*} z=\frac{9}{2}-\frac{1}{2}x^2\text{.} \end{equation*}
Figure 4.5. 3D plot of \(f(x,y)= 5 - \dfrac{x^2+y^2}{2}\) with a plane constant in \(y\) through the point \((2,1)\text{.}\)
Along this curve \(\dfrac{dz}{dx}=-x\) and at \(x=2\) we have \(\dfrac{dz}{dx}=-2\text{.}\) Thus, the instantaneous rate of change of \(f\) in the direction of the positive \(x\)-axis at the point \((2,1)\) is \(-2\text{.}\)
Now consider the instantaneous rate of change of \(f\) in the direction of the positive \(y\)-axis. As shown in the diagram below, if we hold \(x\) constant at \(x=2\) and vary \(y\) we are actually moving along the curve
\begin{equation*} z=3-\frac{1}{2}y^2\text{.} \end{equation*}
Along this curve \(\dfrac{dz}{dy}=-y\) and at \(y=1\) we have \(\dfrac{dz}{dy}=-1\text{.}\) Thus, the instantaneous rate of change of \(f\) in the direction of the positive \(y\)-axis at the point \((2,1)\) is \(-1\text{.}\)
Figure 4.6. 3D plot of \(f(x,y)= 5 - \dfrac{x^2+y^2}{2}\) with a plane constant in \(x\) through the point \((2,1)\text{.}\)
Consider a function of two variables, for example:
\begin{equation*} f(x,y)=x^2(\sin(x+5y))\text{.} \end{equation*}
The following plots the graph of \(z=f(x,y)\text{,}\) together with the vertical planes defined by \(y=y_0\) (in orange) and \(x=x_0\) (in red), and arrows representing the slope of the surface inside these planes.
The slopes of the surface inside the planes above are given by what is known as the partial derivatives of the function. Where \(y=y_0\) is kept constant (in the orange plane), the slope is given by the partial derivative \(f_x(x,y)\text{.}\) Where \(x=x_0\) is kept constant (in the red plane), the slope is given by the partial derivative \(f_y(x,y)\text{.}\) Formally, partial derivatives are defined as follows.

Definition 4.7. Partial Derivative.

Consider the function of two variables, \(f(x,y)\)
The partial derivative of \(f\) with respect to \(x\) at the point \((x_0,y_0)\) is given by the limit (if it exists)
\begin{equation*} \frac{\partial f}{\partial x} (x_0,y_0) = \lim_{h \to 0} \left[ \frac{f(x_0+h,y_0)-f(x_0,y_0)}{h} \right]\text{.} \end{equation*}
The partial derivative of \(f\) with respect to \(y\) at the point \((x_0,y_0)\) is given by the limit (if it exists)
\begin{equation*} \frac{\partial f}{\partial y} (x_0,y_0) = \lim_{h \to 0} \left[ \frac{f(x_0,y_0+h)-f(x_0,y_0)}{h} \right]\text{.} \end{equation*}

Remark 4.8. Notation.

The notation \(f_x\) is often used to denote \(\dfrac{\partial f}{\partial x}\text{.}\) Similarly, \(f_y\) is often used to denote \(\dfrac{\partial f}{\partial y}\text{.}\)

Example 4.9.

Using the definition, calculate the partial derivatives of \(f(x,y) = 5 - \dfrac{x^2+y^2}{2}\) at the point \((2,1)\text{.}\)
Answer.
\(\dfrac{\partial f}{\partial x}(2,1) = -2\) and \(\dfrac{\partial f}{\partial y}(2,1) = -1\)
Solution.
Firstly, calculate the partial derivative of \(f\) with respect to \(x\) at \((2,1)\text{.}\)
\begin{align*} \frac{\partial f}{\partial x}(2,1) \amp = \lim_{h \to 0} \left[ \frac{f(2+h,1)-f(2,1)}{h} \right]\\ \amp = \lim_{h \to 0} \left[\frac{1}{h} \left( \left( 5 - \frac{(2+h)^2 + 1^2}{2} \right) - \left( 5 - \frac{2^2+1^2}{2} \right) \right) \right]\\ \amp = \lim_{h \to 0} \left[\frac{1}{h} \left( -\frac{1}{2}(4+4h+h^2+1) +\frac{1}{2}(4+1) \right) \right]\\ \amp = \lim_{h \to 0} \left[ \frac{1}{h} \left(-2h-\frac{1}{2}h^2 \right) \right]\\ \amp = -2 \end{align*}
Next, calculate the partial derivative of \(f\) with respect to \(y\) at \((2,1)\text{.}\)
\begin{align*} \frac{\partial f}{\partial y}(2,1) \amp = \lim_{h \to 0} \left[ \frac{f(2,1+h)-f(2,1)}{h} \right]\\ \amp = \lim_{h \to 0} \left[\frac{1}{h} \left( \left( 5 - \frac{2^2 + (1+h)^2}{2} \right) - \left( 5 - \frac{2^2+1^2}{2} \right) \right) \right]\\ \amp = \lim_{h \to 0} \left[\frac{1}{h} \left( -\frac{1}{2}(4+1+2h+h^2) +\frac{1}{2}(4+1) \right) \right]\\ \amp = \lim_{h \to 0} \left[ \frac{1}{h} \left(-h-\frac{1}{2}h^2 \right) \right]\\ \amp = -1 \end{align*}
If we calculate the partial derivatives of a function at the general point \((x,y)\) (as opposed to some specific point \((x_0,y_0)\)) we will obtain (instead of two specific values) two new functions of two variables.

Example 4.10.

Using the definition, calculate the partial derivatives of \(f(x,y) = xy-1\text{.}\)
Answer.
\(\dfrac{\partial f}{\partial x}(x,y) = y\) and \(\dfrac{\partial f}{\partial y}(x,y) = x\)
Solution.
Calculating the partial derivative with respect to \(x\text{:}\)
\begin{align*} \frac{\partial f}{\partial x}(x,y) \amp = \lim_{h \to 0} \left[ \frac{f(x+h,y)-f(x,y)}{h} \right]\\ \amp = \lim_{h \to 0} \left[ \frac{\left( (x+h)y-1 \right)-(xy-1)}{h} \right]\\ \amp = \lim_{h \to 0} \left[ \frac{hy}{h} \right]\\ \amp = y \end{align*}
Now, calculating the partial derivative with respect to \(y\text{:}\)
\begin{align*} \frac{\partial f}{\partial y}(x,y) \amp = \lim_{h \to 0} \left[ \frac{f(x,y+h)-f(x,y)}{h} \right]\\ \amp = \lim_{h \to 0} \left[ \frac{\left( x(y+h)-1 \right)-(xy-1)}{h} \right]\\ \amp = \lim_{h \to 0} \left[ \frac{hx}{h} \right]\\ \amp = x \end{align*}
As can be seen in the above example, to calculate the partial derivative of \(f\) with respect to \(x\) at the general point \((x,y)\) all we have to do is treat \(y\) as a constant and differentiate \(f(x,y)\) with respect to \(x\) (using all of the familiar rules of differentiation for functions of one variable). Similarly, to calculate the partial derivative of \(f\) with respect to \(y\) at the general point \((x,y)\) treat \(x\) as a constant and differentiate \(f(x,y)\) with respect to \(y\text{.}\)

Example 4.11.

Find the partial derivatives of the function \(f(x,y) = 5 - \frac{x^2+y^2}{2}\) at the point \((2,1)\) using the above method.
Answer.
\(\dfrac{\partial f}{\partial x}(2,1) = -2\) and \(\dfrac{\partial f}{\partial y}(2,1) = -1\)
Solution.
This function can be written as:
\begin{equation*} f(x,y) = 5 - \frac{1}{2}x^2 - \frac{1}{2}y^2. \end{equation*}
Now, thinking of \(y\) as a constant (so that \(\frac{1}{2}y^2\) is also constant) and treating the function as a function of \(x\) only,
\begin{equation*} \dfrac{\partial f}{\partial x}(x,y) = 0 - 2 \times \frac{1}{2}x - 0 = -x. \end{equation*}
Thus,
\begin{equation*} \dfrac{\partial f}{\partial x}(2,1) = -2. \end{equation*}
Next, think of \(x\) as a constant (so that \(\frac{1}{2}x^2\) is also constant) and treating the function as a function of \(y\) only,
\begin{equation*} \dfrac{\partial f}{\partial y}(x,y) = 0-0-2\times \frac{1}{2} y = -y. \end{equation*}
Thus,
\begin{equation*} \dfrac{\partial f}{\partial y}(2,1) = -1. \end{equation*}
A shorter notation for the partial derivative of \(f\) with respect to \(x\) is \(f_x\text{.}\) Similarly the partial derivative with respect to \(y\) is written as \(f_y\text{.}\)

Example 4.12.

Find \(f_x\) and \(f_y\) when \(f(x,y) = x^2y\text{.}\)
Answer.
\(f_x(x,y) = 2xy\) and \(f_y(x,y) = x^2\text{.}\)
Solution.
To find \(f_x (x,y)\text{,}\) think of \(y\) as a constant. Thus,
\begin{equation*} f_x(x,y) = 2xy\text{.} \end{equation*}
To find \(f_y (x,y)\text{,}\) think of \(x\) as a constant. So,
\begin{equation*} f_y(x,y) = x^2\text{.} \end{equation*}

Example 4.13.

Find \(f_x\) and \(f_y\) when \(f(x,y) = \sin^{-1}\left(\dfrac{x}{y}\right) - 5x^2\text{.}\)
Answer.
\(f_x(x,y) =\dfrac{1}{\sqrt{y^2 - x^2}} - 10x\) and \(f_y(x,y)= \dfrac{-x}{y\sqrt{y^2-x^2}}.\)
Solution.
To find \(f_x (x,y)\text{,}\) think of \(y\) as a constant. Thus, using the chain rule:
\begin{align*} f_x(x,y) \amp = \frac{1}{\sqrt{1 - \left(\dfrac{x}{y}\right)^2 }} \cdot \frac{1}{y} - 10x\\ \amp = \frac{1}{\sqrt{y^2 - x^2}} - 10x\text{.} \end{align*}
To find \(f_y (x,y)\text{,}\) think of \(x\) as a constant. Again, using the chain rule:
\begin{align*} f_y(x,y) \amp = \frac{1}{\sqrt{1 - \left(\dfrac{x}{y}\right)^2 }} \cdot \left( \frac{-x}{y^2} \right) - 0\\ \amp = \frac{-x}{y\sqrt{y^2-x^2}}. \end{align*}

Example 4.14.

The equation \(xz + y^2z^3 = 2\) can be thought of as implicitly defining \(z\) as a function of \(x\) and \(y\text{.}\) Find \(z_x\) and \(z_y\text{.}\)
Answer.
\(z_x = \dfrac{-z}{x+3y^2 z^2}\) and \(z_y =\dfrac{-2yz^3}{x+3y^2 z^2}\)
Solution.
To find \(z_x\) differentiate both sides of the defining equation with respect to \(x\text{,}\) remembering that \(z\) is some unknown function of \(x\text{.}\) Also, remember to treat \(y\) as a constant. Then, using the product rule and the chain rule,
\begin{align*} \frac{\partial}{\partial x} \left(xz + y^2z^3 \right) \amp = \frac{\partial}{\partial x} (2)\\ xz_x + z + 3y^2 z^2 z_x \amp = 0\\ z_x (x+3y^2 z^2) \amp = -z\\ z_x \amp = \frac{-z}{x+3y^2 z^2} \end{align*}
Similarly, differentiating both sides of the defining equation with respect to \(y\text{,}\)
\begin{align*} \frac{\partial}{\partial y} \left(xz + y^2z^3 \right) \amp = \frac{\partial}{\partial y} (2)\\ xz_y + 2yz^3 + 3y^2 z^2 z_y \amp = 0\\ z_y (x+3y^2 z^2) \amp = -2yz^3\\ z_y \amp = \frac{-2yz^3}{x+3y^2 z^2} \end{align*}
Partial derivatives can be found for functions of more than two variables.

Example 4.15.

Find the partial derivatives for the function of three variables
\begin{equation*} f(x,y,z) = (2x+3y-z^2)e^{xz}\text{.} \end{equation*}
Answer.
\(f_x(x,y,z) = e^{xz} (2xz + 3yz - z^3 + 2)\text{,}\) \(f_y(x,y,z) = 3e^{xz}\) and \(f_z(x,y,z) = e^{xz} (2x^2 + 3xy - xz^2 - 2z)\)
Solution.
Write the function as
\begin{equation*} f(x,y,z) = 2xe^{xz} + 3ye^{xz} - z^2 e^{xz}\text{.} \end{equation*}
To find \(f_x\) treat \(y\) and \(z\) as constants and think of \(f\) as a function of \(x\) only. Thus,
\begin{align*} f_x(x,y,z) \amp = (2xz e^{xz} + 2e^{xz} ) + 3yze^{xz} - z^3 e^{xz}\\ \amp = e^{xz} (2xz + 3yz - z^3 + 2) \end{align*}
To find \(f_y\) treat \(x\) and \(z\) as constants and think of \(f\) as a function of \(y\) only. Thus,
\begin{align*} f_y(x,y,z) \amp = 0 + 3e^{xz} - 0\\ \amp = 3e^{xz} \end{align*}
Finally, to find \(f_z\) treat \(x\) and \(y\) as constants and think of \(f\) as a function of \(z\) only. Thus,
\begin{align*} f_z(x,y,z) \amp = 2x^2 e^{xz} + 3xye^{xz} - (xz^2e^{xz} + 2ze^{xz} )\\ \amp = e^{xz} (2x^2 + 3xy - xz^2 - 2z) \end{align*}

Exercises Example Tasks

1.
Find both partial derivatives of the function \(f(x,y)=4-xy-y^2\) at the point \((3,2)\text{.}\)
2.
Find \(\dfrac{\partial f}{\partial x}\) and \(\dfrac{\partial f}{\partial y}\) when \(f(x,y) = \ln(x^2-4xy^3)\text{.}\)
3.
If \(L(x,y) = \dfrac{e^{xy}}{(1-x)(1-y)}\text{,}\) find \(L_x(2,3)\text{.}\)
4.
Find \(f_x(x,y)\) and \(f_y(x,y)\) when \(f(x,y) = x^y\text{.}\)
5.
In the following contour plot the contours are for evenly spaced values of \(k\) from \(-2\) at the point \(X\) to \(2\) at the point \(Y\text{.}\) Find the sign of \(f_x(x,y)\) and \(f_y(x,y)\) at the points \(A\text{,}\) \(B\) and \(C\) given the following contour plot for the function \(f(x,y)\text{.}\) Explain your thinking.
Figure 4.16.

Section 4.2 Higher Partial Derivatives

The partial derivatives of the function \(z=f(x,y)\) are themselves functions of two variables. Thus they can be differentiated further, giving the second partial derivatives, the third partial derivatives etc. Common notations for the second partial derivatives include:
\begin{alignat*}{2} \dfrac{\partial}{\partial x} \left( \dfrac{\partial f}{\partial x} \right) \amp = \dfrac{\partial^2 f}{\partial x^2} \amp = (f_x)_x \amp = f_{xx}\\ \dfrac{\partial}{\partial y} \left( \dfrac{\partial f}{\partial x} \right) \amp = \dfrac{\partial^2 f}{\partial y \partial x} \amp = (f_x)_y \amp = f_{xy}\\ \dfrac{\partial}{\partial x} \left( \dfrac{\partial f}{\partial y} \right) \amp = \dfrac{\partial^2 f}{\partial x \partial y} \amp = (f_y)_x \amp = f_{yx}\\ \dfrac{\partial}{\partial y} \left( \dfrac{\partial f}{\partial y} \right) \amp = \dfrac{\partial^2 f}{\partial y^2} \amp = (f_y)_y \amp = f_{yy} \end{alignat*}

Example 4.17.

Find the second partial derivatives for the function
\begin{equation*} f(x,y) = \sin(x) \cos(y)\text{.} \end{equation*}
Answer.
\(f_{xx}(x,y) = -\sin(x) \cos(y)\text{,}\) \(f_{xy}(x,y) = -\cos(x) \sin(y)\text{,}\) \(f_{yx}(x,y) = -\cos(x) \sin(y)\) and \(f_{yy}(x,y) = -\sin(x) \cos(y).\)
Solution.
Begin by finding the first partial derivatives. Here
\begin{align*} \amp f_x(x,y) = \cos(x)\cos(y) \amp \text{and} \amp \amp f_y(x,y) = - \sin(x) \sin(y)\text{.} \end{align*}
Now differentiate \(f_x(x,y)\) firstly with respect to \(x\) to find \(f_{xx}(x,y)\) and then with respect to \(y\) to find \(f_{xy}(x,y)\text{.}\) Thus,
\begin{align*} f_{xx}(x,y) \amp = -\sin(x) \cos(y), \, \, \text{and}\\ f_{xy}(x,y) \amp = -\cos(x) \sin(y). \end{align*}
Next differentiate \(f_y(x,y)\) with respect to \(x\) to find \(f_{yx}(x,y)\) and then with respect to \(y\) to find \(f_{yy}(x,y)\text{.}\) Thus,
\begin{align*} f_{yx}(x,y) \amp = -\cos(x) \sin(y), \, \, \text{and}\\ f_{yy}(x,y) \amp = -\sin(x) \cos(y). \end{align*}
Notice that for this function \(f_{xy}(x,y) = f_{yx}(x,y)\text{.}\)

Example 4.18.

Calculate \(g_{xxy}\text{,}\) \(g_{xyx}\) and \(g_{yxx}\) when \(g(x)=xy^2 + \dfrac{y}{x^2}\text{.}\)
Answer.
\(g_{xxy} = 6x^{-4}\text{,}\) \(g_{xyx} = 6x^{-4}\) and \(g_{yxx} = 6x^{-4}\text{.}\)
Solution.
Begin by writing the function in the form
\begin{equation*} g(x,y) = xy^2 + yx^{-2}\text{.} \end{equation*}
Then the first partial derivatives are
\begin{align*} \amp g_x = y^2 - 2yx^{-3} \amp \text{and} \amp \amp g_y = 2xy+x^{-2} \end{align*}
and hence the second partial derivatives are
\begin{equation*} g_{xx}=6yx^{-4}, \; g_{xy} = 2y-2x^{-3}, \; g_{yx} = 2y-2x^{-3}, \; g_{yy} = 2x\text{.} \end{equation*}
Differentiating \(g_{xx}\) with respect to \(y\text{,}\) \(g_{xy}\) with respect to \(x\) and \(g_{yx}\) with respect to \(x\) gives
\begin{equation*} g_{xxy} = 6x^{-4}, \; g_{xyx} = 6x^{-4}, \; g_{yxx} = 6x^{-4}\text{.} \end{equation*}
The above instances have provided examples of the following general result.
Clairaut’s Theorem can be extended to higher partial derivatives and to functions of more than two variables.

Example 4.20.

Calculate all first and second order partial derivatives for the function
\begin{equation*} g(x,y,z) = \dfrac{x^2 + 3y^2}{1+2z}\text{.} \end{equation*}
Solution.
Even though \(g\) is a function of \(3\) variables, Clairaut’s Theorem still holds. Thus there will be only 6 distinct second partial derivatives, i.e. \(g_{xx}\text{,}\) \(g_{xy}\text{,}\) \(g_{xz}\text{,}\) \(g_{yy}\text{,}\) \(g_{yz}\text{,}\) \(g_{zz}\text{.}\)
Now
\begin{equation*} g_x = \dfrac{2x}{1+2z}, \,\, g_y = \dfrac{6y}{1+2z}, \,\, g_z = \dfrac{-2(x^2+3y^2)}{(1+2z)^2} \end{equation*}
and so
\begin{equation*} g_{xx} = \dfrac{2}{1+2z}, \,\, g_{xy} = 0, \,\, g_{xz} = \dfrac{-4x}{(1+2z)^2}, \end{equation*}
\begin{equation*} g_{yz} = \dfrac{-12y}{(1+2z)^2}, \,\, g_{yy} = \dfrac{6}{1+2z}, \,\, g_{zz} = \dfrac{8(x^2+3y^2)}{(1+2z)^3}. \end{equation*}

Exercises Example Tasks

1.
Find the second partial derivatives for the function \(z=xye^y\text{.}\)
2.
Calculate \(g_{xx},\,\) \(g_{xy}\) and \(g_{xyy}\) for \(g(x,y) = \dfrac{y}{1+x^2}\text{.}\)
3.
Let \(u(x,t) = e^{-t} \sin \left(\dfrac{x}{c}\right)\) where \(c\) is a constant and \(c>0\text{.}\) Determine if \(u\) satisfies
\begin{equation*} \dfrac{\partial u}{\partial t} = c^2 \dfrac{\partial^2 u}{\partial x^2} \end{equation*}

Remark 4.21. A little remark.

Computer algebra systems can also find partial derivatives. For example, here are some examples of a queries to Wolfram Alpha that will work.
Figure 4.22.
Figure 4.23.
Figure 4.24.

Remark 4.25.

SageMath can also be used to compute partial derivatives. For example, the following Sage cell computes the partial derivatives of the function \(f(x,y)=x^2(\sin(x+5y))\text{.}\)