kill(all)$ ratprint:false$ fpprintprec:5$

# Deriving Cost Curves from a Slightly Modified
Cobb-Douglas Production Function

Any homogeneous production function for which all input levels can be varied
generate monotonic long-run cost curves. Those with constant returns to scale
generate horizontal cost curves, those with increasing returns to scale
generate downward-sloping cost curves, and those with decreasing returns to 
scale generate upward-sloping curves.

Suppose, however, that operation of a firm involves a minimum amount of some
input. In our simple model, make that input capital (K). This workbook derives
the implied production function and cost curves in the long run and in the 
short-run.

## Long-run production function

The coefficient for K in this Cobb-Douglas production function is set to
1/4. Select a value from a0List. This is the coefficient of L. You may 
specify other values, but some difficulties with solve( ) might result.

kill(all)$ ratprint:false$ fpprintprec:5$
xFunction:K^(1/4)*L^a;
a0List: [ 1/4, 3/8, 1/2, 5/8,  3/4, 7/8 ]$   
     /* Select a value from the list*/
a0: a0List[2]$

print("The resulting production function is ",subst(a=a0,xFunction))$

Confirm that the optimal input mix if both K and L are fully variable is 
K/L = (1/(4*a)*(w/r), where w is the wage rate and r is the rental rate for capital.

/*Input. Execute (ctrl-enter) for results */
solnKL: solve(diff(xFunction,L)/diff(xFunction,K) = w/r,K)[1];

Let w = 1 and r = 1 and confirm that the optimal input mix is K/L = 1/(4*a0).

/*Input. Execute (ctrl-enter) for results */
solnKL1 : subst([w=1,r=1, a = a0], solnKL);

Suppose for now that K is freely variable. To derive a long-run cost curve,
substitute the optimal input mix into the production function and express L
in terms of x. 

/*Input. Execute (ctrl-enter) for results 
Let x be the production function when the optimal input mix is 
imposed. Set the expression equal to that name and solve for L.
To avoid a dialog with Maxima, assume x > 0. The float( ) command
is optional*/

assume(x>0)$
solnList: float(solve(rhs(solnKL1)^(1/4) * L^a0 = x, L))$

/* The use of transpose(matrix( )) to create an output table is not required,
   but it facilitates reading the individual items.*/

solnLx: transpose(matrix(solnList));

/*For the values in the list, the output list consists for some
  complex solutions and a single real solution. To avoid having 
  to count the solution and select the value to use in later work,
  we create a named expression listLength to use in the proper place.
  This is not a general rule, but it works for the selected values 
  of a0 and the selected exponent of K. */

listLength: length(solnList);

## Long-run cost

### Total cost curve

Continue to suppose that K is freely variable. Insert the condition named solnKL1
and the real solution above into the expression for cost, given that w = r = 1.
Label the resulting expression ltc_large_x, since it will refer to cases in which
the optimal K exceeds the specified minimum value.

/*Input. Execute (ctrl-enter) for results /*An answer
The value used is taken from a matrix, so the row and column must 
be specified. 
*/
ltc_large_x: subst([solnKL1, solnLx[listLength,1] ],1*K + 1*L);
/*  Using solnList(listLength) would also work. */
[solnLx[listLength,1], solnList[listLength]  ];

Suppose, however, that operating a firm requires K >= 10 units. For very small output
rates L < the optimal value will be employed. That is, K = (3/5)*L becomes 
K >= (1/(4*a)*L over an output range. Determine the upper end of that range. Label 
the resulting value xcritical. It will be used below.

/*Input. Execute (ctrl-enter) for results */
xcritical: float(subst([K=10,a=a0, L=10*a0/(1/4)],xFunction));
ltc_critical: 10 + 10*a0/(1/4);

Deriving the cost expression for L < 15 is relatively simple. Replace
K with 10 in the production function and solve for L as a function of x.
Label the resulting expression solnLsmall.

/*Input. Execute (ctrl-enter) for results 
 For some values of a0, the result of solve() is a list of more
 than one item. As before, the last of these items is real, for the
 values used above. We use the name solnLsmall twice, so that the 
 second assignment, to single item, replaces the first, to a list.*/
solnLsmall: float(solve(10^(1/4)*L^a0 = x,L));
length(solnLsmall); solnLsmall: 
solnLsmall[length(solnLsmall)];

To derive the cost expresssion substitute solnLsmall into the cost 
expression (10 + 1*L). Label this expression ltc_small_x.

/*Input. Execute (ctrl-enter) for results */
ltc_small_x:subst(solnLsmall,10 + 1*L);

Plot these two cost curves and label them.

/*Input. Execute (ctrl-enter) for results */

wxdraw2d(
 xlabel = "x", ylabel = "$", line_width = 2,
 key = "Cost, small x values", explicit(ltc_small_x,x,0,2*xcritical),
 color = red, key = "Cost, large x values",
 explicit(ltc_large_x,x,0,2*xcritical)   )$

Write an if...then...else command that defines ltc.

/*Input. Execute (ctrl-enter) for results */
ltc: if x < xcritical then ltc_small_x else ltc_large_x;

Graph the resulting expression.

/*Input. Execute (ctrl-enter) for results */
wxdraw2d(
xlabel="x", ylabel="$",key="Long-run total cost",
explicit(ltc,x,0,2*xcritical));

## Per-unit cost curves

Graph the average cost curve.

/*Input. Execute (ctrl-enter) for results */
lac_critical : ltc_critical/xcritical;
wxdraw2d(yrange=[0,2*lac_critical], xlabel="x",ylabel="$ per unit",
key = "Long-run average cost", explicit(ltc/x, x, 0, 2*xcritical)
)$

Create expressions for the marginal product of labor for the expressions
ltc_small_x and ltc_large_x. Then create an if...then...else expression for 
the firm's long-run marginal cost curve.

/*Input. Execute (ctrl-enter) for results */
[diff1, diff2]: [diff(ltc_small_x,x), diff(ltc_large_x,x)];
lmc: if x < xcritical then diff1 else diff2;

Determine the limit of the average cost curve as x becomes large.

/*Input. Execute (ctrl-enter) for results */
ltc_large_x/x; limit(%, x,inf);

Copy the graph above (the graph of the long-run average cost curve) and 
paste it into a cell below. Then add the long-run marginal cost curve and
plot the two expressions.

/*Input. Execute (ctrl-enter) for results */
/*The vertical line showing xcritical is not required */
wxdraw2d(user_preamble="set key bottom",
 yrange=[0,3*lac_critical], xlabel="x",ylabel="$/unit", 
 line_type=dots,points_joined=true,
 points([[xcritical,0],[xcritical,subst(x=xcritical,max(diff1,diff2))]]),
/* 
Note that commands can be entered directly into draw( ) -- in this case
the subst( ) command and the max( ) command are used. 
*/
 line_type=solid,line_width=2, key ="Long-run average cost",
 explicit(ltc/x, x, 0, 2*xcritical), color = red, 
 key = "Long-run marginal cost",explicit(lmc,x,0,2*xcritical) )$

## Short-run cost

Suppose that K = 20 (or some other number above the minimum imposed above).
Now the firm, in the short run, can employ neither more nor less than this
amount of capital, so its long-run costs are 20 + 1*L, where L is the 
required employment level for a given input. The mechanics of determining
the cost curves are much the same as above.

Begin by killing the expression for x.

kill(x)$

Confirm that in the short run, L = 0.166*x^2 and derive the implied short-run
total cost curve. Label the expression for the short-run total cost curve stc.

/*Input. Execute (ctrl-enter) for results */
newK : 20$
assume(x>0)$ declare(a,noninteger)$
subst([a=a0,K=newK],xFunction);
solnLsr: float(solve(%=x,L));
/* The print( ) command is not required. It serves to distinguish the expression
   from the list above it. */
print("Short-run total cost curve: ", stc: subst(solnLsr[length(%)],20 + 1*L))$

Derive and plot the short-run average cost curve, marginal cost curve, 
average variable cost curve, and average fixed cost curve.

/*Input. Execute (ctrl-enter) for results */
newx: float(subst([K=newK, a=a0, L = 4*a0*newK],xFunction));
new_sac_critical: (newK + 4*a0*newK)/newx;

/*Input. Execute (ctrl-enter) for results */
wxdraw2d(user_preamble="set key bottom",
xlabel="x",ylabel="$ per unit", yrange=[0,1.5*new_sac_critical],
line_width = 2, key="Average total cost curve", explicit(stc/x,x,0,2*newx),
color=red, key="Marginal cost curve",explicit(diff(stc,x),x,0,2*newx),
color=orange, key = "Average variable cost curve",explicit((stc-20)/x,x,0,2*newx),
color=black, key="Average fixed cost curve",explicit(20/x,x,0,2*newx),
dimensions=[640,480])$

This workbook has used one value from a0List. You should repeat it other
values. 