# A CES Production Function

This set of exercises illustrates some of the production concepts 
that the text treats. It uses a CES production function, which is
entered in the next cell.

This function differs from the one used for utility in two ways.
First, units now matter. If x doubles, this means that twice as 
many units per time period are produced. Second, we have added 
a term tau to the exponent of the function. This additions allows
for the function to have increasing, constant, or decreasing returns to 
scale.

x(K,L,a,b,tau):=(a*K^-b+(1-a)*L^-b)^-(tau/b);

## Economies of Scale

Confirm that the CES production function exhibits returns to scale that 
(1) are determined by tau's value and (2) are independent of the scale
of production.

/*Input. Execute (ctrl-enter) for results */
(a*(m*K)^-b+(1-a)*(m*L)^-b)^-(tau/b)/(a*K^-b+(1-a)*L^-b)^-(tau/b);
/*In this case ratsimp does not help. Try it. Often, some experimentation
  is required to manipulate and simplify expressions. */
radcan(%);

### A 3d graphical view

Given this result, we cannot examine issues related to variable returns to scale.
We can, however, look at production functions that exhibit increasing, decreasing,
and constant returns to scale. First, create three "scanrios" and label them
decreasing, constant, and increasing. Set tau = 0.5 in the first, tau = 1.0 in 
the second, and tau = 2.0 in the third. For all, let a = 0.3 and b = 0.7.

Then use the command wxdraw(decreasing,constant, increasing, columns=3,
dimensions=[800,400]); to plot the three production surfaces. What difference(s)
do you observe? Hint: Look at the edges of the third graph, where K = 1 or L = 1
and, of course, at the values on the vertical axis.

/*Input. Execute (ctrl-enter) for results */
/*The view, labels and tics options not required.*/
decreasing:gr3d(xtics={0,25,50},xlabel="K",view=[60,300],
 ytics ={0,25,50},ylabel="L",zlabel="x",
explicit(x(K,L,0.3,0.7,0.5),K,1,50,L,1,50))$
constant:gr3d(xtics={0,25,50},xlabel="K",view=[60,300],
 ytics ={0,25,50},ylabel="L",zlabel="x",
explicit(x(K,L,0.3,0.7,1.0),K,1,50,L,1,50))$
increasing:gr3d(xtics={0,25,50},xlabel="K",view=[60,300],
 ytics ={0,25,50},ylabel="L",zlabel="x",
explicit(x(K,L,0.3,0.7,2.0),K,1,50,L,1,50))$

wxdraw(decreasing,constant, increasing, columns=3,
dimensions=[800,400]);

Copy one of the gr3d commands into the next cell, remove the label, 
and replace gr with draw. Executing this command creates a graph outside 
of wxMaxima that you can rotate and resize. Do this with each of the 
three values of tau and describe any
aspects of the surfaces that become apparent upon rotation.

/*Input. Execute (ctrl-enter) for results */
draw3d(xtics={0,25,50},xlabel="K",
 ytics ={0,25,50},ylabel="L",zlabel="x",
 explicit(x(K,L,0.3,0.7,2.0),K,1,50,L,1,50),
 dimensions=[480,480])$

An answer:
Inreasing returns to scale results in an expression that is not strictly 
convex. Graph the relationship between L and x when K = L/2, tau = 2.0, and
the other parameters are as above. The nonconvexity becomes quite apparent.

### A 2d graphical view

Select a K/L ratio and replace K with the implied expression in terms of L.
Graph the resulting function for L = 0 through L = 5.

/*Input. Execute (ctrl-enter) for results */
/*An answer, with K/L = 1/2 */
wxdraw2d(xlabel = "L",ylabel="x, when K = L/2",
explicit(x(L/2,L,0.3,0.7,2.0),L,0,5)
)$

Execute the next cell and activate the scroll button or scroll bar icon,
or use the scoll key on your mouse. Before beginning to scroll, click on
the graph. It will be highlighted, indicating that it is ready for animation.

with_slider_draw(
tau, makelist(i/4.0,i,1,8),
xlabel = "L",ylabel="x, when K = L/2",
explicit(x(L/2,L,0.3,0.7,tau),L,0,5),
title = concat("tau =", string(tau))
)$

## Isoquants

