2 Partial Differentiation
You have seen functions of a single variable often - consider \(f(x) = ax +2\) for example. This function contains a constant 2 and a parameter \(a\) but only \(x\) is a variable and derivatives of \(f^{(n)}(x) = \frac{d^nf}{dx^n}\). But we can also have functions that depend on more than one variable like \(f(x,y) = x^2 + 3xy\) which depends on two variables \(x\) and \(y\). In this case for any pair of values \(x\) and \(y\) \(f(x,y)\) has a well defined value. For example, \(f(2,3) = 4 + 3*2*3 = 22\).
We can extend this idea to functions of more than two variables. For the n-variable case \(f(x_1,x_2, ...x_n)\) for a function that depends on \(x_1, x_2, ...x_n\). Functions of one variable can be represented by a graph on a sheet of paper. Functions of two variables can be represented by a surface in 3D space. For example, you may picture \(f(x,y)\) as describing height and position in a landscape. Functions of many variables however are very hard to visualise often. To make things easier in this regard we will focus on functions of two variables most of the time.
2.1 Definition of the partial derivative
A function of two variables \(f(x, y)\) will have a gradient in all directions in the xy plane. Lets consider finding the rate of change of \(f(x, y)\) in the positive \(x\)- and \(y\)-directions. These rates of change are called partial derivotives with respect to \(x\) and \(y\) respectively and have lots of important applications.
For \(f(x, y)\) we define the derivative with respect to \(x\) by saying that it is that for a one variable function when \(y\) is held fixed and treated as constant. We write this as \(\frac{\partial f}{\partial x}\) and read it as the partial derivative of \(f\) with respect to \(x\). We can do the same for \(y \rightarrow \frac{\partial f}{\partial y}\).
To define the partial derivative formally \[ \frac{\partial f}{\partial x}=\lim _{\Delta x \rightarrow 0} \frac{f(x+\Delta x, y)-f(x, y)}{\Delta x} \] provided the limit exists. Similarly, \[ \frac{\partial f}{\partial y}=\lim _{\Delta y \rightarrow 0} \frac{f(x, y+\Delta y)-f(x, y)}{\Delta y} . \]
It is common when discussing partial derivatives involving functions of multiple variables to indicate what variable is being held fixed \[ \left(\frac{\partial f}{\partial x}\right)_y \text { and }\left(\frac{\partial f}{\partial y}\right)_x \]
You can extend this to functions of multi variables \[ \frac{\partial f\left(x_1 \ldots x_n\right)}{\partial x_i} \cdot \]
Just as for single variable functions second and higher order partial derivatives are possible: \[ \begin{aligned} & \frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x}\right)=\frac{\partial^2 f}{\partial x^2} \\ & \frac{\partial}{\partial y}\left(\frac{\partial f}{\partial y}\right)=\frac{\partial^2 f}{\partial y^2} \\ & \frac{\partial}{\partial y}\left(\frac{\partial f}{\partial x}\right)=\frac{\partial^2 f}{\partial y \partial x} \\ & \frac{\partial}{\partial x}\left(\frac{\partial f}{\partial y}\right)=\frac{\partial^2 f}{\partial x \partial y} \end{aligned} \]
Note these last two are equal provided that the second partial derivatives are continuous at the point in question. \[ \begin{aligned} & \frac{\partial^2 f}{\partial x \partial y}=\frac{\partial^2 f}{\partial y \partial x} \\ & \frac{\partial^2 f}{\partial x_i \partial x_j}=\frac{\partial^2 f}{\partial x_j \partial x_i} \end{aligned} \]
Find the first and second derivatives of \(f(x, y)=2 x^3 y^2+y^3\).
\[ \begin{aligned} & \frac{\partial f}{\partial x}=6 x^2 y^2 \\ & \frac{\partial f}{\partial y}=4 x^3 y+3 y^2 \\ & \frac{\partial^2 f}{\partial x^2}=12 x y^2 \\ & \frac{\partial^2 f}{\partial y^2}=4 x^3+6 y \\ & \frac{\partial^2 f}{\partial x \partial y}=12 x^2 y \\ & \frac{\partial^2 f}{\partial y d x}=12 x^2 y \end{aligned} \]
2.2 The total differential and total derivative
In the previous section we defined the rate of change of \(f\) along the positive \(x-\) and \(y-\) axes. Now lets consider the rate of change of \(f(x, y)\) in an arbitrary direction. Lets make simultaneous small changes in \(\Delta x\) in \(x\) and \(\Delta y\) in \(y\) so that \(f\) changes to \(f+\Delta f\). Then we have \[ \begin{aligned} \Delta f = f(x+\Delta x, y+\Delta y)-f(x, y) \\ = f(x+\Delta x, y+\Delta y)-f(x, y+\Delta y)+f(x, y+\Delta y)-f(x, y) \\ = {\left[\frac{f(x+\Delta x, y+\Delta y)-f(x, y+\Delta y)}{\Delta x}\right] \Delta x } \\ +\left[\frac{f(x, y+\Delta y)-f(x, y)}{\Delta y}\right] \Delta y \\ \Delta f \approx \frac{\partial f(x, y)}{\partial x} \Delta x+\frac{\partial f(x, y)}{\partial y} \Delta y \end{aligned} \]
Letting the small changes \(\Delta x\) and \(\Delta y \Rightarrow\) very very small, we define the total derivative as \[ d f=\frac{\partial f}{\partial x} d x+\frac{\partial f}{\partial y} d y \] extended to \(n\) variables \(f\left(x_1, x_2, \ldots x_n\right)\) \[ d f=\frac{\partial f}{\partial x_1} d x_1+\frac{\partial f}{\partial x_2} d x_2+\ldots \frac{\partial f}{\partial x_n} d x_n \]
Find the total differential of the function \[ f(x, y)=y \exp (x+y) \]
\(\frac{\partial f}{\partial x}=y \exp (x+y), \frac{\partial f}{\partial y}=\exp (x+y)+y \exp (x+y)\)
\[ \begin{aligned} d f & =[y \exp (x+y)] d x+[\exp (x+y)+y(\exp (x+y))] d y \\ & =[y \exp (x+y)] d x+[(1+y) \exp (x+y)] d y \end{aligned} \]
Sometimes even if there are multiple variables they can be represented in terms of one variable. For example, \[ x_i=x_i\left(x_1\right) \quad 2,2,3, \ldots n \]
This means that \(f\) can then be expressed as a function of \(x_1\). The total derivative of \(f\) can then be obtained by ordinary differentiation. Alternatively, \[ \left(\frac{d f}{d x}\right)=\left(\frac{\partial f}{\partial x_1}\right)+\frac{\partial f}{\partial x_2} \cdot \frac{d x_2}{d x_1}+\cdots+\frac{\partial f}{\partial x_n} \cdot \frac{d x_n}{d x_1} \] The partial derivative, \(\frac{\partial f}{\partial x_1}\), only accounts for explicit appearances of \(x_1\) and no allowance must be made for the knowledge that changing \(x_1\) necessarily changes \(x_2, x_1 \ldots x_n\). The contributions of these are the other component of the RHS.
Find the total derivative of \(f(x, y)=x^2+3 x y\) with respect to \(x\) given that \(y=\sin ^{-1} x\).
2.3 Exact and inexact differentials
What if we want to find a function \(f\) that differentiates to give a known differential?
Often this relies on experience. For example, consider \(d f=x \,d y+y\, d x\) is \(f(x, y)=x y+c\) where \(c\) is a constant.
Differentials like this (those that integrate directly) are called exact differentials where as those that do not are called inexact differentials. Consider \[ d f=x d y+3 y d x \] is not an obvious differential of any function. Note it is possible to make an inexact differential exact by multiplying it by an integrating factor (not going to deal that in this course).
Show that \(d f=x \, d y+3 y \, d x\) is inexact.
If we integrate with respect to \(x\) \[ f(x, y)=3 x y+g(y) \] where \(g(y)\) is any function of \(y\). If we integrate with respect to \(y\) \[ f(x, y)=x y+h(x) \] where \(h(x)\) is any function of \(x\). These conclusions are inconsistent with each other thus the differential is inexact.
What makes a differential exact? \[ \begin{aligned} & d f=A(x, y) d x+B(x, y) d y \\ & \frac{\partial f}{\partial x}=A(x, y), \frac{\partial f}{\partial y}-B(x, y) \end{aligned} \]
using the property \[ \begin{aligned} & \frac{\partial^2 f}{\partial x \partial y}=\frac{\partial^2 f}{\partial y \partial x} \\ & \frac{\partial}{\partial x} \frac{\partial f}{\partial y}=\frac{\partial}{\partial y} \frac{\partial f}{\partial x} \end{aligned} \] or \[ \frac{\partial}{\partial x} B(x, y)=\frac{\partial}{\partial y} A(x, y) \]
This is both necessary and sufficient for a differential to be exact.
So now lets return to the previous example and lets show that \(x d y+3 y d x\) is inexact \[ B(x, y) d y+A(x, y) d x \] \[ \begin{aligned} & \frac{\partial A}{\partial y}=3, \frac{\partial B}{\partial x}=1 \\ & \frac{\partial A}{\partial y} \neq \frac{\partial B}{\partial x} \text { thus this differential is inexact. } \end{aligned} \]
This can be extended to many variables by requiring \[ \begin{aligned} & \frac{\partial g_i}{\partial x_j}=\frac{\partial g_j}{\partial x_i} \text { for all pairs } i, j \\ & d f=\sum_{i=1}^n g_i\left(x_1, x_i, ... x_n\right) d x_i \end{aligned} \]
Is \(df = (y+z) d x+x d y+x d z\) an exact or inexact differential?
To answer this we need to check \(1/2 n (n-1)\) relationships to check or \(\frac{1}{2} \cdot 3 \cdot 2=3\), relationships to check. \[ \begin{aligned} & g_1=y+z, g_2=x, g_3=x\\ & \frac{\partial x}{\partial y} \overset{?}{=} \frac{\partial y}{\partial x}\\ &\frac{\partial g_1}{\partial y}= 1 \quad \frac{\partial g_2}{\partial x}=1 \\ & \frac{\partial x}{\partial z} \overset{?}{=} \frac{\partial z}{\partial x}\\ &\frac{\partial g_1}{\partial z}=1 \quad \frac{\partial g_3}{\partial x} = 1\\ &\frac{\partial y}{\partial z}\overset{?}{=}\frac{\partial z}{\partial y} \\ &\frac{\partial g_2}{\partial z} = 0 \quad \frac{\partial g_2}{\partial z} = 0. \end{aligned} \] All relationships are consistent so this differential is exact.
2.4 Chain Rule
Lets now consider the case where \(x\) and \(y\) are functions of another variable say \(u\).
Lets say we want to find \(\frac{d f}{d u}\). We could substitute \(x(u)\) and \(y(u)\) into \(f(x, y)\) and then differentiate with respect to \(u\) but sometimes it is easier to use total differentials. \[ d f=\frac{\partial f}{\partial x} d x+\frac{\partial f}{\partial y} d y \] we can divide by \(du\) \(\frac{d f}{d u}=\frac{\partial f}{\partial x} \frac{d x}{d u}+\frac{\partial f}{\partial y} \frac{d y}{d u}\)
This is called chain rule for partial differentiation. The expression above provides the total derivative of \(f\) with respect to \(u\) and is particularly helpful when an equation is expressed in parametric form.
Given \(x(u)=1+a u\) and \(y(u)=b u^3\) find the rate of change of \(f(x, y)=x e^{-y}\) with respect to \(u\).
\[ \begin{aligned} \frac{\partial f}{\partial x} & =e^{-y} \\ \frac{\partial f}{\partial y} & =x e^{-y} \cdot-1 \\ \frac{d x}{d u} & =a \\ \frac{d u}{d u} & =3 b u^2 \\ \frac{d f}{d u} & =e^{-y} \cdot a-x e^{-y} \cdot 3 b u^2 \\ & =a e^{-b u^3}-(1+a u) e^{-b u^3} \cdot 3 b u^2 \\ \frac{d f}{d u} & =e^{-b u^3}\left(a-3 b u^2-3 a b u^3\right) \end{aligned} \]
For \(n\) variables each which are a function of \(u\) \[ \frac{d f}{d u}=\sum_{i=1}^n \frac{\partial f}{\partial x_i} \frac{d x_i}{d u}=\frac{\partial f}{\partial x_1} \frac{d x_1}{d u}+\frac{\partial f}{\partial x_2} \frac{d x_2}{d u}+\cdots+\frac{\partial f}{\partial x_n} \frac{d x_n}{d u} \]
2.5 Change of variables
It is sometimes useful to change variables during an analysis - can use chain rule to do this \[ \frac{\partial f}{\partial u_j}=\sum_{i=1}^n \frac{\partial f}{\partial x_i} \frac{\partial x_i}{\partial u_j}, j=1,2, \ldots n \]
2.6 Thermodynamic relations
First Law of thermodynamics \(\Rightarrow\) Conservation of energy \[ d U=T d S-P d V \] \(U\) is internal energy, \(T\) is temperature, \(S\) is entropy, \(P\) is pressure and \(V\) is volume.
The four quantities on the right hand side are not independent – any two can be varied independently but then the other two are determined. We will for the moment look at this relation mathematically: \[ \begin{aligned} & d U=\left(\frac{\partial U}{\partial X}\right)_Y d X+\left(\frac{\partial U}{\partial Y}\right)_X d Y \\ & \frac{\partial^2 U}{\partial X \partial Y}=\frac{\partial^2 U}{\partial Y \partial X} \quad \\ \end{aligned} \] where \(X\) and \(Y\) are chosen from \(P, V, S,\) and \(T\).
Show that \(\left(\frac{\partial T}{\partial V}\right)_s=-\left(\frac{\partial P}{\partial S}\right)_V\)
\[ \begin{aligned} & d U=\left(\frac{\partial U}{\partial S}\right)_V d S+\left(\frac{\partial U}{\partial V}\right)_S d V \\ & T d S-P d V=\left(\frac{\partial U}{\partial S}\right)_V d S+\left(\frac{\partial U}{\partial V}\right)_S d V \\ & T=\left(\frac{\partial U}{\partial S}\right)_V \text { and }-P=\left(\frac{\partial U}{\partial V}\right)_S \\ & \frac{\partial^2 U}{\partial V \partial S}=\frac{\partial^2 U}{\partial S \partial V} \end{aligned} \] So if we now take the partial derivative \(T\) with respect to \(V\) and the partial of \(P\) with respect to \(S\) we find \[ \begin{aligned} &\frac{\partial{T}}{\partial{V}} = \frac{\partial^2 U}{\partial V \partial S}\\ &-\frac{\partial{P}}{\partial{S}} = \frac{\partial^2 U}{\partial S \partial V} \\ \therefore & \left(\frac{\partial T}{\partial V}\right)_S=-\left (\frac{\partial P}{\partial S}\right)_V \end{aligned} \]
Show that \(\left(\frac{\partial S}{\partial V}\right)_T = \left(\frac{\partial P}{\partial T}\right)_V\)
2.7 Differentiation of integrals
\[ \begin{aligned} & F(x, t)=\int f(x, t)\, d t \\ & \frac{\partial F(x, t)}{\partial t}=f(x, t) \end{aligned} \]
Assuming that the second derivatives are continuous \[ \begin{aligned} & \frac{\partial^2 F(x,t)}{\partial t \partial x}=\frac{\partial^2 F(x, t)}{\partial x \partial t} \\ & \frac{\partial}{\partial t}\left(\frac{\partial F(x, t)}{\partial x}\right)=\frac{\partial}{\partial x}\left(\frac{\partial F(x,t)}{\partial t}\right)=\frac{\partial}{\partial t} f(x,t) \end{aligned} \]
Integrating this with respect to \(t\) gives us \[ \frac{\partial F(x, t)}{\partial x}=\int \frac{\partial}{\partial x} f(x, t) d t \]
Now consider the definite integral \[ \begin{aligned} I(x) & =\int_{t=u}^{t=v} f(x, s) d t \\ & =F(x, v)-F(x, u) \end{aligned} \] where \(u\) and \(v\) are constants. Differentiating this integral with respect to \(x\) \[ \begin{aligned} \frac{\partial I(x)}{\partial x} & =\frac{\partial F(x, v)}{\partial x}-\frac{\partial F(x, u)}{\partial x} \\ & =\int^v \frac{\partial}{\partial x} f(x, t) d t-\int^u \frac{\partial}{\partial x} f(x, t) d t \\ \frac{\partial I(x)}{\partial x} & =\int_u^v \frac{\partial}{\partial x} f(x, t) d t \end{aligned} \]
This is Leibnitz’ rule for differentiating integrals. It means that for constant limits of integration the order of differentiation and integration can be reversed. In the general case \[ \begin{aligned} I(x) & =\int_{t=u(x)}^{t+v(x)} f(x, t) d t \\ & =F(x, v(x))-F(x, u(x)) \\ \frac{\partial I}{\partial v} & =f(x, v(x)) \text { and } \frac{\partial I}{\partial u}=-f(x, u(x)) \\ \frac{d I}{d x} & =\left(\frac{\partial I}{\partial v}\right) \frac{d v}{d x}+\left(\frac{\partial I}{\partial u}\right) \frac{d u}{d x}+\frac{\partial I}{\partial x} \\ & =f(x, v(x)) \frac{d v}{d x}-f(x, u(x)) \frac{d u}{d x}+\frac{\partial}{\partial x} \int_{u(x)}^{v(x)} f(x, t) d t \\ & =f(x, v(x)) \frac{d v}{d x}-f(x, u(x)) \frac{d u}{d x}+\int_{u(x)}^{v(x)} \frac{\partial}{\partial x} f(x, t) d t \end{aligned} \] Can do the final step because \(u(x)\) and \(v(x)\) are held constant in the last term.
Find the derivative of \[ I(x) = \int_x^{x^2}\frac{\sin xt}{t} dt \]