7.2 Review of Matrices

Introduction

A vector is an ordered list of objects (for our class, real or complex numbers).  Vectors are used in science to describe things like spacial coordinates (in physics) or life stages (in biology).  We will use vectors to write systems of ODE’s in a concise manner.

Here is an example of a row vector:

rv=Table[(Subscript[v, j]),{j,1,4}]

and a column vector:

cv=Table[(Subscript[w, j]),{j,1,4}];
MatrixForm[cv]

A matrix is a two dimensional extension of the concept of a vector.  A matrix has rows and columns.  Here is an example of a 3×4 matrix

A=Table[Table[(Subscript[a, j,k]),{k,1,4}],{j,1,3}];
MatrixForm[A]

It has 3 rows and 4 columns.  A square matrix has the same number of rows as columns.  The matrix given above is not square because it has more columns, then it has rows.  The dimension of a matrix is m×n, where m is the number of rows and n is the number of columns.  As stated, the above matrix is 3×4.  A square matrix would be n×n dimensional.

Vectors can be thought of as matrices, where a row vector has dimension 1×n and a column vector has dimension m×1.

Algebra of Matrices

Scalar Multiplication and Addition of Matrices

We can multiply a matrix by a scalar (a real or complex number).  For example:

MatrixForm[c*A]

Note that every element of the matrix is multiplied by the scalar.  If two matrices have the same dimensions, then we can add them together (component wise).  For example: If

B=Table[Table[(Subscript[b, j,k]),{k,1,4}],{j,1,3}];
MatrixForm[B]

then

MatrixForm[A+B]

The Transpose of a matrix:  if A is an m×n matrix with elements (Subscript[a, j,k]) (meaning the number in the j row and k column), then the transpose of A, denoted as (A^T) is an n×m matrix with elements (Subscript[a, k,j]).  For example:

MatrixForm[Transpose[A]]

The first row of A becomes the first column of (A^T), the second row of A becomes the second column of (A^T), and so on.

Matrix Multiplication

Multiplying two matrices together is a little complicated.  First let’s talk about the dot product of two vectors.  If two vectors are the same length (dimension), then their dot product is the sum of the product of the corresponding elements:

((Subscript[v, 1]) (Subscript[v, 2]) (Subscript[v, 3]) ··· (Subscript[v, n]))∘((Subscript[w, 1]) (Subscript[w, 2]) (Subscript[w, 3]) ··· (Subscript[w, n]))=(Subscript[v, 1])(Subscript[w, 1])+(Subscript[v, 2])(Subscript[w, 2])+···+(Subscript[v, n])(Subscript[w, n]).

In vector notation this is:

(OverVector[v])∘(OverVector[w])=(∑_(k=1)^n)(Subscript[v, k])(Subscript[w, k]).

Now for matrix Multiplication.  If A is an m×l matrix and B is an l×n matrix, then A B will be an m×n matrix whose element are given by (Subscript[(A B), j,k]) equals (the (j^th) row of A)∘(the (k^th) column of B).

Note that matrix multiplication is not commutative.  If A is 2×4, B is 4×2 and C is 4×5, then A B is a 2×2 matrix while B A is a 4×4 matrix.  Also A C is a 2×5, while C A does not exist (you can not multiply a 4×5 and a 2×4 matrix in that order) because the “inner” dimensions do not match.  Two matrices are equal if they have the same dimension and the same elements (A=B if and only if (Subscript[a, j,k])=(Subscript[b, j,k]) for all possible values of j and k).

The identity matrix, denoted as I, is the matrix with property that A I=I A=A, for any square matrix A.  Here are the 2×2, 3×3 and 4×4 identity matrices:

{IdentityMatrix[2]//MatrixForm,
IdentityMatrix[3]//MatrixForm,
IdentityMatrix[4]//MatrixForm}

They have one’s on the main diagonal and zero’s everywhere else.

Example:

Clear[A,B]

A={{1,5,3,4},{2,-1,-2,1}};
MatrixForm[A]

B={{3,-1,0,2},{1,0,1,0}};
MatrixForm[B]

M=A.B; (* This is multiplying A and B *)
MatrixForm[M]

Note that we tried to multiple a 2×4 times a 2×4 and got an error.

M=A.Transpose[B]; (* This is multiplying A and (B^T) *)
MatrixForm[M]

M.IdentityMatrix[2]//MatrixForm

IdentityMatrix[2].M//MatrixForm

bob=Transpose[B].A;
MatrixForm[bob]

Note that A (B^T) was a 2×2 matrix while (B^T)A was a 4×4 matrix, so A (B^T)≠(B^T)A.  Again, Matrix multiplication is NOT, in general, commutative.

Matrix Inverses

The inverse of a square matrix A, denoted (A^(-1)), is a square matrix with the property: A (A^(-1))=(A^(-1))A=I, if it exists.  The process for finding an inverse of a matrix is outlined in the book on pages 372-374.  Here is an example of how Mathematica can be used to find inverses, by using the Inverse command and the RowReduce command.

Clear[A]

A={{3,0,1},{0,2,4},{1,1,1}};
MatrixForm[A]

We can augment the matrix on the right with the identity matrix and use RowReduce:

AAug={{3,0,1,1,0,0},{0,2,4,0,1,0},{1,1,1,0,0,1}};
MatrixForm[AAug]
RowReduce[AAug]//MatrixForm

The inverse is the 3×3 matrix given by the last three columns.  Notice that we get the identity matrix on the left and the inverse on the right.

Using the Inverse command we get:

Inverse[A]//MatrixForm

Now an example of a matrix that does not have an inverse:

Clear[bob]

bob={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
MatrixForm[bob]
bobinverse=Inverse[bob]

Lets see what happens with the augmented matrix:

bobaug={{1,2,3,4,1,0,0,0},{5,6,7,8,0,1,0,0},{9,10,11,12,0,0,1,0},{13,14,15,16,0,0,0,1}};
MatrixForm[bobaug]
RowReduce[bobaug]//MatrixForm

Notice that we did not get the identity on the left.

Final Thoughts

We can also consider matrices (or vectors) with functions as elements.  In this case, we can integrate or differentiate a matrix.  See page 375 of the book.  The goal here can be demonstrated with the following.

Consider the system of differential equations:

(Subscript[u, 1])'=Cos[t] (Subscript[u, 1])+(e^t)(Subscript[u, 2]),

(Subscript[u, 2])'=(e^(-t))(Subscript[u, 1])-Sin[t] (Subscript[u, 2]).

If we let (OverVector[u])=(({{(Subscript[u, 1])}, {(Subscript[u, 2])}})), then the system can be written as a matrix equation:

(OverVector[u])'=(({{Cos[t], (e^t)}, {(e^(-t)), -Sin[t]}})) (OverVector[u]).

We can then use theory from matrix and linear algebra to try to solve the system.