The Internet Economy

 

Econ 407: More on Matrices

> with(linalg):
A:=linalg[matrix](3,3,[4,1,-5,-2,3,1,3,-1,4]);

Warning, new definition for norm

Warning, new definition for trace

[Maple Math]

> IDM:=matrix([[1,0,0],[0,1,0],[0,0,1]]);

[Maple Math]

Definition: An identity matrix is a square matrix which has one on the main diagonal and 0 everywhere else, such as the matrix IDM shown above. Multiplying Matrix A by the identity matrix would return the A matrix as expected.

> C:=evalm(A&*IDM);

[Maple Math]

We can expand a matrix by using the two commands agument or concat as shown below:

> a := matrix([[1,2],[2,3]]);

[Maple Math]

> b := matrix(2,3,[3,4,5,6,7,8]);

[Maple Math]

> augment(a,b);

[Maple Math]

> v := vector(2,[1,2]);

[Maple Math]

> concat(v,b,v);

[Maple Math]

In the above examples we create a new matrix by joining a and b, or joing a vector, a matrix and a vector. This is a useful tool for solving equation sytems. See page 223 of the text and the following example.

Suppose you want to solve the following sytems of equations for x1 and x2:

2x1 + 12x2 = 40

8x1 + 4x2 =28

> a:=matrix([[2,12],[8,4]]);

[Maple Math]

> b:=matrix([[40],[28]]);

[Maple Math]

> C:=augment(a,b);

[Maple Math]

By appropriate additions and subtractions for rows and cols, we can reduce the C matrix to:

> [Maple Math]

Note that 2 is the solution for x1, and 3 is the solution for x2, and the first part is just an identity

matrix. We can also solve the system by multiplying the inverse of the a matrix by the b matrix. See the following example. 4x1+x2-5x3=8, -2x1+3x2+x3=12, 3x1-x2+4x3=5. Using matrix notation to show the A and the b matrix.

> A:=matrix([[4,1,-5],[-2,3,1],[3,-1,4]]);
b:=vector([8,12,5]);

[Maple Math]

[Maple Math]

> restart;

> A:=matrix([[4,1,-5],[-2,3,1],[3,-1,4]]);

[Maple Math]

[Maple Math]

> aa:=inverse(A);

[Maple Math]

>

> b:=vector([8,12,5]);

[Maple Math]

[Maple Math]

> with(linalg):

Warning, new definition for norm

Warning, new definition for trace

> d1:=det(A);

d1 := 98

> Ain:=inverse(A);

[Maple Math]

> X:=evalm(Ain&*b);

[Maple Math]

We can also use the solve command to solve the system for x1, x2, and x3.

> solve({4*x1+x2-5*x3=8, -2*x1+3*x2+x3=12, 3*x1-x2+4*x3=5},{x1,x2,x3});

[Maple Math]

Note that the solutions are identical.