Utility Maximization

Cobb-Douglas system

Let's calculate the factor demands  for the Cobb-Douglas utility function.

u[x1_,x2_] := x1*x2
L= u[x1,x2]- lambda*(p1 x1 + p2 x2 - m)
firstOrder={D[L,x1]==0,D[L,x2]==0,D[L,lambda]==0}
solution=Solve[{D[L,x1]==0,D[L,x2]==0,D[L,lambda]==0},
   {x1,x2,lambda}][[1]]

Here's the indirect utility function:

v[p1_,p2_,m_] := Evaluate[u[x1,x2]/.solution]
v[p1,p2,m]

Now check Roy's identity:

{-D[v[p1,p2,m],p2]/D[v[p1,p2,m],m],-D[v[p1,p2,m],p1]/D[v[p1,p2,m],m]}

Here are plots of the indirect utility function with respect to y and (p1,p2):

Plot[v[1,1,m],{m,1,50}]

ContourPlot[v[p1,p2,10],{p1,1,10},{p2,1,10}]

To find the expenditure function, we solve the indirect utility function for m.

solution=Solve[v[p1,p2,m]==u,m][[1]]

e[p1_,p2_,u_] = Evaluate[m/.solution]

To find the money metric utility functions, just substitute:

m[p1_,p2_,x1_,x2_] := e[p1,p2,u]/.{u->u[x1,x2]}
m[p1,p2,x1,x2]

Here's the indirect money metric utility function:

mu[p1_,p2_,q1_,q2_,m] := e[p1,p2,u]/.{u->v[q1,q2,m]}

mu[p1,p2,q1,q2,m]