# Legendre Transformation

### From bio-physics-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}

Integration 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 characterizing 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 variables** 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} and eliminate the dependency on chosen variables. \begin{align} \delta g= \sum_{i=1}^p \delta f_i - \sum_{p+1}^n \delta u_i \cdot x_i \end{align}

## Legendre Transformation in Classical Mechanics

In classical mechanics the Hamilton function and the Lagrange function are connected by the Legendre transformation $\dot{q}_i \rightarrow p_i$. \begin{align} H(q,p)=\sum_ip_i\,\dot{q}_i(q,p)-L(q,\dot{q}(q,p)) \end{align} We derived this formula in the article about energy conservation Invariance of Euler-Lagrange Equations and Conserved Quantities, but we can get some more insight by playing with already known relations. \begin{align} \frac{\partial L}{\partial v} = p \end{align} \begin{align} \frac{\partial H}{\partial p} = v \end{align} Notice this functions are complementary in the same way, as the functions above, where we introduced the Legendre transformation. If we hold the generalized coordinates $q$ fixed the variables depend on $v$ only and the partial derivatives can be written as total derivatives. \begin{align} \frac{d L}{d v} = p \end{align} \begin{align} \frac{d H}{d p} = v \end{align} In integral form we have \begin{align} L=\int_0^v p(v') \, dv' \quad \text{with} \quad \delta L = p(v) dv \end{align} \begin{align} H= \int_0^p v(p') \, dp' \quad \text{with} \quad \delta H = v(p) dp \end{align} On the other hand, the change of the product $pv$ is \begin{align} \delta (p\cdot v)= p \cdot dv + v \cdot dp= \delta L + \delta H \end{align} In integrated form this means the area $p\cdot v$ consists of $H+L$.

In other words, for each fixed point $q$, the Hamiltonian $H(p)$ is the Legendre transformation of the Lagrangian $L(v)$ \begin{align} H(p)=p \cdot v(p)-L(v(p)) \end{align}