]> Change of variables

### Chapter 3: Many Variables; Section 1: Differentiation; page 4

Previous topic: page 3 Derivatives of Higher Order

Next topic: page 5 Stationary Points

# Change of Variables

## Two variables

For functions with a single variable $f\left(x\right)$, the change of the variable x by a new variable u can be written by a functional relation between the variables

 $\begin{array}{l}x=x\left(u\right)\\ f\left(x\right)=f\left[x\left(u\right)\right]\end{array}\right\}$ (3.1.4.1)

and the derivative with respect to the new variable is given by the chain rule:

 $\frac{\text{d}f}{\text{d}u}=\frac{\text{d}f}{\text{d}x}\frac{\text{d}x}{\text{d}u}$ (3.1.4.2)

In the case of a function of two variables $f\left(x,y\right)$ , the change of the pair of variables (x,y) by a new pair (u,v), can be also expressed by a functional relation of the variables

 $\begin{array}{l}\left\{\begin{array}{l}x=x\left(u,v\right)\\ y=y\left(u,v\right)\end{array}\\ f\left(x,y\right)=f\left[x\left(u,v\right),y\left(u,v\right)\right]\end{array}\right\}$ (3.1.4.3)

The derivatives of the function with respect to the new variables can be obtained from the definition of partial derivatives, yielding the following chain rules:

 $\begin{array}{l}{\left(\frac{\partial f}{\partial u}\right)}_{v}={\left(\frac{\partial f}{\partial x}\right)}_{y}{\left(\frac{\partial x}{\partial u}\right)}_{v}+{\left(\frac{\partial f}{\partial y}\right)}_{x}{\left(\frac{\partial y}{\partial u}\right)}_{v}\\ {\left(\frac{\partial f}{\partial v}\right)}_{u}={\left(\frac{\partial f}{\partial x}\right)}_{y}{\left(\frac{\partial x}{\partial v}\right)}_{u}+{\left(\frac{\partial f}{\partial y}\right)}_{x}{\left(\frac{\partial y}{\partial v}\right)}_{u}\end{array}\right\}$ (3.1.4.4)

The relations (3.1.4.4) contain partial derivatives, indexed by the variable that is kept constant during the differentiation. This notation is introduced just for clarity. It is not necessary, and will be usually omitted, except for a few particular cases. Since the first derivatives are also functions of two variables, the chain rules (3.1.4.4) can be reused, in order to obtain second order derivatives, and so on, up to any order of differentiation. It should be clear, without saying, that (3.1.4.4) requires differentiability of f, with respect to x and to y.

## Matrix notation

The expression (3.1.4.4) can be written in a more compact matrix form:

 $\left(\begin{array}{l}\frac{\partial f}{\partial u}\\ \frac{\partial f}{\partial v}\end{array}\right)=\left(\begin{array}{cc}\frac{\partial x}{\partial u}& \frac{\partial y}{\partial u}\\ \frac{\partial x}{\partial v}& \frac{\partial y}{\partial v}\end{array}\right)\left(\begin{array}{l}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\end{array}\right)$ (3.1.4.5)

The matrix notation is borrowed from the linear algebra. We don't need to know algebra, but can use this notation by following a simple rule. The following expression corresponds to a n dimensional space

 $\left(\begin{array}{l}{w}_{1}\\ {w}_{2}\\ ...\\ {w}_{n}\end{array}\right)=\left(\begin{array}{cccc}{a}_{11}& {a}_{12}& ...& {a}_{1n}\\ {a}_{21}& {a}_{22}& ...& {a}_{2n}\\ ...& ...& ...& ...\\ {a}_{n1}& {a}_{n2}& ...& {a}_{nn}\end{array}\right)\left(\begin{array}{l}{v}_{1}\\ {v}_{2}\\ ...\\ {v}_{n}\end{array}\right)$ (3.1.4.6)

