Legendre Transformation
From biophysics wiki
The Legendre transformation aims to replace the dependence of a function e.g. $f(x)$ on $x$ by another variable e.g. $u$. To introduce the concept of Legendre transformation we start with the simple case for functions of one independent variable. We call the derivative of $f(x)$ $u$ and the derivative of $g(u)$ we call $x$. \begin{align} \frac{df}{dx}=u\\ \frac{dg}{du}=x\\ \end{align} Notice, the variables $u,x$ play a somewhat complementary role. The change of $df$ and $dg$ is \begin{align} df=\frac{\partial f}{\partial x} \, dx=u \, dx\\ dg=\frac{\partial g}{\partial u} \, du=x \, du\\ \end{align} We need one further building block to make the argument. The change in $ux$ is \begin{align} d(ux)=u \, dx + x \, du = df + dg \end{align}
Integratition of this equation give the Legendre transformation in one variable $f(x) \rightarrow g(u)$ \begin{align} g(u)=u \cdot x(u) - f[x(u)] \end{align} depending on the physical problem we might choose $-u=f'(x)$, then we get \begin{align} g(u)=f[x(u)]-u \cdot x(u) \end{align}
This transformation has a geometric interpretation. The function $f(x)=x^2$ characterises the blue curve below

instead of characterising this curve by the variable $x$ we can also use the slope $u(x)=df/dx$. The Legendre transformation of $f(x)$ describes the same curve as a function of the slope. Let's plug in $f'=2x=u$ \begin{align} g(u)=u \cdot \frac{u}{2} - \left( \frac{u}{2} \right)^2=\frac{u^2}{4} \end{align}
The Legendre transformation in more varialbes is \begin{align} g(x_1,x_2, \dots,x_{p},u_1,u_2,\dots, u_{n-p})=f(x_1,x_2, \dots ,x_n)- \sum_{p+1}^n u_i \cdot x_i(u) \end{align} with \begin{align} u_i=\frac{\partial f}{\partial x_i} \end{align} where we eliminated the dependence of $g$ on $x_{p+1},\dots, x_n$.
Let's make this more clear by looking at the change in $g$ \begin{align} \delta g(x_1,x_2, \dots,x_{p},u_1,u_2,\dots, u_{n-p})= \delta f(x_1,x_2, \dots ,x_n)- \sum_{p+1}^n \delta u_i \cdot x_i+u_i \cdot \delta x_i \end{align} The change in $f$ is nothing but $\sum_i u_i \cdot \delta x_i$ \begin{align} \delta g= \sum_{i=1}^n u_i \cdot \delta x_i - \sum_{p+1}^n \delta u_i \cdot x_i+u_i \cdot \delta x_i \end{align} we see, that some terms with indices $p+1, \dots , n$ cancel \begin{align} \delta g= \sum_{i=1}^p u_i \cdot \delta x_i - \sum_{p+1}^n \delta u_i \cdot x_i \end{align}