6

Is it possible to compute symbolically the Legendre transform of a function in Mathematica?

I find no LegendreTransform function.

glS
  • 7,623
  • 1
  • 21
  • 61
a06e
  • 11,327
  • 4
  • 48
  • 108

1 Answers1

9

I wrote a small function to compute Legendre transform of differentiable univariate functions.

LegendreTransform[f_]:=Module[{x,y,sol,expr},
    sol = Solve[f'[x] == y, x, Reals];
    expr = FullSimplify[First[y x - f[x]/.sol], {x,y}\[Element]Reals];
    Evaluate[expr/.y->#]&]

Some examples:

LegendreTransform[-Log[#] &]
(* -1 + Log[-(1/#1)] & *)

LegendreTransform[Exp[#] &]
(* ConditionalExpression[(-1 + Log[#1]) #1, #1 > 0] & *)
a06e
  • 11,327
  • 4
  • 48
  • 108