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

# Modified Cobb-Douglas 
Production Function and Industry Supply

We recall and slightly modify the modified Cobb-Douglas production function 
that we used in Chapter 7. The first modification introduces a list of a0 values
for the production function. One value results in diminishing returns to scale,
one in constant returns to scale, and the third in increasing returns to scale.
You can select one of the three and execute the workbook to examine the implications.

The second modification is to extend the analysis to the long-run supply curve
that this firm inhabits. The exercises are based on the assumptions that firms' 
costs are not affected by the number of firms or output level in the industry
and that all firms are identical.

## Long-run production function

As before the coefficient for K in this Cobb-Douglas production function is set to
1/4. Select a value from a0List, which is modified slightly. Execute the commands
using the first, second , and third entries, which correspond to decreasing, 
constant, and increasing returns to scale.

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

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  
Execute (ctrl-enter) for results 
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 level 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) )$

Determine the quantity (ies) at which marginal cost equals average cost, 
if they are ever equal. Determine the value of average cost at the relevant
quantity(ies). 

Also, determine the implications for the industry supply. (Beware: When
the firm enjoys increasing returns to scale, this is a trick question.)

### Decreasing returns to scale

When you select the first item in the list of a0 values, execute the commands
in this subsection in order to conduct the analysis.

/* Input. Execute (ctrl-enter) for results */
solve(diff(ltc_small_x/x,x),x); xfirm: float(%[2]);

Use the output to determine the industry price if many indentical firms are free to 
enter or exit a constant-cost industry. 

Describe the industry supply curve. 

What is required to determine the number of firms in this industry?

/* Input. Execute (ctrl-enter) for results */
industryPrice: float(subst(xfirm,ltc_small_x/x));

Discussion
The industry supply curve is a horizontal line whose height is $3.5566. The demand
curve, which determines the quantity in this sort of industry, also determines the
number of firms: n = X/5.6234.

### Constant Returns to Scale

When you select the second item in the list of a0 values, execute the commands
in this subsection in order to conduct the analysis.

/* Input. Execute (ctrl-enter) for results */
solve(diff(ltc_small_x/x,x),x); xfirm: float(%[2]);

Discussion
You can use x^(1 - 1/3) = 8.0395 to determine that x = 22.795. Look at the graph
above and to earlier output to confirm that x = 22.795 is xcritical. That is, 
the firm's average cost falls until x = xcritical and is 1.7548 for all larger 
values. 

The industry supply curve is a horizontal line whose height is $1.7548. The number
of firms is indeterminate: n <= X/22.795. Firms must produce at least 22.795, but
can produce larger quantities.

/* Input. Execute (ctrl-enter) for results */
solve(diff(ltc_small_x/x,x),x); xfirm: float(%[2]);

### Increasing Returns to Scale 

Examine the graph above and explain why no supply curve can exist in this case.

An answer:
The average cost curve slopes downward for all values. This industry will tend to
be monopolized and, therefore, the firm will be a price searcher. A supply curve
can exist only when the firms in an industry are price takers.

## An extension

Suppose that an industry consists of two types of firms:
1. 1000 firms of this type: x = K^(1/4)*L^(1/2) and K0 = 15
2. Any number of firms of this type: x = 0.1*K^(1/4)*L^(1/4)
Suppose further that w = 1 and r = 1 for any employment level in this industry.
This is, suppose that you are examining a constant-cost industry.

An answer.

Begin with the fact that, absent the K0 constraints, all firms would employ 
capital and labor so that K/L = 1/2.

First, suppose that only type 1 firms exist. For L < 15, the production
function is x = 15^(1/4)*L(1/2), so L = x^2/15^(1/2). This implies that 
ltc over this range is 15 + x^2/15^(1/2). The average cost curve reaches its
minimum value 15 x = 15^(3/4), where average cost is about 3.936. For 
prices below this value, no industry exists.

