Thermodynamic potentials
The four siblings: $u$, $h$, $f$, and $g$ (no others, no more allowed).
Read Chapter 8 (content starts now).
Internal energy  $u$
Our Gibbs law says, $$du=Tds  Pdv,$$ where $Tds=\delta q_r$.
One way of stating this: $du$ is the heat flow for reversible processes when the volume is not changing (isochoric processes).
Maxwell relationships
The Gibbs law, $$du=Tds  Pdv.$$
Hmmm, $s$ and $v$... We can in principal write $u$ as a function of any two independent thermodynamic parameters/function, for example$u=u(s,v)$.
With these variables, the Pfaffian of $du$ is: $$du = \(\frac{\partial u}{\partial s} \)_v ds + \(\frac{\partial u}{\partial v} \)_s dv,$$
and we can easily identify the coefficients of $ds$ and $dv$ from Gibbs Law with these partial derivatives: $$\(\frac{\partial u}{\partial s} \)_v = T; \hspace{2.0em} \( \frac{\partial u}{\partial v} \)_s = P.$$
Now, using the properties of an exact differential, the cross derivatives of these two expressions have to be equal, that is... $$ \[ \frac{\partial T}{\partial v}\]_s = \[ \frac{\partial P}{\partial s} \]_v .$$
This is one of the socalled Maxwell relations. Three more exist for the other three thermodynamic potentials.
This is an example of what Kerson Huang wrote...
Enthalpy  $h$
We have found the enthalpy to be useful instead of the internal energy when we're interested in processes where $P$ is constant (isobaric) instead of $v$ (isochoric). The differential of enthalpy (units: energy) was calculated from its definition: $$h \equiv u + Pv \Rightarrow dh = du +Pdv +vdP.$$
On substitution into the Gibbs law $du = Tds Pdv$: $$dh = Tds + v\,dP.$$
Enthalpy is apparently the heat flow for reversible, isobaric processes.
This now suggest that it would be most convenient to think of $h=h(s,P)$, and there's a Maxwell relationship that follows from this: $$ \( \frac{\partial T}{\partial P}\)_s = \( \frac{\partial v}{\partial s} \)_P .$$
Enthalpy, $h$, is the second of the four "thermodynamic potentials". It can be thought of as Legendre transformation of $u$...
Legendre transformations
The relationship of $u=u(s,v)$ and $h=h(s,P)$ is an example of a more general problem:
Given a function $f=f(x,y)$ of two independent variables $x$ and $y$: $$\begin{align} df = & \frac{\partial f}{\partial x} dx + \frac{\partial f}{\partial y} dy\\ \equiv & u\,dx + v\,dy.\end{align}$$
Is there some general recipe to come up with a function $g=g(u,y)$ where...
 the independent variables of this new function are $u=\partial f/\partial x$ and $y$ instead of $x$ and $y$, and
 the function $g(u,y)$ is some composition of $f$, $x$, $y$, $u$, and $v$, and
 $g$ has the same units as $f$?
