Cost Function

Hal R. Varian
January, 1992

U-shaped average costs

Undergraduate texts are full of U-shaped average cost curves,  but it is rare to see an accurate plot of one.  Let's try to do this for the cost function c[y]=y^a+F.  First we'll set values for the two parameters, a and F, and then calculate the various curves.  Finally, we'll plot them.

a=2
F=1
c[y_] := y^a + F
AC[y_] := c[y]/y
AVC[y_] := y^a/y
MC[y_] := Evaluate[D[c[y],y]]

Plot[{AC[y],AVC[y],MC[y]},{y,.001,5}]

Let's do the same graph with a=4

a=4
c[y_] := y^a + F
AC[y_] := c[y]/y
AVC[y_] := y^a/y
MC[y_] := Evaluate[D[c[y],y]]
Plot[{AC[y],AVC[y],MC[y]},{y,.001,3}]

Long-run and short-run costs

Let's try to get Mathematica to draw the long-run average cost curve as the envelope of short-run average cost curves.   First we have to compute a short-run average cost function.   Since there is only one variable factor, we don't have to do any minimization---we simply solve for the variable input as a function of the output and the fixed factor.

f[x1_,x2_] := x1^(1/2) x2^(1/2)
solution1=Solve[y==f[x1,x2],x1][[1]]
cs[w1_,w2_,y_,x2_]:= Evaluate[(w1 x1 + w2 x2)/.solution1]
acs[w1_,w2_,y_,x2_] := Evaluate[cs[w1,w2,y,x2]/y]
acs[w1,w2,y,x2]

Now that we have the short run average cost function, we have to solve for the long-run cost function.  To do this we differentiate long-run costs with respect to the long-run factor, and set this derivative equal to zero.  Then we substitute this result into the short-run cost function and divide by output to get the short-run average cost function.

solution2=Solve[D[cs[w1,w2,y,x2],x2]==0,x2][[1]]
cl[w1_,w2_,y_] := Evaluate[cs[w1,w2,y,x2]/.solution2]
acl[w1_,w2_,y_]:= Evaluate[cl[w1,w2,y]/y]
acl[w1,w2,y]

Plot[{acl[1,1,y],acs[1,1,y,5],acs[1,1,y,10],acs[1,1,y,15],
acs[1,1,y,20]},{y,1,30},AxesOrigin->{0,0},PlotStyle->
{Thickness[1/100],Thickness[1/300],
Thickness[1/300],Thickness[1/300],Thickness[1/300]}]

Note how the long-run average cost curve is the envelope of the short-run curves.  [The options in the graph just make things look a little clearer.]

Shephard's Lemma

Take the production function

f[x1_,x2_] := x1 x2
L=w1 x1 + w2 x2 - lambda*(f[x1,x2]-y)
solution=Solve[{D[L,x1]==0,D[L,x2]==0,D[L,lambda]==0},{x1,x2,lambda}][[1]]
c[w1_,w2_,y_] = w1 x1 + w2 x2 /.solution

Now check the derivatives of the cost function with respect to each of the variables:

{D[c[w1,w2,y],y],D[c[w1,w2,y],w2],D[c[w1,w2,y],w1]}

Note that lambda equals marginal cost, and that the derivatives with respect to the price variables gives the conditional factor demands.