Is it possible to compute symbolically the Legendre transform of a function in Mathematica?
I find no LegendreTransform function.
Is it possible to compute symbolically the Legendre transform of a function in Mathematica?
I find no LegendreTransform function.
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] & *)