Copy one of the gr3d scenarios to the next cell and change
it to a wxdraw3d command. Add a contour=both option.

/*Input. Execute (ctrl-enter) for results */
wxdraw3d(view=[60,300],xtics={0,25,50},xlabel="K",
 ytics ={0,25,50},ylabel="L",zlabel="x", color=gray,
contour=both,
explicit(x(K,L,0.3,0.7,0.5),K,1,50,L,1,50),
dimensions=[480,480])$

/* Animating this analysis, varying the returns to scale */

with_slider_draw3d(
tau, makelist(i/4.0,i,1,8),
view=[60,300],xtics={0,25,50},xlabel="K",
 ytics ={0,25,50},ylabel="L",zlabel="x", color=gray,
contour=both,
explicit(x(K,L,0.3,0.7,tau),K,1,50,L,1,50),
dimensions=[480,480],
title = concat("tau = ", string(tau)))$

While we're animating, consider what happens as b changes. Remember
that the elasticity of substitution is s = 1/(1 + b). Repeat this
for other values of tau. Why is the formula for creating b values 
given each of these characteristics: (1)It never equals 1, and (2)It
is never smaller than -1?

Repeat this animation with tau = 0.75 and with tau = 1.25.

/* Animating this analysis, varying the elasticity of substitution */
with_slider_draw3d(
b, makelist(-0.99+i/2,i,0,10),
view=[60,300],xtics={0,25,50},xlabel="K",
 ytics ={0,25,50},ylabel="L",zlabel="x", color=gray,
contour=both,
explicit(x(K,L,0.3,b,1),K,1,50,L,1,50),
dimensions=[480,480],
title=concat("s = ", string(1/(1+b))))$

An answer:
(1) The exponent -tau/b would be undefined if b = 0, so we approximate
the Cobb-Douglas case by allowing b to equal 1.01. 
(2) The elasticity of subsutition's definition is such that s < 0 would imply
upward-sloping isoquants.

## Single Variable Input

Create a short-run production function srx(K0,L,a,b,tau). Evaluate that 
function when K0 = 10, a=0.3, b=0.7, and tau=1.

/*Input. Execute (ctrl-enter) for results */
srx(K0,L,a,b,tau):= ''(x(K0,L,a,b,tau));
srx(10,L,.3,.7,1);
/*This part is not required. It just provides a different
  look at the expression. */
ratprint:false$ ratsimp(srx(10,L,0.3,0.7,1));

Plot two srx( ) curves, one with K0 = 10 and the second with K0 = 20. Keep
the a, b, and tau values from above. What does the graph suggest about 
returns to the variable input L?

/*Input. Execute (ctrl-enter) for results */
wxdraw2d(user_preamble="set key left",
 xlabel="L", ylabel = "x",
 line_width=2, key = "K = 10",
 explicit(srx(10,L,.3,.7,1),L,0,50),
 color=red, key = "K = 20",
 explicit(srx(20,L,.3,.7,1),L,0,50)   )$

Determine that the marginal product of labor is (1) positive for all
values of L and (2) decreasing for all values of L.

/*Input. Execute (ctrl-enter) for results */
diff1srxL: diff(srx(K0,L,a,b,tau),L); 
diff2srxL: diff(srx(K0,L,a,b,tau),L,2);
/* A value of the 2nd derivative */
subst([a=0.3,b=0.7,tau=1,K0=10, L=10],%);

Discussion
diff1srxL is positive because 1 - a > 0 and all other terms are positive. 
diff2srxL is negative because the second term (-b - 1) is negative and all other
terms are negative.

Confirm these results with two graphs, one for the marginal product of labor
and the other for the derivative of the marginal product of labor with
respect to L (the 2nd derivative of xsr wrt L).

/*Input. Execute (ctrl-enter) for results */
wxdraw2d(
 xlabel="L",ylabel="Marginal product of L (MPL)",
 explicit( subst([K0=10,a=0.3,b=0.7,tau=1],diff1srxL),L,0,50)
 )$

/*Input. Execute (ctrl-enter) for results */
wxdraw2d(
 xlabel="L",ylabel="Slope of MPL", key = "diff2srxL",
 explicit( subst([K0=10,a=0.3,b=0.7,tau=1],diff2srxL),L,0,50)
 )$