The two columns of n values each, denoted by w and v are called vectors, and the square form of n² values, denoted by a, is called a matrix. The term aij of the matrix means the value at row i and column j. The expression (3.1.4.6) obeys the following rule

 $\begin{array}{l}{w}_{i}=\sum _{j=1}^{n}\left({a}_{ij}\text{​}{v}_{j}\right)\\ \text{where}\text{\hspace{0.28em}}i=1,2,...n\end{array}\right\}$ (3.1.4.7)

## Transformations in two dimensions

A relation between the pair of variables (3.1.4.3), can be interpreted geometrically, as the relation between the two systems of coordinates in a two dimensional space. One point in such a space is defined as a pair of the coordinate values. If there is one to one correspondence between each point of the one coordinate system, with a point of the other system, then the relation (3.1.4.3) defines the transformation of the coordinates.

We already know that a coordinate system displayed with rectangular coordinate axes, is called Cartesian. Other systems, for example the polar coordinates, use a different display, and are called by the general name curvilinear coordinates. In order to understand better the transformation of coordinates, we are going to study few examples. We'll start with the translation and the rotation of Cartesian coordinates. The translation and rotation of a geometrical object in a plane is already known from chapter 1. But the translation and rotation of the coordinate system, is equivalent to the translation and rotation of an object in the opposite direction, which we'll have to keep in mind. This is graphically explained at Fig.  Translation of coordinates and Fig.  Rotation of coordinates

The simplest example is a translation of the Cartesian coordinates by the constant increments Δx and Δy. From the translation of an object (1.2.5.11), one obtains the translation of the coordinate system:

 $\begin{array}{l}x=x\text{'}+\Delta x\\ y=y\text{'}+\Delta y\end{array}\right\}$ (3.1.4.8)

After substituting u by x' and v by y' in (3.1.4.5), one obtains

 $\left(\begin{array}{l}\frac{\partial f}{\partial x\text{'}}\\ \frac{\partial f}{\partial y\text{'}}\end{array}\right)=\left(\begin{array}{cc}\frac{\partial x}{\partial x\text{'}}& \frac{\partial y}{\partial x\text{'}}\\ \frac{\partial x}{\partial y\text{'}}& \frac{\partial y}{\partial y\text{'}}\end{array}\right)\left(\begin{array}{l}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\end{array}\right)=\left(\begin{array}{cc}1& 0\\ 0& 1\end{array}\right)\left(\begin{array}{l}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\end{array}\right)$ (3.1.4.9)

yielding

 $\begin{array}{l}\frac{\partial f}{\partial x\text{'}}=\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y\text{'}}=\frac{\partial f}{\partial y}\end{array}\right\}$ (3.1.4.10)

Was this expected? The derivative with respect to one of the coordinate axes, is obtained by incrementing the coordinate in the direction of the axis. The new coordinates' axes remain parallel to the previous ones, and therefore the derivative is unaffected.

On the other hand, the rotation of the coordinates should have effect on the derivatives, as shown in the next example. The rotation of coordinates about the origin by an angle Δφ according to (1.2.5.35) is expressed by

 $\begin{array}{l}x=x\text{'}\mathrm{cos}\Delta \phi -y\text{'}\mathrm{sin}\Delta \phi \\ y=x\text{'}\mathrm{sin}\Delta \phi +y\text{'}\mathrm{cos}\Delta \phi \end{array}\right\}$ (3.1.4.11)

yielding this time a different result, in comparison with (3.1.4.9)

 $\left(\begin{array}{l}\frac{\partial f}{\partial x\text{'}}\\ \frac{\partial f}{\partial y\text{'}}\end{array}\right)=\left(\begin{array}{cc}\frac{\partial x}{\partial x\text{'}}& \frac{\partial y}{\partial x\text{'}}\\ \frac{\partial x}{\partial y\text{'}}& \frac{\partial y}{\partial y\text{'}}\end{array}\right)\left(\begin{array}{l}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\end{array}\right)=\left(\begin{array}{cc}\mathrm{cos}\Delta \phi & \mathrm{sin}\Delta \phi \\ -\mathrm{sin}\Delta \phi & \mathrm{cos}\Delta \phi \end{array}\right)\left(\begin{array}{l}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\end{array}\right)$ (3.1.4.12)

