# Legendre transformation: non-convex/non-convave functions

The Legendre transformation is used to derive the Hamiltonian from the Lagrangian, and it finds many applications in thermodynamics to convert between the different potentials.

$f(x) \rightarrow g(u)$ with $u = \frac{df}{dx}$

The starting function $f$ needs to be convex (or concave), though. What if $f$ is globally non-convex and non-concave (i.e. $f$ has convex as well as concave sections)? This would lead to a multi-valued $g(u)$, as confirmed in the comments to this question. You could probably split $f$'s domain and get multiple $g$'s, one for each section of $f$, but I've never seen this done in practice. Instead, people just seem to ignore this problem. Is this valid and if so, why does it work?

I'm most interested in the thermodynamic applications:

$U(S)$ is transformed via $T = \frac{\partial U}{\partial S}$ to $F(T) = U - ST$. What if $U(S)$ isn't globally convex (or concave), what are the implications? Can we guarantee that $U(S)$ will always be convex or why is it possible to ignore this issue in practice?

• One deals with such situations by using the more general Legendre-Fenchel transformation (see the article "Convex conjugate" on wikipedia). Morally, this amounts to taking the Legendre tranformation of the convex envelope of your function (so you lose information in this way). This turns out to be the relevant conept in particular in statistical physics. In the latter, nonconvex thermodynamic potentials appear naturally in mean-field theories and, when this occurs, equivalence of ensembles is violated. – Yvan Velenik Apr 15 '15 at 12:37
• You might want to make your comment into an answer, so I can accept it. I'd also be interested what this means for the validity of $F(T)$ as a whole and what you mean by "equivalence of ensembles is violated". – Christian Aichinger Apr 18 '15 at 16:39

As long as long-range interactions (e.g., gravity) are negligible, the internal energy $U$ of a homogeneous system is an extensive quantity. In such a case, the second law of thermodynamics in fact guarantees that $U$ is a convex function of other extensive quantities it depends on, e.g., $S$, $V$, and $N$.

An important observation is that given a thermodynamic system, a tiny part of it should be in equilibrium with the rest. Suppose that we take this tiny part to be negligibly small compared to the entire system, and simply call it "the system." The rest of the entire system acts as a reservoir with some fixed temperature $T_{0}$, pressure $P_{0}$, and chemical potential $\mu_{0}$, so let's call this "the reservoir." When the system and the reservoir are in thermodynamic equilibrium, the second law of thermodynamics demands that the total entropy be maximized. Notice that the change in the total entropy is given by \begin{equation} \Delta S_{\mathrm{total}} = \Delta S + \frac{Q_{\mathrm{reservoir}}}{T_{0}} = \Delta S - \frac{\Delta U + P_{0}\Delta V - \mu_{0}\Delta N}{T_{0}} = -\frac{1}{T_{0}} \Delta \Omega, \end{equation} where $\Omega = U-T_{0}S + P_{0}V-\mu_{0}N$. Hence, maximizing $S_{\mathrm{total}}$ is equivalent to minimizing $\Omega$. Here, $\Omega$ has three, as opposed to four, independent variables because there is a relation between $U$, $S$, $V$, and $N$. Taking the independent parameters to be $S$, $V$, and $N$, we have \begin{equation} \Omega(S,V,N) = U(S,V,N) - T_{0}S + P_{0} V - \mu_{0} N. \end{equation}

A consistency condition is that for an arbitrary $T_{0}$, $P_{0}$, and $\mu_{0}$, there exists a unique minimum of $\Omega(S,V,N)$ with respect to its independent variables, viz., the system should be able to equilibrate with the reservoir. It then follows that the function $U(S,V,N)$ is convex.

So far, $S$, $V$, $N$, and $U(S,V,N)$ are properties of a small system that is a part of a much larger body. However, for a homogeneous system, the internal energy of the entire body must have the same form as any small part of it. Therefore, what I have shown equally holds for an arbitrary homogeneous system.

[Taking the independent variables of $\Omega$ to be $U$, $V$, and $N$ would lead to the concavity of the function $S(U,V,N)$.]

• Could you explain why "the second law of thermodynamics in fact guarantees that U is a convex function of other extensive quantities it depends on"? – Soap Aug 15 '17 at 14:48
• Well, the rest of my answer is an elaboration of that statement. – higgsss Sep 24 '17 at 10:11

The procedure $f(x)\rightarrow g(u)=xu-f(x)$ obtained by inverting $u=f'(x)$ is the "wrong" definition of the Legendre transform and that's what gets you in trouble when the function is not convex or twice differentiable. The correct definition in the one given by Werner Fenchel, namely, $$g(u)=\sup_{x}\ (\ xu-f(x)\ )\ .$$ It is always convex and well defined even if $f$ is not convex and it stays the same if one replaces $f$ by its convex envelope. You can learn all about it in Yvan's book (I don't know why he didn't mention it in his comment above), pp. 480-488.

If you want more thorough references on convexity in statistical mechanics, the canonical ones are:

1. "Convexity in the Theory of Lattice Gases" by Robert Israel. The introduction by Arthur Wightman is a real beauty and in particular it discusses the argument due to Gibbs about how the convexity of $U$ as a function of $S$ essentially follows from the Second Law of Thermodynamics (see also the answer by higgsss).

2. "Convexity: An Analytic Viewpoint" by Barry Simon.