/* Input. Execute (ctrl-enter) for results */
assume(x > 0, L > 0)$
solve(x = 15^(1/4)*L^(1/2),L);
ltcsmall : 15 + x^2/(15^(1/2));
lmc1small: diff(ltcsmall,x); lac1small: ltcsmall/x;
solve(lmc1small=lac1small ,x);
x10 : float(rhs(%[2]));
float(subst(x=x10,lac1small));

Answer, continued
The graph below (not required) shows that the supply curve begins at 
p = 3.936, with x = 7.622,values indicated above.

/* Input. Execute (ctrl-enter) for results */
[x1critical : float(15^(1/4)*30^(1/2)),
lac1critical: float((15 + 30)/x1critical)];
wxdraw2d(yrange=[0,5],
explicit(lmc1small,x,0,x1critical),
explicit(lac1small,x,0,x1critical)
)$

An answer, continued
The expression for the supply curve of each firm can be derived,
for 3.936 <= p <= 4.1747: x = (sqrt(15)/2)*p, (or x = 1.9365*p, approximately) 
so the industry supply over this price range can be written as  X = 1936.5*P. 

/*Input. Execute (ctrl-enter) for results */
solve(p = lmc1small, x); float(%);

An answer, continued
Beyond K = 15 and L = 30, K/L = 1/2, so x = (L/2)^(1/4)*L^(1/2) = (1/2)^(1/4)*L^(3/4). 

/* Input. Execute (ctrl-enter) for results */
solnL1 : float(solve(x = (1/2)^(1/4)*L^(3/4),L));

/* An answer, continued */
The third expression above states L in terms of x. Total cost for quantities larger 
than the critical value is L + L/2 = 1.5*L, so ltclarge = 1.899*x^(4/3). The 
marginal cost based on this is 2.5198*x^(1/3). Setting marginal cost equal to price
yields the supply curve over this range: x = 0.625*p^3, so X = 62.5*p^3.

/* Input. Execute (ctrl-enter) for results */
assume(p > 0)$
ltclarge : rhs(solnL1[3])*1.5;
lmc1large: diff(ltclarge,x);
float(solve(lmc1large=p,x));

An Answer, continued
We can define the firm's inverse supply curve as below.

/* Input. Execute (ctrl-enter) for results */
firm1_inverse_supply: if x < x10 then subst(x=x10,lmc1small) elseif x < x1critical 
                       then lmc1small else lmc1large;

An answer, continued
The graph below shows part of the type 1 firm's supply curve. All firms are
identical, so the industry supply curve is the same height with X = 1000*x.

/* Input. Execute (ctrl-enter) for results */
wxdraw2d(xrange=[0,50],yrange=[0,10],
 xlabel="Firm output", ylabel="$ per unit",
 key= "Supply curve, type 1 firm",
 explicit(firm1_inverse_supply,x,x10,50)
 )$

An answer, continued
For the second type of firms, K/L = 1/3, which implies this relationship
between x and L: x = 0.076*L. This firm has a constant marginal cost, with
lmc2 = 17.548.

For prices below $17.548, these firms do no exit. Given that any number of 
them can enter, and that any one can produce any quantity without affecting
its marginal cost, two results follow: (1) the price cannot rise above
$17.548 and (2) we cannot specify the number of this type of firms. The
number of such firms is both indeterminate and irrelevant to our analysis.

/* Input. Execute (ctrl-enter) for results */
x2: float(((1/3)*L)^(1/4)*L^(3/4)/10.0);
float(solve(x = x2,L));
ltc2 : rhs(%[1])*(4/3);
lmc2: diff(ltc2,x);
float(solve(lmc1large=lmc2,x)); x1max : rhs(%[1]);

An answer, continued
The graph below is still cast in terms of a single firm, but it 
can be scaled up. For quantities below 333,700 (approximately), only 
the first type of firms exist and the supply curve looks like the 
one develope above. If larger quantities are demanded, then the price
equals $17.548.

/* Input. Execute (ctrl-enter) for results */
wxdraw2d(xrange=[0,2*x1max],yrange=[0,1.1*lmc2],
explicit(firm1_inverse_supply,x,x10,x1max),
explicit(lmc2,x,x1max,2*x1max)
)$