and finally

 $\begin{array}{l}\frac{\partial f}{\partial x\text{'}}=\mathrm{cos}\Delta \phi \frac{\partial f}{\partial x}+\mathrm{sin}\Delta \phi \frac{\partial f}{\partial y}\\ \frac{\partial f}{\partial y\text{'}}=-\mathrm{sin}\Delta \phi \frac{\partial f}{\partial x}+\mathrm{cos}\Delta \phi \frac{\partial f}{\partial y}\end{array}\right\}$ (3.1.4.13)

The relation of the polar with the Cartesian coordinates was given in chapter 1. It is reproduced here

 $\begin{array}{l}\left\{\begin{array}{l}x=r\mathrm{cos}\phi \\ y=r\mathrm{sin}\phi \end{array}\\ \text{restrictions:}\\ r\ge 0\\ 0\le \phi <2\pi \end{array}\right\}$ (3.1.4.14)

and will be used as another example of transformation. The substitution of (3.1.4.14) into (3.1.4.5) yields

 $\left(\begin{array}{l}\frac{\partial f}{\partial r}\\ \frac{\partial f}{\partial \phi }\end{array}\right)=\left(\begin{array}{cc}\frac{\partial x}{\partial r}& \frac{\partial y}{\partial r}\\ \frac{\partial x}{\partial \phi }& \frac{\partial y}{\partial \phi }\end{array}\right)\left(\begin{array}{l}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\end{array}\right)=\left(\begin{array}{cc}\mathrm{cos}\phi & \mathrm{sin}\phi \\ -r\mathrm{sin}\phi & r\mathrm{cos}\phi \end{array}\right)\left(\begin{array}{l}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\end{array}\right)$ (3.1.4.15)

and finally

 $\begin{array}{l}\frac{\partial f}{\partial r}=\mathrm{cos}\phi \frac{\partial f}{\partial x}+\mathrm{sin}\phi \frac{\partial f}{\partial y}\\ \frac{\partial f}{\partial \phi }=-r\mathrm{sin}\phi \frac{\partial f}{\partial x}+r\mathrm{cos}\phi \frac{\partial f}{\partial y}\end{array}\right\}$ (3.1.4.16)

## Transformations in three dimensions

We learned previously how to use a three dimensional right-handed Cartesian coordinate system, for displaying a function of two variables. The same system allows us also to display any point of a function with three variables. As in the case of a planar coordinate system, one can define curvilinear coordinates. We are now going to study here two examples, which are the most common: the cylindrical and the spherical coordinates, and their relations with the Cartesian.

As a first example we'll study the cylindrical coordinate system. It uses the the polar coordinates for the (x,y) plane, and the z coordinate, as it is defined in the Cartesian coordinate system.

Notice that a constant r, defines a cylinder with radius=r. A graphical display of the cylindrical coordinates is given in Fig. Cylindrical coordinates.

The relation with the Cartesian coordinates is

 $\begin{array}{l}x=r\mathrm{cos}\phi \\ y=r\mathrm{sin}\phi \\ z=z\\ \text{restrictions:}\\ r\ge 0\\ 0\le \phi <2\pi \end{array}\right\}$ (3.1.4.17)

The transformation of the first derivatives of a function with three variables

 $f=f\left(x,y,z\right)$ (3.1.4.18)

