Exchange

Hal Varian
January 1992

Edgeworth Box

Our first challenge is to draw an Edgeworth box using Mathematica.  We'll need utility functions and endowments, so:

indiffA=ContourPlot[5Log[x1] + 5Log[x2],{x1,0.5,9},{x2,0.5,9},
   ContourShading->False]
indiffB=ContourPlot[3 Log[10-x1] + 7 Log[10-x2],{x1,0.5,9},{x2,0.5,9},
   ContourShading->False]

Let's plot the contract curve in this box.  The set of points were the MRS of agent A equals the MRS of agent B is given by

FOCcontractCurve=D[x1^5 x2^5,x2]/D[x1^5 x2^5,x1] -
D[(10-x1)^3 (10-x2)^7,x2]/D[(10-x1)^3 (10-x2)^7,x1]

Solve[solution==0,x2][[1]]

contractCurve1=Plot[15 x1/(35-2x1),{x1,0,10}]
Show[{indiffA,indiffB,contractCurve1}]

Sometimes it is hard to find an explicit formula for the contract curve.  But we can still plot it as an implicit function using ContourPlot.  We simply plot one contour: the contour where the equation describing the contract curve is satisfied.

contractCurve2=ContourPlot[FOCcontractCurve,{x1,.5,9},{x2,.5,9},
Contours->{0},
ContourShading->False,ContourSmoothing->True]

[In my version of Mathematica I get an extra contour; I assume that this is a bug.] Finally, we put it all together:

Show[indiffA,indiffB,contractCurve2]

Solving for equilibrium

If the equations describing the demand functions are simple enough, we can solve algebraically for the equilibrium.  But in more complicated cases, we'll have to solve numerically.  Here agent A has Cobb-Douglas demand parameter a, agent B has parameter B, and we set price 2 equal to 1.

Simplify[Solve[a (p*wA1 + wA2)/p1 + 
b*(p*wB1 + wB2)/p==wA1+wB1,p][[1]]]

We'll solve a CES case numerically.  Let the CES parameters be 1 and 2, and let each agent have 10 units of each good.  It's a good idea to plot the equation first to see what the demand function looks like.

equationToSolve=
        (p 10 + 10) p^(-2) /(p^(-1) + 1) + 
        (p 10 + 10) p^(-3) /(p^(-2) + 1) - 20
Plot[ equationToSolve,{p,.1,10}]

Hmm.  Looks like the solution is p=1; let's check:

FindRoot[ (p 10 + 10) p^(-1) /(p^(-1) + 1) + 
        (p 10 + 10) p^(-2) /(p^(-2) + 1) - 20,{p,.5}]

Yep.  Let's go back and look at equationToSolve again...

Simplify[equationToSolve]

That makes it pretty obvious that p=1 is a solution...can yous see why?