Exact differentials and line integrals

The METRIC Project

Background

We can use differential relations such as

dz=f(x, y)dx+g(x, y)dy,

which tell us about infinitesimal changes, to calculate the effect on z of large changes in x and y. In general, though, we need to know more than simply the amounts by which x and y have changed: we need information concerning the value of x, and the associated value of y, throughout the change. In other words, we need to specify a path in xy-space between the old and new values of x and y.

This is most easily seen by reference to an example. Consider the differential relation

dz=(x^2)dx+2x y dy.

We calculate the change Δz in the value of z as we move from x = 0, y = 0 to x = 1, y = 1 along the path y = x. The large change Δz is equal to the infinite sum of all the infinitesimal changes: the integral ∫dz, in other words. But

∫dz=∫(x^2)dx+∫2x y dy,

where x and y range from 0 to 1, and are equal throughout. We can use Mathematica to calculate this quantity, which is known as the line integral along the curve:

Integrate[((x^2) /. y -> x), {x, 0, 1}] + 
      Integrate[(2  x y /. x -> y), {y, 0, 1}]

(Note the substitutions y -> x and x -> y inside the integrals which specify the path of the line integral.)

Now: what happens if we keep the changes in x and y the same, but change the path: y = (Sqrt[x]), say? The line integral calculation is the same, except for the substitutions, which become y -> (Sqrt[x]) and x -> (y^2) respectively:

Integrate[((x^2) /. y -> (Sqrt[x])), {x, 0, 1}] + 
      Integrate[(2  x y /. x -> (y^2)), {y, 0, 1}]

As you see, the path matters here, but this is not always the case.

Exercises and Explorations 1

1. Path-dependence and path-independence

Repeat the above calculations, but this time for the differential relation

dz=(y^2)dx+2x y dy.

Try some alternative paths of your own between (0, 0) and (1, 1): the path y = (x^2), say, or y = sin (π x/2) (make sure all your paths actually pass through both points). What do you discover? Can you find any exceptions? 

What about if you consider paths between a different pair of points: (1, 0) and (0,  1), say? (Again, be sure that that paths you consider do actually pass through your chosen pair of points.)

2. A new formula

Our way of calculating path integrals using two substitutions is a little unwieldy, because it fails to deal with paths described by functions (such as y = x + sin π x) for which no neat inverse equation x =.  ..  exists. We can get round this by noting that

∫f(x, y)dx+∫g(x, y)dy=∫{f(x, y)+g(x, y)(dy/dx)}dx.

So the line integral of

dz=(y^2)dx+2x y dy

between (0, 0) and (1, 1) along the path y = x + sin π x is, in Mathematica terms

Integrate[
      ((y^2) + 2  x y D[x + Sin[π x], x]) /. 
        y -> x + Sin[π x], {x, 0, 1}]

Was this what you expected? Use the new formula to explore at least two other paths (making sure, as always, that the paths you consider all pass through your chosen pair of points). The following Mathematica function might help you automate things a bit:

lineIntegral[f_, g_, {x_, xmin_, xmax_}, y_, yexpr_] := 
      Integrate[
        Evaluate[(f  +  g D[yexpr, x]) /. y -> yexpr], {x, xmin, xmax}]

as in

lineIntegral[(y^2), 2  x y, {x, 0, 1}, y, x + Sin[π x]]

Exact Differentials

In the last section, you studied two differential relations:

dz=(x^2)dx+2x y dy

and

dz=(y^2)dx+2x y dy.

Focussing on the latter for the moment, let's divide by the infinitesimal quantity dt:

(dz/dt)=(y^2)(dx/dt)+2x y (dy/dt).

Note that if we set z = x (y^2) this corresponds exactly to the chain rule of partial differentiation:

(dz/dt)=∂(z/∂)x(dx/dt)+∂(z/∂)y(dy/dt),

as you can verify by determining the partial derivatives of z with respect to x and y.

D[x (y^2), x]

D[x (y^2), y]

By way of contrast, consider the former of the two differentials from the last section:

dz=(x^2)dx+2x y dy.

We simply can't work the same trick with this one: there exists no function in x and y whose x-derivative is (x^2) and whose y-derivative is 2xy. An expression whose x-derivative is (x^2) must be of the form (1/3) (x^3) + (Subscript[k, 1])(y)...

