Section 1.3

Matrices and their Algebra

Matrix Notation

A matrix is an ordered rectangular array of numbers, usually enclosed in parentheses or

square brackets.

> A:=matrix(3,4,[]): print(A);

matrix([[A[1,1], A[1,2], A[1,3], A[1,4]], [A[2,1], ...

The double subscripts are commonly used to indicate location of an entry in a matrix that is not

a row or column vector.

Algebra of Matrices

Equality of matrices

******************************************************************

Two matrices A and B are equal if their corresponding entries are equal.

******************************************************************

> A:=matrix(3,3): B:=matrix(3,3):

> evalm(A=B);

matrix([[A[1,1], A[1,2], A[1,3]], [A[2,1], A[2,2], ...

Addition of matrices

The set of real numbers is closed under addition; that is, the sum a + b of any two real

numbers a and b is a real number. The set of all mxn matrices is also closed under addition.

Example 1: Consider two matrices:

> A:=matrix(3,3): B:=matrix(3,3):

and their sum

> A+B=evalm(A+B);

A+B = matrix([[A[1,1]+B[1,1], A[1,2]+B[1,2], A[1,3]...

>

Example 2: Consider two matrices:

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

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

> B:=matrix([[7, 0, 9, 2],[2, -3, 1, -1]]);

B := matrix([[7, 0, 9, 2], [2, -3, 1, -1]])

and their sum

> A+B=evalm(A+B);

A+B = matrix([[8, -2, 12, 6], [7, 3, 4, 3]])

>

Example 3: Consider two matrices of different sizes

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

A := matrix([[4, 1, 2, 7], [1, 5, 3, 4]])

B := matrix([[1, 6, 3], [5, 6, 8]])

>

> A+B=evalm(A+B);

Error, (in linalg[matadd]) matrix dimensions incompatible

>

***********************************************************

We can only add matrices of the same size. The resulting matrix is obtained by

adding the corresponding entries of the given matrices.

The set of all mxn matrices is, therefore, closed under the operation of addition. ************************************************************

Properties of matrix addition

Recall: the set of real numbers under addition satisfies the following the:

commutative property a + b = b + a;

associative property (a + b) + c = a + (b + c);

additive identity property a + 0 = a + 0 = a; and

additive inverse property a + -a = (-a) + a = 0.

The set of all mxn matrices also satisifies similar properties.

The zero matrix.

> Z := matrix(2,2,0);

Z := matrix([[0, 0], [0, 0]])

**************************************************************

Addition Properties for Matrices

The set of all mxn matrices is closed under addition.

The commutative property holds: A + B = B + A

The associative property holds: (A + B) + C = A + (B + C)

The zero matrix Z is the identity element under addition: A + Z = Z + A = A

The additive inverse of the matrix A is - A: A + (-A) =(-A) + A = Z

***************************************************************

Multiplication by a Scalar

What is the effect of multiplying a matrix by a real scalar?

Example 4: Consider the matrix:

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

A := matrix([[1, 2], [3, 4]])

>

Multiply the matrix A by the scalar k

> k*A=evalm(k*A);

k*A = matrix([[k, 2*k], [3*k, 4*k]])

>

Example 5: Consider the matrix A

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

A := matrix([[1, 2, 3], [3, 4, 5], [5, 7, 9]])

> k*A=evalm(k*A);

k*A = matrix([[k, 2*k, 3*k], [3*k, 4*k, 5*k], [5*k,...

>

How do the entries of the matrix k*A relate to the entries of matrix A?

*************************************************************

The multiplication of a matrix by a scalar results in a matrix whose entries

are obtained by multiplying each entry of the given matrix by the given scalar.

*************************************************************

Properties of multiplication by a scalar

******************************************

Scalar Multiplication Properties for Matrices

r(A+B) = rA + rB

(r+s)A = rA + sA

(rs)A = r(sA)

(rA)B = A(rB) = r(AB)

*****************************************

Matrix Multiplication

Example 6: Consider the matrices:

> A:=matrix([[4,1,2,7]]); B:=matrix([[1],[6],[3]]);

A := matrix([[4, 1, 2, 7]])

B := matrix([[1], [6], [3]])

>

A is a 1x4 matrix and B is 3x1 matrix. Let us consider the two products A*B and B*A .

> BA:=multiply(B,A);

BA := matrix([[4, 1, 2, 7], [24, 6, 12, 42], [12, 3...

>

What does this tell us about product B*A ? Product B*A is a 3x4 matrix obtained by

multiplying a 3x1 matrix B and a 1x4 matrix A. What if we multiply A with B?

> AB=multiply(A,B);

Error, (in multiply) non matching dimensions for vector/matrix product

>

In this case the product AB is not defined.

Example 7: Consider now the matrices:

> A:=matrix([[a1,a2,a3]]);
B:=matrix([[b1],[b2],[b3]]);

A := matrix([[a1, a2, a3]])

B := matrix([[b1], [b2], [b3]])

>

> AB=multiply(A,B);

AB = matrix([[a1*b1+a2*b2+a3*b3]])

>

The result is a real number.

***************************************************************

Let us raise some Questions :

Is matrix multiplication always well-defined?

Is the product of two matrices (whenever defined) a matrix?

Is product AB equal to product BA for any two matrices A and B?

*****************************************************************

How does this multiplication process work?

Example 8: Consider the two matrices:

> A:=matrix([[a11,a12,a13],[a21,a22,a23],
[a31,a32,a33]]);

A := matrix([[a11, a12, a13], [a21, a22, a23], [a31...

> B:=matrix([[b11,b12],[b21,b22],[b31,b32]]);

B := matrix([[b11, b12], [b21, b22], [b31, b32]])

and their product AB

> matrixmul(A,B);

`The purpose of this procedure is to show the proce...

`multiplying two matrices A and B and obtaining the...

`of the product matrix AB`

` `

`The product of the two matrices AB ` = matrix([[a1...

`is obtained as follows`

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 1 of the matrix A and column 1 of the matrix B

to get the (1,1)-th entry of the product AB 

vector([a11, a12, a13])*matrix([[b11], [b21], [b31]...

` `

`and write the entry into the product matrix`

AB = matrix([[a11*b11+a12*b21+a13*b31, `*`], [`*`, ...

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 1 of the matrix A and column 2 of the matrix B

to get the (1,2)-th entry of the product AB 

vector([a11, a12, a13])*matrix([[b12], [b22], [b32]...

` `

`and write the entry into the product matrix`

AB = matrix([[a11*b11+a12*b21+a13*b31, a11*b12+a12*...

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 2 of the matrix A and column 1 of the matrix B

to get the (2,1)-th entry of the product AB 

vector([a21, a22, a23])*matrix([[b11], [b21], [b31]...

` `

`and write the entry into the product matrix`

AB = matrix([[a11*b11+a12*b21+a13*b31, a11*b12+a12*...

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 2 of the matrix A and column 2 of the matrix B

to get the (2,2)-th entry of the product AB 

vector([a21, a22, a23])*matrix([[b12], [b22], [b32]...

` `

`and write the entry into the product matrix`

AB = matrix([[a11*b11+a12*b21+a13*b31, a11*b12+a12*...

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 3 of the matrix A and column 1 of the matrix B

to get the (3,1)-th entry of the product AB 

vector([a31, a32, a33])*matrix([[b11], [b21], [b31]...

` `

`and write the entry into the product matrix`

AB = matrix([[a11*b11+a12*b21+a13*b31, a11*b12+a12*...

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 3 of the matrix A and column 2 of the matrix B

to get the (3,2)-th entry of the product AB 

vector([a31, a32, a33])*matrix([[b12], [b22], [b32]...

` `

`and write the entry into the product matrix`

AB = matrix([[a11*b11+a12*b21+a13*b31, a11*b12+a12*...

` `

`End of matrix multiplication procedure.`

`Try your own examples to learn the process`

Compare this with the Maple output

> AB=multiply(A,B);

AB = matrix([[a11*b11+a12*b21+a13*b31, a11*b12+a12*...

>

Example 9: Consider the two matrices:

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

A := matrix([[1, 2, 3], [2, 2, 3], [3, -1, 0]])

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

B := matrix([[1, 2], [2, 2], [3, 2]])

The product AB is

> matrixmul(A,B);

`The purpose of this procedure is to show the proce...

`multiplying two matrices A and B and obtaining the...

`of the product matrix AB`

` `

`The product of the two matrices AB ` = matrix([[1,...

`is obtained as follows`

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 1 of the matrix A and column 1 of the matrix B

to get the (1,1)-th entry of the product AB 

vector([1, 2, 3])*matrix([[1], [2], [3]]) = 14

` `

`and write the entry into the product matrix`

AB = matrix([[14, `*`], [`*`, `*`], [`*`, `*`]])

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 1 of the matrix A and column 2 of the matrix B

to get the (1,2)-th entry of the product AB 

vector([1, 2, 3])*matrix([[2], [2], [2]]) = 12

` `

`and write the entry into the product matrix`

AB = matrix([[14, 12], [`*`, `*`], [`*`, `*`]])

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 2 of the matrix A and column 1 of the matrix B

to get the (2,1)-th entry of the product AB 

vector([2, 2, 3])*matrix([[1], [2], [3]]) = 15

` `

`and write the entry into the product matrix`

AB = matrix([[14, 12], [15, `*`], [`*`, `*`]])

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 2 of the matrix A and column 2 of the matrix B

to get the (2,2)-th entry of the product AB 

vector([2, 2, 3])*matrix([[2], [2], [2]]) = 14

` `

`and write the entry into the product matrix`

AB = matrix([[14, 12], [15, 14], [`*`, `*`]])

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 3 of the matrix A and column 1 of the matrix B

to get the (3,1)-th entry of the product AB 

vector([3, -1, 0])*matrix([[1], [2], [3]]) = 1

` `

`and write the entry into the product matrix`

AB = matrix([[14, 12], [15, 14], [1, `*`]])

` `

< type ; and press Enter to continue ?topic for help  exit; to quit >

;

` `

Multiply row 3 of the matrix A and column 2 of the matrix B

to get the (3,2)-th entry of the product AB 

vector([3, -1, 0])*matrix([[2], [2], [2]]) = 4

` `

`and write the entry into the product matrix`

AB = matrix([[14, 12], [15, 14], [1, 4]])

` `

`End of matrix multiplication procedure.`

`Try your own examples to learn the process`

>

Compare this with the Maple output

> AB=multiply(A,B);

AB = matrix([[14, 12], [15, 14], [1, 4]])

>

******************************************************************

The product of an mxn matrix A with an nxr matrix B is obtained by multiplying row i

of A with column j of B and substituting the result in ( i,j )-entry. This is done for each i

( i = 1,..,m ) and for each j ( j =1,..,r). The result is an mxr matrix .

******************************************************************

Properties of matrix multiplication

The set of all nonzero real numbers under multiplication satisfies the following:

the commutative property a*b = b*a ;

the associative property [a*b]*c = a*[b*c] ;

the distributive property a*[b+c] = a*b+b*c ;

the multiplicative identity property a*1 = 1*a = a ; and

The set of all mxn matrices enjoy similar properties.

********************************************************************

Multiplication Properties for Matrices

Matrix multiplication is not always defined.

The commutative property does not always hold.

The associative property holds (AB)C = A(BC)

The distributive property holds A(B + C) = AB + AC and (A+B)C = AC + BC

********************************************************************

Special Types of matrices

Diagonal matrix

A diagonal matrix is a square matrix whose off diagonal elements are all zero.

> D2:=diag(a,b,c,d);

D2 := matrix([[a, 0, 0, 0], [0, b, 0, 0], [0, 0, c,...

A 4x4 diagonal matrix with entries a, b, c and d

Identity matrix

An identity matrix is a diagonal matrix with diagonal entries all equal to 1.

The 3x3 identity matrix is:

> I3:=diag(1,1,1);

I3 := matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

and the 4x4 identity matrix is:

> I4:=diag(1,1,1,1);

I4 := matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1,...

Recall, that in the set of all real numbers, the number 1 plays the role of the multiplicative

identity; that is, for any real number a, a*1 = 1*a = a. Is there an analogous statement for

matrices? What is the result of multiplying a square matrix A with its associated identity matrix?

Example 10: Consider a 3x3 matrix A and the 3x3 identity matrix

> A:=matrix([[a,b,c],[d,e,f],[g,h,i]]);

A := matrix([[a, b, c], [d, e, f], [g, h, i]])

> I3:=diag(1,1,1);

I3 := matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

> multiply(A,I3);

matrix([[a, b, c], [d, e, f], [g, h, i]])

****************************************************************

The identity matrix plays the role of the multiplicative identity.

IA = AI = A

*****************************************************************

Transpose of a matrix

The transpose of an nxm matrix A is obtained by interchanging the rows and columns of A.

Example 12: Consider the matrix A

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

A := matrix([[1, 2, 3], [2, 2, 4], [0, 1, 5]])

> B:=transpose(A);

B := matrix([[1, 2, 0], [2, 2, 1], [3, 4, 5]])

> C:=transpose(B);

C := matrix([[1, 2, 3], [2, 2, 4], [0, 1, 5]])

Consider a 3x4 matrix A with general entries:

> A:=matrix([[a11,a12,a13,a14],[a21,a22,a23,a24],
[a31,a32,a33,a34]]);

A := matrix([[a11, a12, a13, a14], [a21, a22, a23, ...

> A^T=transpose(A);

A^T = matrix([[a11, a21, a31], [a12, a22, a32], [a1...

> (A^T)^T=transpose(transpose(A));

(A^T)^T = matrix([[a11, a12, a13, a14], [a21, a22, ...

****************************************************************

Properties of the Transpose Operation

(A^T)^T = A

(A+B)^T = A^T+B^T

AB^T = B^T A^T

*****************************************************************

NOTE: The dot product <u,v> can be written as u^T v if u and v are column vectors.

> u := matrix(3,1,[1,5,2]); v := matrix(3,1,[2,-1,3]);

u := matrix([[1], [5], [2]])

v := matrix([[2], [-1], [3]])

> u^T = transpose(u);

u^T = matrix([[1, 5, 2]])

> multiply(transpose(u),v);

matrix([[3]])

Symmetric matrix

Symmetric matrices arise in the formulation of many physical and engineering problems.

Let us look at the class of all matrices A that satisfy the property: A = A^T ?

Example 13: Consider the matrix:

> A:=matrix([[1,2,5],[2,6,9],[5,9,11]]);

A := matrix([[1, 2, 5], [2, 6, 9], [5, 9, 11]])

The transpose of A is

> A^T=transpose(A);

A^T = matrix([[1, 2, 5], [2, 6, 9], [5, 9, 11]])

In general, what relations must be satisfied by the entries of a matrix A that will make A = A^T ?

Such matrices are called symmetric matrices .

Triangular matrices

These matrices are called upper (lower) depending on whether the entries below

(above) the main diagonal are all zero.

An upper triangular matrix is:

> A :=matrix([[1,2,4],[0,5,0],[0,0,8]]);

A := matrix([[1, 2, 4], [0, 5, 0], [0, 0, 8]])

A lower triangular matrix is:

> B:= matrix([[1,0,0],[0,5,0],[0,6,0]]);

B := matrix([[1, 0, 0], [0, 5, 0], [0, 6, 0]])

The notion Ax=b

Consider the linear system

x[1]-2*x[2] = -1

3*x[1]+5*x[2] = 19

Linear combination of the column vectors.

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

u := matrix([[1], [3]])

> v := matrix(2,1,[-2,5]);

v := matrix([[-2], [5]])

> b := matrix(2,1,[-1,19]);

b := matrix([[-1], [19]])

> x_1*evalm(u) + x_2*evalm(v)=evalm(b);

x_1*matrix([[1], [3]])+x_2*matrix([[-2], [5]]) = ma...

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

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

> evalm(A)*matrix(2,1,[x_1,x_2])= evalm(b);

matrix([[1, 3], [-2, 5]])*matrix([[x_1], [x_2]]) = ...

>

This system can be written as Ax=b .

Exercises

1-15(odd), 19, 20, 21, 27, 31, 32, 45