# The Cobb-Douglas Utility Function

## Basics

This exercise set follows the text's development with the Cobb-
Douglas utility function replacing the CES function.

kill(all)$ ratprint:false$
u(x,y,a):=x^a*y^(1-a);

Set a = a0 = 1/4 and graph the utility function for x and y 
values from 0 to 50.

/*Input. Execute (ctrl-enter) for results */
a0 : 1/4$  [xmax, ymax]:[50,50]$      
umax : u(xmax, ymax, a0)$
wxdraw3d(color=green, 
xlabel = "x", ylabel = "y", zlabel = "u", 
ztics={0,0.25*umax,0.5*umax,0.75*umax,umax},
xtics={0,0.25*xmax, 0.5*xmax,0.75*xmax ,xmax},
ytics={0, 0.25*ymax,0.5*ymax,0.75*ymax , ymax},
explicit(u(x,y,a0),x,0.01,xmax,y,0.01,ymax ))$

The graph below rotates the graph.

with_slider_draw3d(h, makelist(360*i/25,i,1,25),
view = [50,h], color=green, 
xlabel = "x", ylabel = "y", zlabel = "u", 
ztics={0,0.25*umax,0.5*umax,0.75*umax,umax},
xtics={0,0.25*xmax, 0.5*xmax,0.75*xmax ,xmax},
ytics={0, 0.25*ymax,0.5*ymax,0.75*ymax , ymax},
explicit(u(x,y,a0),x,0.01,xmax,y,0.01,ymax ),
dimensions=[480,480])$

## Indifference Curves

Indifference curves are contour lines projected onto the base
of a graph. Copy the graph that you created above and add
"contour=surface" to it. Change the view to [50, 330].

/*Input. Execute (ctrl-enter) for results */
wxdraw3d(color=green, view=[50,330],
xlabel = "x", ylabel = "y", zlabel = "u", 
contour=surface, dimensions=[480,480],
ztics={0,0.25*umax,0.5*umax,0.75*umax,umax},
xtics={0,0.25*xmax, 0.5*xmax,0.75*xmax ,xmax},
ytics={0, 0.25*ymax,0.5*ymax,0.75*ymax , ymax},
explicit(u(x,y,a0),x,0.01,xmax,y,0.01,ymax ))$

Project the contour lines onto the base, still showing the
surface.

/*Input. Execute (ctrl-enter) for results */
wxdraw3d(view = [50,330], color=green, 
xlabel = "x", ylabel = "y", zlabel = "u", 
contour=base, dimensions=[480,480],
ztics={0,0.25*umax,0.5*umax,0.75*umax,umax},
xtics={0,0.25*xmax, 0.5*xmax,0.75*xmax ,xmax},
ytics={0, 0.25*ymax,0.5*ymax,0.75*ymax , ymax},
explicit(u(x,y,a0),x,0.01,xmax,y,0.01,ymax ))$

Set "contour=map" to focus on the indifference curves in the 
x-y plane.

/*Input. Execute (ctrl-enter) for results */
wxdraw3d(
contour=map,
ztics={0,0.25*umax,0.5*umax,0.75*umax,umax},
xtics={0,0.25*xmax, 0.5*xmax,0.75*xmax ,xmax},
ytics={0, 0.25*ymax,0.5*ymax,0.75*ymax , ymax},
explicit(u(x,y,a0),x,0.01,xmax,y,0.01,ymax ))$

Draw the isoquants for any two of the utility levels shown above.
Use implicit(...) to draw the graph in wxdraw2d.

/*Input. Execute (ctrl-enter) for results */
wxdraw2d(xlabel="x",ylabel="y",key="u=10",
implicit(u(x,y,a0)-10,x,0,xmax,y,0,ymax),
key="u=20",color=green,
implicit(u(x,y,a0)-20,x,0,xmax,y,0,ymax)
)$

Use solve (u(x,y,a)-y, y) to derive an expression for y 
that can be used to generate isoquants.

/*Input. Execute (ctrl-enter) for results */
assume(x>0,y>0,a>0,a<1,u>0)$ declare(a,noninteger)$
solny: solve(u(x,y,a)-u,y);

Create a function yIC(u,x,a) that can generate indifference
curves, using the output from solny above.

/*Input. Execute (ctrl-enter) for results */
yIC(u,x,a):=''( rhs(solny[1]));

Graph the two indifference curves that you graphed above,
this time using explicit( ). Set yrange=[0,50].

/*Input. Execute (ctrl-enter) for results */
wxdraw2d(xlabel="x",ylabel="y",key="u=10",yrange=[0,50],
explicit(yIC(10,x,a0),x,0,xmax),
key="u=20",color=green,
explicit(yIC(20,x,a0),x,0,xmax)
)$

The (negative of the) slope of an indifference curve is the marginal 
rate of substitution (mrs). Confirm that the Cobb-Douglas function 
is homothetic: mrs = (a/(1-a))*(y/x).

/*Input. Execute (ctrl-enter) for results */
/*dy/dx = */  mrs = -diff(yIC(u,x,a),x);
subst(u(x,y,a),u,%);

The graphs above indicate that, for the selected utility levels,
the marginal rate of substitution on any indifference curve becomes 
quite small as the amount of x consumed becomes large. 

Use the limit command to confirm that mrs approaches 0 as x becomes 
large for a given utility level, u0 -- that is, as we move to the 
right along an indifference curve.

/*Input. Execute (ctrl-enter) for results */
limitRight: limit(-diff(yIC(u0,x,a),x),x,inf);

In the other direction, mrs appears to become quite large as 
we move to the northwest along any indifference curve. Applying
the limit command does not give a direct value for the limit of 
the mrs function, but its value can be discerned. The term
outside the parenetheses is (a/1-a)*u0^(1/(1-a)), a positive 
constant. The term that approaches a limit is x^(1/(a-1)), and
a - 1 < 0, so this value becomes quite large as x approaches 
zero.

/*Input. Execute (ctrl-enter) for results */
limitLeft: limit(-diff(yIC(u0,x,a),x),x,0);

Select any value for u0. Let a be any value between 0 and 1. Confirm
that the limiting mrs equals infinity.

/*Input. Execute (ctrl-enter) for results */
subst([a=0.7,u0=3],limitLeft);
limit(x^-(10/3),x,0);

Draw three indifference curves, for three different consumers, given these
values of a: 1/4, 1/2, and 3/4. For each one, let u = 10 (remembering that 
the number has no interpretation--we cannot say that the three are equally
well off). Let the values of x and y range from 0 to 30.

/*Input. Execute (ctrl-enter) for results */
wxdraw2d(xlabel="x",ylabel="y",key="uA=10",yrange=[0,20],
explicit(yIC(10,x,1/4),x,0,30),
key="uB=10",color=green,
explicit(yIC(10,x,1/2),x,0,30),
key="uC=10",color=black,
explicit(yIC(10,x,3/4),x,0,30)
)$

The graph drawn below provides an animated representation of
a representative indifference curve as a ranges from 0.1 to
0.1 in increments of 0.1.

with_slider_draw(a, makelist(.1*i,i,1,9),
yrange=[0,30], key=concat("u=10,a=",string(a)),
explicit(yIC(10,x,a),x,0,30)
)$