# ECON 331  97/1
# ASSIGNMENT #3
# 
# QUESTION 1
# 
# Typically, one would not use Cramer's rule in Maple to solve for
# variables in a system of linear equations.  Cramer's rule is a
# conveneint compuational device which allows us to solve linear
# equation sytems 'by hand'.  In Maple we could find the inverse demand
# functions using the solve command as we did in assignment #1.  Here is
# another way of solving linear systems using the linalg package:
> with(linalg):
Warning, new definition for norm
Warning, new definition for trace
# The coefficient matrix is:
> A:=matrix([[-2,1],[1,-3]]);

                                [-2     1]
                           A := [        ]
                                [ 1    -3]

# The vector of constants is:
> d:=vector([q1-20,q2-25]);

                       d := [q1 - 20, q2 - 25]

# The solution vector (p1, p2) is:
> multiply(inverse(A),d);

           [- 3/5 q1 + 17 - 1/5 q2, - 1/5 q1 + 14 - 2/5 q2]

# 
# If you really wanted to use Cramer's rule, you could do something like
# this:
> A1:=augment(d,subvector(A,1..2,2));

                              [q1 - 20     1]
                        A1 := [             ]
                              [q2 - 25    -3]

> A2:=augment(subvector(A,1..2,1),d);

                              [-2    q1 - 20]
                        A2 := [             ]
                              [ 1    q2 - 25]

# The inverse demand functions are:
> p1:=det(A1)/det(A);
> p2:=det(A2)/det(A);

                     p1 := - 3/5 q1 + 17 - 1/5 q2


                     p2 := - 1/5 q1 + 14 - 2/5 q2

# 
# 
# QUESTION 2
# a)
# Here we will use a slightly different approach to implement Cramer's
# rule.
> restart;
> with(linalg):
Warning, new definition for norm
Warning, new definition for trace
# From assignment #1, we know that the coefficient matrix for the IS-LM
# sytem is:
> A:=matrix(2, 2, [1-b+bt, a, k, -B]);

                            [1 - b + bt    a ]
                       A := [                ]
                            [    k         -B]

# The vector of constants is:
> d:=matrix(2,1,[Co+Io+G, M0]);

                               [Co + Io + G]
                          d := [           ]
                               [    M0     ]

We can find Ye :
> AY:=copyinto(d,copy(A),1,1);

                            [Co + Io + G    a ]
                      AY := [                 ]
                            [    M0         -B]

> Ye:=det(AY)/det(A);

                         -B Co - B Io - B G - a M0
                   Ye := -------------------------
                           -B + B b - B bt - a k

> simplify(Ye);

                       B Co + B Io + B G + a M0
                       ------------------------
                         B - B b + B bt + a k

> collect(",B);

                        (Co + Io + G) B + a M0
                        ----------------------
                         (1 - b + bt) B + a k

# Similarly, we can find re:
> Ar:=copyinto(d,copy(A),1,2);

                        [1 - b + bt    Co + Io + G]
                  Ar := [                         ]
                        [    k             M0     ]

> re:=det(Ar)/det(A);

                   M0 - M0 b + M0 bt - k Co - k Io - k G
             re := -------------------------------------
                           -B + B b - B bt - a k

# b)
# The coefficient on M0 is:
> coeff(Ye,M0,1);

                                   a
                       - ---------------------
                         -B + B b - B bt - a k

> simplify(");

                                  a
                         --------------------
                         B - B b + B bt + a k

> collect(",B);

                                  a
                         --------------------
                         (1 - b + bt) B + a k

# Given the standard assumptions about the magnitude of the parameters
# in the expression above, the coefficient on M0 is postive.  This means
# that an increase in the exogenous stock of money will 'cause' an
# unambiguous increase in Ye.