is according to the matrix notation (3.1.4.6),

 $\left(\begin{array}{l}\frac{\partial f}{\partial r}\\ \frac{\partial f}{\partial \phi }\\ \frac{\partial f}{\partial z}\end{array}\right)=\left(\begin{array}{ccc}\mathrm{cos}\phi & \mathrm{sin}\phi & 0\\ -r\mathrm{sin}\phi & r\mathrm{cos}\phi & 0\\ 0& 0& 1\end{array}\right)\left(\begin{array}{l}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\\ \frac{\partial f}{\partial z}\end{array}\right)$ (3.1.4.19)

The four terms from the upper left corner of the matrix correspond to the matrix of (3.1.4.15), and therefore (3.1.4.16) holds also here. The vanishing terms are due to the independence of z from r and φ.

The spherical coordinates serve as the second example of curvilinear coordinates in three dimensions. The relation with the Cartesian coordinates is

 $\begin{array}{l}x=R\mathrm{sin}\theta \mathrm{cos}\phi \\ y=R\mathrm{sin}\theta \mathrm{sin}\phi \\ z=R\mathrm{cos}\theta \\ \text{restrictions:}\\ R\ge 0\\ 0\le \theta \le \pi \\ 0\le \phi <2\pi \end{array}\right\}$ (3.1.4.20)

The coordinate φ is the same, as the one used in the cylindrical system. R is the distance of a point from the origin

 ${R}^{2}={r}^{2}+{z}^{2}={x}^{2}+{y}^{2}+{z}^{2}$ (3.1.4.21)

where r is borrowed here from the cylindrical coordinates. Notice the difference between R and r. Sometimes the Greek letter ρ is used instead of r, in order to stress the difference. The angle θ is between the positive direction of the z axis and the straight segment connecting the point with the origin. Notice the difference in the span of φ and θ.

A constant value of θ defines a dual conic surface with an opening angle of θ. A constant value of R defines a spherical surface with radius R. A graphical display of the spherical coordinates is given at Fig. Spherical coordinates.

The transformation of the first derivatives of (3.1.4.18) is

 $\begin{array}{l}\left(\begin{array}{c}\frac{\partial f}{\partial R}\\ \frac{\partial f}{\partial \theta }\\ \frac{\partial f}{\partial \phi }\end{array}\right)=\left(\begin{array}{ccc}\frac{\partial x}{\partial R}& \frac{\partial y}{\partial R}& \frac{\partial z}{\partial R}\\ \frac{\partial x}{\partial \theta }& \frac{\partial y}{\partial \theta }& \frac{\partial z}{\partial \theta }\\ \frac{\partial x}{\partial \phi }& \frac{\partial y}{\partial \phi }& \frac{\partial z}{\partial \phi }\end{array}\right)\left(\begin{array}{c}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\\ \frac{\partial f}{\partial z}\end{array}\right)=\\ =\left(\begin{array}{ccc}\mathrm{sin}\theta \mathrm{cos}\phi & \mathrm{sin}\theta \mathrm{sin}\phi & \mathrm{cos}\theta \\ R\mathrm{cos}\theta \mathrm{cos}\phi & R\mathrm{cos}\theta \mathrm{sin}\phi & -R\mathrm{sin}\theta \\ -R\mathrm{sin}\theta \mathrm{sin}\phi & R\mathrm{sin}\theta \mathrm{cos}\phi & 0\end{array}\right)\left(\begin{array}{c}\frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\\ \frac{\partial f}{\partial z}\end{array}\right)\end{array}\right\}$ (3.1.4.22)

## Physical dimensions

Since a transformation of coordinates is defined by functional relations, in the case of variables with physical dimensions, one should take care to obey the appropriate rules. In the examples given already on this page, if the Cartesian coordinates correspond to a metric system, these rules are obeyed.

Let's consider (3.1.4.20) as an example. A metric system would have the following relations of the physical dimensions:

 $\begin{array}{l}\left[x\right]=\left[y\right]=\left[z\right]=\left[R\right]\\ \left[\theta \right]=\left[\phi \right]=\text{\hspace{0.28em}}\text{none}\end{array}\right\}$ (3.1.4.23)

