# ECON 331 97/1
# ASSIGNMENT #7
# 
> restart;
> with(linalg):
Warning, new definition for norm
Warning, new definition for trace
# 
# Production function:
# 
> q:=26*z1+24*z2-7*z1^2-12*z1*z2-6*z2^2;

                                     2                  2
            q := 26 z1 + 24 z2 - 7 z1  - 12 z1 z2 - 6 z2

# 
# Profit function (pi):
# 
> pi:=q-w1*z1-w2*z2;

                              2                  2
    pi := 26 z1 + 24 z2 - 7 z1  - 12 z1 z2 - 6 z2  - w1 z1 - w2 z2

# 
# Factor demand functions:
# 
> sols:=solve({diff(pi,z1),diff(pi,z2)},{z1,z2});

    sols := {z2 = 1 - 7/12 w2 + 1/2 w1, z1 = 1 + 1/2 w2 - 1/2 w1}

# 
# Second-order conditions:
# 
> H:=hessian(pi,[z1,z2]);

                               [-14    -12]
                          H := [          ]
                               [-12    -12]

> det(H);

                                  24

# 
# Since det(H)>0 and H(1,1)<0, the S.O.C. for a unique maximum are
# satisfied. This means that the profit function is strictly concave in
# (z1,z2 ).  This also implies that the production function is strictly
# concave in (z1,z2 ) since the cost function is linear in (z1,z2 ).
# 
# Comparative Statics:
# 
# The production function in general functional form:
# 
> q:=(z1,z2)->f(z1,z2):
# 
# The profit function in general functional form:
# 
> pi:=(z1,z2)->f(z1,z2)-w1*z1-w2*z2:
# 
# The first-order conditions:
# 
> D[1](pi)=0;

                ((z1, z2) -> D[1](f)(z1, z2) - w1) = 0

> D[2](pi)=0;

                ((z1, z2) -> D[2](f)(z1, z2) - w2) = 0

# 
# The first-order conditions imply that the marginal products of the
# factors are equal to their factor prices at the profit maximising
# levels of the factors, ie:  diff(f,z1)=w1, and  diff(f,z2)=w2 .
# 
# The supply function is found by expressing the production function as
# a function of the profit maximising levels of the factors:
# 
> maxq:=(w1,w2)->f(z1(w1,w2),z2(w1,w2));

            maxq := (w1, w2) -> f(z1(w1, w2), z2(w1, w2))

# 
# The comparative static result we seek can be expressed in general
# functional form:
# 
> dmaxq_dw1:=D[1](maxq);

dmaxq_dw1 := (w1, w2) ->

    D[1](f)(z1(w1, w2), z2(w1, w2)) D[1](z1)(w1, w2)

     + D[2](f)(z1(w1, w2), z2(w1, w2)) D[1](z2)(w1, w2)

# 
# The first term in each product is the marginal product of the factor
# which we know is equal to the appropriate factor price at the profit
# maximum.  The second term in each product is:  diff(zi,w) , i=1,2. 
# These derivatives are evaluated at the profit maximising levels of the
# factors.  Their values are:
# 
> assign(sols);
> dz1_dw1:=diff(z1,w1);
> dz2_dw1:=diff(z2,w1);
# 

                           dz1_dw1 := -1/2


                            dz2_dw1 := 1/2

# 
# So diff(maxq,w1) is:
# 
> dmaxq_dw1:=w1*dz1_dw1+w2*dz2_dw1;

                    dmaxq_dw1 := - 1/2 w1 + 1/2 w2

# 
# Notice that the sign of this derivative is ambiguous, it depends on
# the relative magnitudes of w1 and w2.  In particular, if w1<w2, an
# increase in w1 will lead to an increase in the profit maximising level
# of output!  If you are surprised by this result ask your TA to
# explain!
