# ECON 331 97/1
# HOMEWORK ASSIGNMENT #1
# 
# QUESTION 1
# 
# a)
> Diff( 20-2*p1+p2, p2);
> value(");
# 

                          d
                         --- (20 - 2 p1 + p2)
                         dp2


                                  1

> Diff( 25+p1-3*p2, p1);
> value(");

                          d
                         --- (25 + p1 - 3 p2)
                         dp1


                                  1

# b)
> d1 := q1=20-2*p1+p2;
> d2 := q2=25+p1-3*p2;
> s1 := q1=2*p1;
> s2 := q2=2*p2;
# 

                      d1 := q1 = 20 - 2 p1 + p2


                      d2 := q2 = 25 + p1 - 3 p2


                           s1 := q1 = 2 p1


                           s2 := q2 = 2 p2

> solve( {d1, d2}, {p1, p2});

      {p1 = - 1/5 q2 + 17 - 3/5 q1, p2 = - 1/5 q1 + 14 - 2/5 q2}


# c)
> solve( {d1, d2, s1, s2}, {q1, q2, p1, p2});

                     240       125       120       250
               {q2 = ---, p1 = ---, p2 = ---, q1 = ---}
                     19        19        19        19

# 
# QUESTION 2
# 
> with(linalg);
# 
> A := matrix( 2, 2, [1, 1, 2, 3]);
> c := vector( [4, 2]);
> d := vector( [1, 2]);
> A_inv := inverse(A);
# 
# 

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


                             c := [4, 2]


                             d := [1, 2]


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

> x := evalm( A_inv &* d -c);
# 

                            x := [-3, -2]

# 
# QUESTION 3
# 
# a)
# The goods market equilibrium condition is represented by equation g1,
# while the money market equilibrium condition is represented by
# equation m1:
> restart;
> g1:= Y = Co + b*(Y - t*Y) + Io - a*r + G;
> m1:= Mo = k*Y - B*r;

              g1 := Y = Co + b (Y - t Y) + Io - a r + G


                         m1 := Mo = k Y - B r

# The IS  locus (Y as a function of r) is:
> solve( {g1}, {Y});

                            Co + Io - a r + G
                       {Y = -----------------}
                               1 - b + b t

# The LM locus (Y as a function of r) is:
> solve( {m1}, {Y});

                                 Mo + B r
                            {Y = --------}
                                    k

# b)
# To graph the LS and LM loci in (Y,r) space we need to invert the
# equations we solved for above.  This is easily done as follows:
> solve( {g1}, {r});

                      Co + b Y - b t Y + Io - Y + G
                 {r = -----------------------------}
                                    a

> solve( {m1}, {r});

                                -Mo + k Y
                           {r = ---------}
                                    B

# To graph the loci in Maple we need to assign some values to the
# parameters in our model:  
> Co:=10:
> Io:=10:
> G:=10:
> b:=0.8:
> t:=0.5:
> a:=30:
> Mo:=10:
> k:=0.5:
> B:=10:
# The loci can now be plotted in the following manner:
> with(plots):
> Z:=plot( [-(Y-Co-b*Y+b*t*Y-Io-G)/a, (-Mo+k*Y)/B], Y=0..50):
> U:=textplot( [50, 1.5, 'LM']):
> V:=textplot( [50, 0.1, 'IS']):
> display( [Z, U, V]);

# c)
> restart;
> with(linalg):
# The coefficient matrix is:
> A:=matrix(2, 2, [1-b+bt, a, k, B]);

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

# The column vector of  endogenous variables is:
> x:=vector([Y, r]);

                             x := [Y, r]

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

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

