Professional Documents
Culture Documents
These notes are intended to complement the text for the course, covering
more of the derivation and the theory. This is a draft. There may be typos.
Please inform me if anything looks wrong.
Contents
1 Matrices 1
1.1 Introduction to matrices . . . . . . . . . . . . . . . . . . . . . 1
1.2 Transpose operation . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Matrix addition . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Matrix multiplication by a scalar . . . . . . . . . . . . . . . . 3
1.5 Matrix multiplication by vectors . . . . . . . . . . . . . . . . . 4
1.6 From linear equations to matrices . . . . . . . . . . . . . . . . 5
1.7 Gauss elimination . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.8 Multiplying two matrices . . . . . . . . . . . . . . . . . . . . . 8
1.9 Matrix inversion . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.10 Non-invertible Matrices . . . . . . . . . . . . . . . . . . . . . . 13
1.11 Determinants . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.12 Matrices in Matlab . . . . . . . . . . . . . . . . . . . . . . . . 16
1 Matrices
1.1 Introduction to matrices
A matrix is a two-dimensional array of numbers with certain arithmetic prop-
erties. It is usually represented inside brackets. For example:
" #
1 2 1
A= (1)
0 4 1
This matrix has 2 rows and 3 columns, and hence is called a 2 3 matrix.
The entries of a matrix are represented by two subscripts, the first for the
row and the second for the column. Hence, Aij is the entry in the ith row,
jth column. In the above example, then A12 = 2, while A21 = 0. A general
2 3 matrix may be written
" #
A11 A12 A13
A= (2)
A21 A22 A23
1
A matrix with either one row or one column is called a vector. A vector
with only one row is called a row vector, and in this class will be written in
triangular braces. For example
1
v= 6 (5)
1
v1
v
v= 2 (6)
...
vn
" #
1 2 1
A= (7)
0 4 1
2
then
1 0
T
A = 2
4 (8)
1 1
This process can also be done in reverse, where a common factor is pulled
out of terms to simplify the expression. One matrix we will see is
" # " #
EA
e L
EA
L
EA 1 1
k = = (11)
EA
L
EA
L L 1 1
Using the formulas in the last two sections, we can now define matrix
subtraction
A B = A + (1 B) (12)
3
1.5 Matrix multiplication by vectors
Matrix-vector multiplication comes up often. The formula for matrix-vector
multiplication is as follows: If Ax = b, then
X
bi = Aij xj (13)
j
" # 5 ( ) ( )
1 2 3 15+26+37 38
6 = = (14)
0 4 1 05+4617 17
7
If the number of columns in the matrix is not equal to the number of rows
in the vector, then that matrix and vector cannot be multiplied.
Square matrices are of particular interest. A special square matrix is the
identity matrix, which is usually called I. It is the matrix extension of the
number 1. We know that 1 x = x for any number x. For the identity matrix
Iv = v (15)
for any vector v that has the same number of rows as the number of
columns in the identity matrix. The identity matrix has the form of having
1s on the main diagonal from top left to bottom right, and zeros elsewhere.
The 3 3 identity matrix, for example, is
1 0 0
0 1 0 (16)
0 0 1
The reader should verify that for any vector v with length 3, Iv = v. In
other words
1 0 0 v1
v1
0 1 0 v = v2 (17)
2
0 0 1 v3
v3
4
1.6 From linear equations to matrices
One of the most important applications of linear algebra (arguably the most
important) is the solution of systems of linear equations. A set of linear
equation may look like
d1
d2 (21)
d3
and then figure out the coefficient for each one in each equation. The resulting
matrix equation looks like
2 4 2 d1
2
1 2 0 d2 = 1 (22)
2 0 1
d3
2
If we multiply the matrix and vector back, we can check that we get our
original 3 equations. To fill out our matrix, we ask ourselves, what is the
coefficient of d1 in the first equation? That number (2 here) goes in the
11 position of the matrix. Then, what is the coefficient of d2 in the first
equation? That goes in the 12 position, and so on until the first row is
completed. Then we go to the second row, and ask, what is the coefficient
of d1 in the second equation, and put that in the 21 position. We continue
until all the rows and columns are filled up.
Once we create a matrix equation, we are in a position to use linear
algebra to solve the system of equations.
5
be performed on a system of equations without changing the answer. The
operations of interest are:
1) We can multiply a given row by a scalar
2) We can add a scalar multiple of one row to another
3) We can interchange 2 rows.
These operations correspond to multiplying the corresponding equation
by a scalar, adding a multiple of one equation to another, and changing
the order of two equations, respectively. We know from algebra that these
operations will not change the answers.
Of course, whatever we apply to one side of the equation we must apply
to the other. Here is an example of how to use these operations to solve a
problem.
Consider the problem
2 4 2 d1
2
1 2 0 d2 = 1 (23)
2 0 1
d3
2
The goal is to manipulate the matrix until the lefthand side is the identity
matrix. Typically, we first eliminate the entries below the diagonal, starting
with the first column, changing the diagonal entries to 1 along the way. Then
we start with the last column, eliminating upwards.
So our first step is to get the first diagonal term equal 1. We accomplish
this by multiplying that row by 1/2.
R1 1/2 1 2 1 d1
1
1 2 0 d2 = 1 (24)
2 0 1
d3
2
Notice that, like all algebra, anything we do to the lefthand side of the
equation we have to do to the right. Next we eliminate K21 by adding 1
times the first row.
1 2 1 d1
1
R1 + R2 0 0 1 d2
= 0 (25)
2 0 1
d3
2
2 R1 + R3 0 4 1
d3
4
6
We now wish to set K22 = 1. Typically, we would accomplish this by
multiplying the second row by the reciprocal of K22 . However, we cannot do
this when K22 = 0. In this case then, we interchange the second row with
the next row below that has a nonzero entry in second column (here, row 3).
1 2 1 d1
1
R3 0 4 1 d2
= 4 (27)
R2 0 0 1
d3
0
1 2 1 d1
1
1
R2 4 0 1 1/4
d2 = 1 (28)
0 0 1
d3
0
The next step would be to finish zeroing the second column below the
main diagonal, but this is done in this problem. We next multiple K33 by its
reciprocal, but we are lucky that this is also done. So we begin eliminating
the numbers above the diagonal, starting with the right column.
1 2 1 d1
1
1
R2 + 4 R3 0 1 0 d2
= 1 (29)
0 0 1
d3
0
And continue
R1 + R3 1 2 0 d1
1
0 1 0 d2 = 1 (30)
0 0 1 d3
0
And now continue to the next column
R1 2 R2 1 0 0 d1
1
0 1 0 d = 1 (31)
2
0 0 1 d3
0
d1
1
d2 = 1 (32)
d3
0
7
It is a good idea to check our answers by plugging into our original prob-
lem, and indeed
2 4 2 1
2
1 2 0 1 = 1 (33)
2 0 1
0
2
ABy = b (34)
but what is the proper way to multiply AB? Lets look at an example
where x and y have length 2. In this case we can rewrite the equations in
non-matrix form as
and
8
(A11 B11 + A12 B21 )y1 + (A11 B12 + A12 B22 )y2 = b1 (41)
(A21 B11 + A22 B21 )y1 + (A21 B12 + A22 B22 )y2 = b2 (42)
" #( ) ( )
A11 B11 + A12 B21 A11 B12 + A12 B22 y1 b1
= (43)
A21 B11 + A22 B21 A21 B12 + A22 B22 y2 b2
or
2
X 2
X
A1k Bk1 A1k Bk2 ( ) ( )
y1 b1
k=1 k=1
2 2
= (44)
X X y2 b2
A2k Bk1 A2k Bk2
k=1 k=1
n
X
Cij = Aik Bkj (45)
k=1
" # 4 0 1 2
1 2 3
1 3 1 4
0 4 1
0 5 2 1
" #
1 4 + 2 1 + 3 0 1 0 + 2 3 + 3 5 1 1 + 2 1 + 3 2 1 2 + 2 4 + 3 1
=
0 4 + 4 1 1 0 0 0 + 4 3 1 5 0 1 + 4 1 1 2 0 2 + 4 4 1 1
" #
2 21 7 13
= (46)
4 7 2 15
9
An important note is that AB 6= BA. The size of the matrices may not
even be the same. Even if they are the same size, generally the answer will
not be the same. For example
while
(AB)T = B T AT (49)
Proof:
Let C = AB. Then
(AB)T = CT = C ji (50)
ij ij
while
n n n
B T AT B Tik ATkj =
X X X
= B ki Ajk = Ajk B ki = C ji (51)
ij
k=1 k=1 k=1
AA1 = A1 A = I (52)
Notice that here, the inverse is the same on the left and right, even though
in general matrix multiplication is not commutative.
10
The same process of Gauss elimination can be used to invert a matrix.
For example Let
4 2 2
4 6 8
A= (53)
2 2 4
4 2 2 1 0 0
1
4 6 8 A = 0 1 0 (54)
2 2 4 0 0 1
We simply use the row operations on both sides of the equation as before.
The goal is to change A into the identity matrix, which will make the right
hand side A1 , as we will see. We start, as before, by multiplying the first
row by 1/4.
1
R
4 1
1 .5 .5 .25 0 0
1
4 6 8 A = 0 1 0 (55)
2 2 4 0 0 1
1 .5 .5 .25 0 0
1
R2 4R1
0 4 6 A = 1 1 0
(56)
2 2 4 0 0 1
1 .5 .5 .25 0 0
1
0 4 6 A = 1 1 0 (57)
R3 + 2R1 0 3 5 .5 0 1
1 .5 .5 .25 0 0
1
.25R2 0 1 1.5 A = .25 .25 0
(58)
0 3 5 .5 0 1
11
Now get rid of the 32 term by subtracting the 3 times the second row
from the third
1 .5 .5 .25 0 0
1
0 1 1.5 A = .25 .25 0 (59)
1 .5 .5 .25 0 0
1
0 1 1.5 A = .25 .25 0 (60)
Now we can work our way back up the upper triangle to to zero out those
entries.
1 .5 .5 .25 0 0
1
R2 1.5R3 0 1 0 A = 4 2.5 3
(61)
0 0 1 2.5 1.5 2
Then
R1 .5R3 1 .5 0 1 .75 1
1
0 1 0 A =
4 2.5 3
(62)
0 0 1 2.5 1.5 2
Finally,
R1 .5R2 1 0 0 1 .5 .5
1
0 1 0 A = 4 2.5 3 (63)
0 0 1 2.5 1.5 2
Since
1 0 0
1 1 1
0 1 0 A = IA = A (64)
0 0 1
we can conclude
12
1 .5 .5
A1 = 4 2.5 3
(65)
2.5 1.5 2
A1 Ax = A1 b (66)
x = A1 b (67)
2 4 2 d1
2
1 2 1 d2 = 1 (68)
2 0 1
d3
2
Proceeding as before
R1 1/2 1 2 1 d1
1
1 2 1 d2 = 1 (69)
2 0 1
d3
2
Then
13
1 2 1 d1
1
R1 + R2 0 0 0 d2
= 0 (70)
2 0 1
d3
2
Then
1 2 1 d1
1
0 0 0 d2 = 0 (71)
2 R1 + R2 0 4 1 d3
4
Then
1 2 1 d1
1
R3 0 4 1 d2
= 4 (72)
R2 0 0 0
d3
0
Looking at the third row, there is no way to get the last entry to be 1
without spoiling the other entries in that row. This matrix is non-invertible,
or singular. Since the last equation is true (multiplying out, we get 0 = 0)
the system of equations has infinitely many solutions. If it were false (e.g. 0
= 4), the system would have no solutions.
One way to check whether a matrix is singular is to see if the determinant
is zero. Of course, to do this we need to know what the determinant is...
1.11 Determinants
The determinant, as we will learn later, is a scale factor of a linear map
between two spaces of the same dimension. This will make more sense later.
For now, we just discuss how to determine it and what it means for solving
equations.
For a 2-by-2 matrix, the determinant is
" #
a b a b
det = = ad bc (73)
c d c d
14
det A = A11 det (cof(A11 )) A12 det (cof(A12 )) + ... + (1)n+1 A1n det (cof(A1n ))(74)
where cof(Aij ) is the matrix formed by eliminating row i and column j from
the original matrix A. For example, if
a b c
A= d e f (75)
g h i
then
" #
d f
cofA12 = (76)
g i
which is formed by eliminating row 1 and column 2 from the original matrix
A. In this way, we can determine the determinant of an n n by taking the
determinants of smaller (n 1) (n 1) matrices.
Instead of using the first row, we can use any row or column. To keep
signs positive, we add the term if i + j is even, and subtract if it is odd.
As an example, lets examine a 3 3 matrix
a b c
e f
d f
d e
d e f = a b + c (77)
h i g i g h
g h i
= aei ahf bdi + bgf + cdh cge (78)
15
1.12 Matrices in Matlab
(More examples of how to do linear algebra in Matlab will be posted later)
The strength of this approach is that calculators and computers can solve
these systems of equations very rapidly. This section shows how to solve a
system in one computer program: Matlab. I can usually figure out with a
little time how most of the graphing calculators work, so feel free to stop by
and I will look. See also
http://www.math.umbc.edu/ e campbell/Calculators/TI8x/linalg.html
for TI calculators.
Matlab treats everything as a matrix (scalars are 1 1 matrices, vectors
are n 1 matrices). To create a matrix, start with a left bracket, [, in
the command window followed by the numbers. Numbers in the same row
should be separated by spaces or commas, while changing rows should be
accomplished by using a semicolon or return. When done, enter a right
bracket, ] and hit return. The program will then display the matrix.
16
Next enter the vector and hit enter.
17
To solve, type inv(K) * b or K \ b.
And you are done.
18
19