Yes! The recipe is surprisingly simple:
$$g = f  ux.$$
You should verify that... $$dg = v\,dy  x\,du,$$
which shows that $g=g(u,y)$...
OK, let's do it: Since $g = f  ux,$ the differential $dg$ is $$dg=dfdu\,xu\,dx.$$
Subbing in the differential of $f$ which was $df=u\,dx+v\,dy$: $$\begineq dg &=&[{\color{blue}u\,dx}+v\,dy]x\,du{\color{blue}u\,dx}\\ &=&{\bf v\,dyx\,du}.\\ \endeq $$
The original definition of $v$ was $v=\frac{\partial f}{\partial y}$. But we see from this Pfaffian of $g(y,u)$ that it's also true that $v=\frac{\partial g}{\partial y}.$ Summarizing: $$v=\frac{\partial f}{\partial y} =\frac{\partial g}{\partial y}.$$
Looking at the Pfaffian, it must also be true that: $$x=\frac{\partial g}{\partial u}.$$
Apparently, as the example of internal energy and enthalpy shows, $g=f+ux$ would also work as a Legendre transformation.
Legendre transform of a function of 1 variable
In pictures!
Give this as an outofclass exercise.
Spot assignment: When $f$ is a function of just one variable, that is, $f=f(x)$, there is a nice visualization of the Legendre transformation.
The Pfaffian of a function of 1 variable, $f(x)$, is $df=(d f/d x)\,dx\equiv u\,dx$. The Legendre transformation is $$g(x)=f ux=f(x)\left(\frac{df}{dx}\right)_{\text{at } x}x.$$
To find out graphically what the meaning of $g(x)$ is, you will carefully draw and label things on the accompanying figure:
 Pick some particular $x$ value, and label it as '$x$' on the $x$axis.
 Draw a line up to meet the curve at $y=f(x)$.
 Draw a horizontal line to the $y$axis, and mark this height as '$f(x)$' on the $y$axis.
 Draw the tangent line to the function at $(x,f(x))$ that has slope $f'(x)$. Draw the line long enough to cross the $y$axis.
 $u\cdot x = f'(x) x$ is the change in height ($\Delta y$) of the tangent line, as you go from $0$ to $x$ in the horizontal direction. Draw a vertical line segment of length $f'(x)x$ on the diagram in a place to make the connection visually with its meaning. Label the distance '$ux$' on your line segment.
 You have already marked $f(x)$ on the $y$axis for the $x$ value you choose. Now find $g(x)=f(x)ux$ visually, Mark and label that $y$ position as '$g(x)$' on the $y$axis.
Now answer these questions or draw on the diagram as directed.
 How would you describe the relationship of $g(x)$ to $f(x)$?
 For $x=0$, what will $g(0)$ be?
 Choose a couple of other $x$values and find $g(x)$ for each of these values. Use these to sketch out (in another color, but on the same figure) the function $g(x)$.
 Find algebraically the Legendre transformation $g(x)$ of the function
$f(x)=3x^2x+5$.
 Plot with Mathematica the two functions $f(x)$ and $g(x)$ on the same graph. (You can Plot[{function 1, function 2},....]). Print out and attach the plot: Label $f(x)$ and $g(x)$. Pick one $x$ value (not zero) and make the construction above to justify visually the value $g(x)$ for that $x$.
The Legendre transformations of internal energy
Given $f(x,y)$, then our recipe is...$f(x,y)\pm\frac{\partial f}{\partial x}x\equiv g(\frac{\partial f}{\partial x},y)$.
$du=T\,ds  P\,dv$  $u(s,v)$  $\partial u/\partial v = P$ $\partial u/\partial s = T$ 

