Legendre Transform Calculator

Stephanie Ben-Joseph headshot Stephanie Ben-Joseph

Introduction

The Legendre transform is a fundamental tool in mathematics and physics that converts a convex function into its dual representation. It is widely used in fields such as classical mechanics, thermodynamics, and optimization. This calculator allows you to compute the Legendre transform of a single-variable convex function at a specified slope value.

Understanding the Legendre Transform

Given a real-valued convex function f(x), the Legendre transform f^*(p) is defined as:

f^*(p) = supx px - f(x)

This means we look for the value of x that maximizes the expression px - f(x). Intuitively, this corresponds to finding the point where the line with slope p is tangent to the graph of f. The Legendre transform then records the intercept of this tangent line.

Mathematical Characterization

For differentiable convex functions, the maximizing x satisfies the condition:

f'(x) = p

Once this x is found, the Legendre transform value is computed as:

f^*(p) = px - f(x)

How to Interpret the Results

The output f^*(p) represents the value of the Legendre transform at slope p. This value can be seen as the support function of the convex function f and provides a dual perspective by switching from the variable x to the slope p.

In physics, this corresponds to changing from a coordinate-based description to a momentum-based one. In optimization, it helps analyze dual problems and understand sensitivity to changes in parameters.

Worked Example

Consider the quadratic function:

f(x) = x22

Its derivative is:

f'(x) = x

Setting f'(x) = p gives x = p. Substituting back, the Legendre transform is:

f^*(p) = pp - p22 = p22

This matches the well-known result for the Legendre transform of a quadratic function. Using the calculator, you can input f(x) = x^2/2 and p = 1 to verify this output.

Comparison Table: Legendre Transform vs. Related Transforms

Transform Domain Purpose Key Property
Legendre Transform Convex functions Convert function to slope/momentum domain Involution for strictly convex, lower semicontinuous functions
Fourier Transform Integrable functions Convert time/space domain to frequency domain Linear and invertible
Laplace Transform Functions of exponential order Analyze system dynamics and differential equations Transforms convolution into multiplication
Fenchel Conjugate Convex functions Generalization of Legendre transform in convex analysis Supports duality in optimization

Limitations and Assumptions

Frequently Asked Questions

What is the purpose of the initial x guess?

The initial guess helps Newton's method start close to the solution of f'(x) = p. A good guess improves convergence speed and accuracy.

Can I use this calculator for non-convex functions?

The Legendre transform is not generally defined for non-convex functions. Using such functions may produce incorrect or undefined results.

Why does the calculator use Newton's method?

Newton's method efficiently solves the equation f'(x) = p by iteratively improving the estimate for x. It requires the first and second derivatives of f.

Is the Legendre transform reversible?

Yes, for strictly convex and lower semicontinuous functions, applying the Legendre transform twice returns the original function.

Can I save or export the results?

This calculator provides a "Copy Result" button to copy the computed x and f^*(p) values for your records. CSV export is not currently supported.

How does this relate to physics?

In classical mechanics, the Legendre transform converts the Lagrangian (function of position and velocity) into the Hamiltonian (function of position and momentum), enabling analysis of conservation laws and system dynamics.

Enter function and slope.

Embed this calculator

Copy and paste the HTML below to add the Legendre Transform Calculator – Compute Convex Function Duals to your website.