CM 210- Fall 2018. Class notes for solving Legendre Transforms in HW#1
October 31, 2018

Here is a package that does the Legendre transform of most reasonable functions f. I call it  LegendreTr[f_,m_]. The parameter m is the number of roots you expect the derivative equation to have. One can alsways start with m=1. One can then try m=2 etc.... We can use it to invert the LT as well.....

LegendreTr[f_,m_]:=Block[{}, leg= x y - f; der=D[leg,x];xsol=x/.Solve[der==0,x]; Do[g[j]= Simplify[(leg/.x->xsol[[j]]),Assumptions-> Element[g[j],Reals]],{j,1,m}];Return[Table[g[j]/.y->x,{j,1,m}]]]

a) Here is one simple example. It is the solution to  Problem 4(a,b)

f0=Exp[x -1]

lf0=Simplify[LegendreTr[f0,1][[1]],Assumptions->Element[x,Reals]]

Here we got the logarithm with its complex 
integers. Set C(1)=0 and proceed next.

f0= x Log[x]

Simplify[LegendreTr[f0,1][[1]],Assumptions->Element[x,Reals]]

Next we do problem $.c

Clear[f0]

f0=x^2/2-x^3/3

lf0=LegendreTr[x^2/2-x^3/3,2]

G1=lf0[[1]]

G2=lf0[[2]]

G1curvature=Simplify[D[G1,{x,2}]]

G2curvature=Simplify[D[G2,{x,2}]]

Plot[{G1,G1curvature},{x,-2,1/4},PlotStyle->{Red,Blue}]

Plot[{G2,G2curvature},{x,-2,1/4},PlotStyle->{Red,Blue}]

This shows us that G1 is concave upwards, while G2 is concave downwards

Next we do another LT on G1 and G2!

LG11=LegendreTr[G1,1]

LG12=LegendreTr[G1,2]

LG21=LegendreTr[G2,1]

LG22=LegendreTr[G2,2]

Here we see that only one LT exists for G1 and G2. Let us plot these and compare with original function f0

Plot[{f0+.2,LG11,LG21},{x,-2,2},PlotStyle->{Red,Blue,Magenta}]

Here we see that the original function f0 (Red) is recovered by piecing together the LT of G1 (Blue) and G2 (Magenta). I have shifted the f0 upwards by a bit to see the differences. This shows the difficulty of solving the LT’s of   non-concave functions uniquely.