$h=u+Pv$  $dh = T\,ds + v\,dP$  $h(s,P)$  
$f = u  Ts$  $df = s\,dT  P\,dv$  $f(T,v)$  
$g = u Ts+Pv$  $dg=s\,dT+v\,dP$  $g(T,P)$ 
You can show any of these differentials by differentiating the definition of the function, and using $du=T\,dsP\,dv$, then simplifying.
Problem 87
Gibbs function of a certain gas:$$g=RT\ln\left(\frac{P}{P_0}\right)AP$$
equation of state? (An equation of state is an equation that connects three state variables, such as $P$, $v$, and $T$.)
specific entropy?
specific Helmholz function $f$?
Helmholtz energy  $f$
$$f \equiv u  Ts.$$
The differential is: $$df = dus\,dT  T\,ds.$$
Using $du= TdS P\,dv$ in this,
$$df = s\,dT  P\,dv.$$ Making it look like $f=f(T,v)$ is the most natural form.
Constant $T$ process
Imagine a system in contact with a large, constant temperature reservoir. Under such conditions,
$$[df]_T = P\,dv = \delta w_r.$$
So, the Helmholz energy is apparently equal to (minus) the work done in a reversible, isothermal process.
Since a reversible process is the best we can do, we could say that the Helmholz energy is the maximum mechanical energy to be had from an isothermal process.
In German, work is "Arbeit", and so some texts have used $a(T,v)\equiv f(T,v)$a convention that the IUPAC (International Union of Pure and Applied Chemistry) wants to adopt, but it hasn't caught on yet. They also resolved (1988) to banish the previous term "free energy", yeah, that's where $f$ apparently comes from :<.
Constant $T$, constant $v$ process
Since, $$df = s\,dT  P\,dv.$$ for a process at constant $T$ and constant $v$, it looks like $[df]_{T,v}=0$. But is $f$ a maximum or a minimum here?
The second law can be written: $$dS = \frac{\delta Q_r}{T} \geq \frac{\delta Q}{T}.$$
Imagine that the system is in contact with a reservoir at temperature $T$. Then, in any spontaneous process, the net entropy of the system + the reservoir must increase: $$dS + dS_{res} \geq 0.$$
If the reservoir transfers some heat $\delta Q$ to the system, then $dS_{res} = \delta Q/T$. Subbing this in and rearranging... $$T dS \geq \delta Q.$$
Or, rearranging, and dividing by $n$ for the system... $$0 \geq \delta q  Tds.$$
This is a restatement of the second law: $$ds = \frac{\delta q_r}{T}\geq\frac{\delta q}{T}.$$
The Helmholz energy is $f\equiv uTs$. The differential of this is... $$df = duTdss\,dT$$
Substituting in the first law in the form $du = \delta q  Pdv$: $$\begineq df&=&\delta qPdvTdss\,dT\\ &=& (\delta qTds)Pdvs\,dT \endeq$$
For a constant volume, constant temperature process, the last two terms vanish, $$\[df\]_{v,T}=\delta q Tds \leq 0$$
So, the second law tells us that $f$ can spontaneously decrease (but not increase) when $v$, and $T$ are held constant.
Conclusion: Imagine a system that is held at a constant volume and a constant temperature.
If such a system is initially not in equilibrium, it may change spontaneously to a state in which $f$ is lower. When the system is no longer changing, its Helmholz energy, $f$, is at a minimum, such that $\[df\]_{v,T}=0$. This defines the equilibrium state (isochoric, isothermal system).
We will soon use this to find the precise phases for a van der Waals gas below its critical temperature.
Gibbs energy  $g$
The Gibbs energy (or sometimes Gibbs free energy) is, $$g = u Ts+Pv.$$
Once more using $du=\delta qP\,dv$, we can write the differential as $$\begineq dg &=& du T\,dss\,dT+P\,dv+v\,dP\\ &=& \delta qPdv Tdss\,dT+Pdv+v\,dP\\ &=& (\delta q Tds)s\,dT+v\,dP \endeq$$
Arguing as before, if $T$ and $P$ are held constant (AT LAST: these are the variables we can most easily control in the lab), $$\[ dg \]_{T,P} \leq 0.$$ So such a constrained system can spontaneously move to lower $g$, and an equilibrium system is sitting at a minimum of the the Gibbs energy $g$.
We will soon use this for chemistry: To find things like the equilibrium concentrations of reactants and products in chemical reactions.
Relation to the other thermodynamic potentials... $$\begin{align}g & = u  Ts +Pv\\ &= f + Pv = h  Ts.\end{align}$$
Canonically conjugate variables
Instead of transforming the dependence of the internal energy dependence on $v \rightarrow P$, we could find Legendre transformations of $u$ that would depend on $T$ and $v$, or on $T$ and $P$ instead.
The resulting functions would have differentials that depend on combinations like $T\,ds$, or $s\,dT$, or $P\,dv$, or $v\,dP$, but never combinations like $T\,dP$. We give this kind of relationship a special name:
 $T$ and $S$ are canonically conjugate variables (heatrelated).
 $P$ and $V$ are canonically conjugate variables (mechanical).
Notice that in each pair there is one quantity that is only ever intensive ($T$ and $P$), and one extensive quantity ($S$ and $V$).
We can extend our equations to include nonmechanical forms of work. For example, in an electric circuit, there is work associated with moving a chunk of charge $dQ_e$ (*not* a heatsorry!) through a voltage difference ${\mathcal E}$: $$\delta W = {\mathcal E} dQ_e.$$
 $Q_e$ and ${\mathcal E}$ are canonically conjugate,
 the amount of charge $Q_e$ is extensive, and
 the voltage difference ${\mathcal E}$ is intensive.
Summary