On the other hand, if the Cartesian coordinate system is not metric, then the relation (3.1.4.21) is senseless.

The following example (exercise 1) is a legitimate transformation of two variables:

 $\begin{array}{l}x=u\mathrm{exp}\left(w\right)\\ y=w\mathrm{exp}\left(-u\right)\end{array}\right\}$ (3.1.4.24)

But in the case of physical variables, and since the argument of an exponential function should be dimensionless, it follows that x and y should also be dimensionless. If x and y have physical dimensions, then one could use, for example, the following transformation:

 $\begin{array}{l}x=u\mathrm{exp}\left({k}_{1}w\right)\\ y=w\mathrm{exp}\left(-{k}_{2}u\right)\\ {k}_{1}\text{\hspace{0.17em}}\text{and}\text{\hspace{0.17em}}{k}_{2}\text{\hspace{0.17em}}\text{are}\text{\hspace{0.17em}}\text{constants}\end{array}\right\}$ (3.1.4.25)

with the following relations of the physical dimensions

 $\begin{array}{l}\left[x\right]=\left[u\right]={\left[{k}_{2}\right]}^{-1}\\ \left[y\right]=\left[w\right]={\left[{k}_{1}\right]}^{-1}\end{array}\right\}$ (3.1.4.26)

## Legendre transformation

The Legendre transformation, commonly used in theoretical physics, is of a different kind. This transformation uses a physical function, in order to transform a derivative into a new variable. The transformation obeys the rules of physical dimensions, and modifies the function.

The transformation shown here is for a function of two variables, but can be easily extended to more variables. The total differential of  f(x,y)  is

 $\begin{array}{l}\text{d}f=u\text{ }\text{d}x+v\text{ }\text{d}y\\ \left\{\begin{array}{l}u=\frac{\partial f}{\partial x}\\ v=\frac{\partial f}{\partial y}\end{array}\end{array}\right\}$ (3.1.4.27)

In order to use u as a variable instead of x, we'll define a new function g as

 $g=f-x\text{ }u$ (3.1.4.28)

With the assistance of (3.1.4.27) one obtains

 $\begin{array}{l}\text{d}g=\text{d}f-u\text{ }\text{d}x-x\text{ }\text{d}u=\\ =u\text{ }\text{d}x+v\text{ }\text{d}y-u\text{ }\text{d}x-x\text{ }\text{d}u=\\ =v\text{ }\text{d}y-x\text{ }\text{d}u\end{array}\right\}$ (3.1.4.29)

with

 $\begin{array}{l}g=g\left(u,y\right)\\ \left\{\begin{array}{l}x=-\frac{\partial g}{\partial u}\\ v=\frac{\partial g}{\partial y}\end{array}\end{array}\right\}$ (3.1.4.30)

Notice that f and g are different functions, but have the same physical dimensions. The procedure can be similarly applied for the transformation  $y↔v$.

As a physical example of the Legendre transformation, we'll use again the main law of thermodynamics (3.1.2.12/14), where the internal energy U is a function of two variables: the entropy S and the volume V, and the total differential is

 $\begin{array}{l}U=U\left(S,V\right)\\ \left\{\begin{array}{l}\text{d}U={\left(\frac{\partial U}{\partial S}\right)}_{V}\text{d}S+{\left(\frac{\partial U}{\partial V}\right)}_{S}\text{d}V=\\ =T\text{d}S-p\text{d}V\end{array}\end{array}\right\}$ (3.1.4.31)

where T is temperature and p is pressure.

