## Legendre Transform

The Legendre transform describes a function - in the normal Legendre case, a convex function (but for the generalized case, see [1]) - as a function of its supporting hyperplanes. In the case of a 2D function these are supporting lines. The supporting lines are the lines that just touch the function. These lines do not intersect the function anywhere else if the function is convex.

Why is the Legendre transform interesting? It is basically just writing down a function in a different manner. The Legendre transform is particular useful in the situation that the derivatives of a function are easier to describe than the function itself. For a nice introduction see [2]. Intuitively, we map from points to , with the slope and some value so that we can recover and (see below for the exact definition).

In the following example, we will get get the Legendre transform of the function:

And in particular, .

The Legendre transform is defined (with proper domain ) by:

In the animation below the first curve that is drawn is the convex function at hand. Subsequently we will be performing a for loop in which we draw lines over different slopes . The curves depict the difference between and the line . The maximum difference is found by , the supremum operation, which sweeps over all . This difference is visualized through a single peak with height . Last, the Legendre transform is drawn as for all different slopes we try.

To refresh the animation, press F5.

I hope the Legendre transform is a little bit less mysterious after you’ve seen this animation. The animation has been created by making use of the vis.js library. The source code can be found at legendre.js.

## Physics

A very common example of the Legendre transform in physics is the one that transform the Lagrangian into the Hamiltonian. The Lagrangian describes a system in generalized position and velocity coordinates:

The Hamiltonian is the Legende transform of the Laplacian:

The Lagrangian is the function of above. The sum (or actually, the inner product ) is replacing the term.

## Probability theory

The rate function is defined as the Legendre transform of the scaled cumulant generating function of a random variable . The scaled cumulant generation function of $A_n$ is defined by the limit:

And the Gärtner-Ellis theorem establishes under some conditions the rate function:

This theorem is more general than Cramér’s theorem, which is only valid for independent and identically distributed random variables.

Now you know what a Legendre transform entails, you might start to notice it in the most surprising places! For example in clustering multivariate normal distributions [3]!

- Legendre-Fenchel Transforms in a Nutshell, a good explanation of the Legendre-Fenchel generalization of the Legendre transform
- Making Sense of the Legendre Transform
- Clustering Multivariate Normal Distributions