D[(1/3) (x^3) + k1[y], x]

... and one whose y-derivative is 2xy is necessarily of the form x (y^2) + (Subscript[k, 2])(x)...

D[x (y^2) + k2[x], y]

These two forms are just incompatible, and that's that.

Differentials of the type

dz=(y^2)dx+2x y dy,

for which a function z = z(x, y) can be found, are called exact differentials. Their line integrals have the property of being independent of path, which means that the quantity z is a function of the state of the system alone, and not of its history, i.e the route taken between the endpoints of the integral.

Exercises and Explorations 2

1. A test for exactness

Consider the exact differential

dz=(y^2)dx+2x y dy.

Compare the output from

D[(y^2), y]

and

D[2  x y,  x]

What do you notice? Does the same thing work with the non-exact differential

dz=(x^2)dx+2x y dy?

Can you explain this phenomenon: why should the existence of a z that's a simple function of x and y imply the property you've just discovered? (Hint: look back at your mathematics lecture notes.)

2. Classifying differentials

Using a test based on question 1, test whether the differential

dz=f(x, y)dx+g(x, y)dy

is exact or not, where

(i) f(x, y) =y cos πxy  and g(x, y)=x cos πxy;

(ii) f(x, y) =x cos πxy  and g(x, y)=y cos πxy;

(iii) f(x, y) =y+πy cos πxy  and g(x, y)=x+2  y+πx cos πxy;

(iv) f(x, y) =x+πy cos πxy  and g(x, y)=x+2  y+πx cos πxy;

Choose on of the exact differentials, and verify that its line integrals are equal along at least three paths of your choosing between the points (0, 0) and (1, 1). Choose one of the inexact differentials, and find two paths between (0, 0) and (1, 1) along which its line integrals differ.

3. Integrals

For the exact differential whose line integral you determined in the last question, find a function z(x, y) with the property that ∂z/∂x = f and ∂z/∂y = g. (Note: this sometimes requires a little care and thought.) Calculate the quantity

Δz=z(1, 1) - z(0, 0)

What do you notice?

Thermodynamical application

Differentials arise naturally in thermodynamics, in which changes in certain quantities depend on changes in the pressure, temperature and/or volume of, say, a fluid. Often the differentials that most naturally arise from the mathematics are non-exact, and therefore describe history-dependent quantities. But with a little cleverness we can usually arrange things so that our differentials are exact, and therefore describe quantities that depend on state alone.

For one mole of a van de Waals fluid the internal energy, U, depends on the pressure, p, and volume, V, as follows:

dU=(1/2)(3  p-(a/(V^2))+((6ab)/((V^3))))dV+(3/2)(V - b)dp,

where a and b are constants.

In the case of carbon dioxide, a=0.364081 Pa (m^6)(mol^(-2)) and b=0.00004267(m^3)(mol^(-1)) In three separate experiments, the pressure and volume of one mole of (Subscript[CO, 2]) were changed from (V = 0.0246726, p = 1.0×(10^5)) to (V = 0.0122836, p = 2.0×(10^5)) along three "paths in pV-space":

(a) along a "straight line" path in the pV plane which joins these points;
(b) isothermally at 298K;
(c) along a two-stage path: first along the isochore from (V = 0.0246726, p = 1.0×(10^5)) to (V = 0.0246726, p = 2.0×(10^5)), then along the isobar from (V = 0.0246726, p = 2.0×(10^5)) to (V = 0.0122836, p = 2.0×(10^5)).

Exercises and Explorations 3

1. The three paths

Write down the equation for the "straight line" path (a), and calculate the line integral of dU along it.

For one mole of a van de Waals fluid, the pressure,  volume and temperature satisfy

(p+(a/(V^2)))(V - b)=R T,

Verify that the endpoints we are studying both lie on the T = 298K isotherm for (Subscript[CO, 2]) (to suitable accuracy), and calculate the line integral of dU along this path.

Finally, calculate the line integral along the two-stage path (this isn't hard to do, but it may require some thought.)

Show all three paths on a suitably labelled diagram.

2. Exactness of the internal energy differential

Show that dU is an exact differential, and therefore that U depends on the current pressure and volume alone, and not on their histories. Find an explicit expression for U in terms of V and p, and show that your result is consistent with your findings from question 1, to a suitable accuracy.