The following application of the Legendre transformation (3.1.4.28/30) yields a new function $H\left(S,p\right)$, which is called Enthalpy:

 $\begin{array}{l}H=U+pV\\ \left\{\begin{array}{l}\text{d}H=\text{d}U+p\text{d}V+V\text{d}p=\\ =T\text{d}S-p\text{d}V+p\text{d}V+V\text{d}p=\\ =T\text{d}S+V\text{d}p=\\ ={\left(\frac{\partial H}{\partial S}\right)}_{p}\text{d}S+{\left(\frac{\partial H}{\partial p}\right)}_{S}\text{d}p\end{array}\end{array}\right\}$ (3.1.4.32)

Since the differentiation of $H\left(S,p\right)$ is independent of the order, we obtain in addition to (3.1.3.11), another Maxwell equation of thermodynamics:

 ${\left(\frac{\partial T}{\partial p}\right)}_{S}={\left(\frac{\partial V}{\partial S}\right)}_{p}$ (3.1.4.33)

## Exercises

Exercise 1.

$f=f\left(x,y\right)$

is a function of two variables. Calculate

$\frac{\partial f}{\partial u}\text{ }\text{and}\text{ }\frac{\partial f}{\partial w}$

for the transformation of variables (3.1.4.24) :

$\begin{array}{l}x=u\mathrm{exp}\left(w\right)\\ y=w\mathrm{exp}\left(-u\right)\end{array}\right\}$

Exercise 2. Obtain the general expression of the second order derivatives

$\frac{{\partial }^{2}f}{\partial {\tau }^{2}}\text{\hspace{0.17em}},\text{ }\frac{{\partial }^{2}f}{\partial {\sigma }^{2}}\text{ }\text{and}\text{ }\frac{{\partial }^{2}f}{\partial \tau \text{ }\partial \sigma }$

for the function of two variables

$f=f\left(x,y\right)$

after applying the transformation

$\begin{array}{l}x=x\left(\tau ,\sigma \right)\\ y=y\left(\tau ,\sigma \right)\end{array}\right\}$

Exercise 3. The Cartesian coordinate system (x', y') is obtained by rotating the system (xy) by an angle β about the origin. For a given function

$f=f\left(x,y\right)$

Calculate

1. ${\left(\frac{\partial f}{\partial x\text{'}}\right)}^{2}+{\left(\frac{\partial f}{\partial y\text{'}}\right)}^{2}$

2. $\frac{{\partial }^{2}f}{\partial x{\text{'}}^{2}}+\frac{{\partial }^{2}f}{\partial y{\text{'}}^{2}}$

Exercise 4. The function $f=f\left(x,y\right)$ undergoes the transformation $\begin{array}{l}x=x\\ y=y\left(x,z\right)\end{array}\right\}$ Use the expressions $\begin{array}{l}{\left(\frac{\partial y}{\partial x}\right)}_{z}\text{ }\text{and}\text{ }{\left(\frac{\partial y}{\partial z}\right)}_{x}\\ {\left(\frac{\partial f}{\partial x}\right)}_{y}\text{ }\text{and}\text{ }{\left(\frac{\partial f}{\partial y}\right)}_{x}\end{array}\right\}$ in order to obtain

1. ${\left(\frac{\partial f}{\partial x}\right)}_{z}$

2. ${\left(\frac{\partial f}{\partial z}\right)}_{x}$

3. ${\left(\frac{\partial f}{\partial y}\right)}_{z}$

4. ${\left(\frac{\partial f}{\partial z}\right)}_{y}$
Notice: The first two questions of this exercise are simple, but the last two require a good understanding of the change of variables, and of the partial derivatives.

Exercise 5. As a continuation of the example (3.1.4.31/33)

1. Obtain the total differential of the thermodynamic function $F\left(T,V\right)$ called "Helmholtz free energy" by the use of the Legendre transformation!
2. Obtain the total differential of the thermodynamic function $G\left(T,p\right)$ called "Gibbs free energy" by the use of the Legendre transformation!
3. From the total differentials, deduce the corresponding thermodynamic Maxwell equations!

Previous topic: page 3 Derivatives of Higher Order

Next topic: page 5 Stationary Points