Lecture Notes Matrices
Lecture Notes Matrices
D. E. WELLS
May 1971
TECHNICAL
REPORT
LECTURE NOTES
NO.
15217
MATRICES
David E. Wells
May 1971
Latest Reprinting September 1995
PREFACE
In order to make our extensive series of lecture notes more readily available, we have
scanned the old master copies and produced electronic versions in Portable Document
Format. The quality of the images varies depending on the quality of the originals. The
images have not been converted to searchable text.
MATRICES
I.
Introduction
Matrix notation is a powerful mathematical shorthand.
review matrix
notation and definitions; matrix addition, multiplication and transposition; determinants, inverse and orthogonal matrices; and partitioned
matrices.
Ayres [1962] is
the
2.
=
5
6
5
cos 8
-sin 8
sin 8
cos 8
3
An element of a matrix will be denoted by a lower case letter
with a double subscript which indicates at which row and column intersection it is located.
For example
row vector.
scalar matrix.
--,
The unit
3.
=0
Matrices of different
41J
and
are not conformable for addition, the first being of order 2 x 3 and
the second being of order 3 x 1.
The sum of two matrices A and B which are conformable for
addition, is a matrix C = A + B, each element of which is the sum of
the corresponding elements of A and B.
c .. = a .. + b ..
IJ
IJ
IJ
( 1)
For example:
~+
2
+ 5
+J
5 + 3
~ ~
(2)
(3)
n A
More generally
n can
B = -A
i.e. B is called the negative of A.
A and B
6
5
5
in that order, are conformable for multiplication, however they are
not conformable in the reverse order
2
5
5
Note that the two inner subscripts are equal in the first (conformable)
case and are not equal in the second (nonconformable) case.
6
The product of two matrices A and B, which are conformable
for multiplication, is a matrix C =A B whose (i, j)th element is
the sum of the products of the elements in the ith row of A and the
j th co 1umn of B, taken term by term.
c .. =
L:
IJ
(4)
3
C = AB =
2
=
32
77
(distributive)
(5)
(A + B) C = A C + B C
(distributive)
(6)
(associative)
(?)
= (A B) C
A (B C)
However, in general,
A B ~ B A
(8)
(not commutative)
(9)
A B= AC
A B = 0
( 10)
with itself and with the identity matrix of the same order.
example of commutative matrices is
r~ -2Jl
2
f3 -~
~
13 -ll
l2
2J
rL -~1
2
Another
! -sl
6
~4
-~
c :]
and
3
B
5
4
then B = AT and A
for
( 11 )
= 1 , 2, 3 and j = 1 , 2.
The transpose has the following properties
(AT)T = A
( 12)
(A + B) T = AT+ BT
( 13)
(nA) T = nAT
( 14)
( 15)
A =
5
is symmetric (AT= A).
aij = aji
For any square matrix A, the matrices (A+ AT) and(AAT) will be
symmetric.
(16)
det A, or
IAI . .
If A is of order
L:
(+ a I. a2j
I
(17)
ank)
. k,
k,
A term in equation
If the elements
in the ith row and jth column of A are removed, then the determinant
of the remaining (n-1) x (n-1) matrix is called the minor of the element
a .. , and is denoted by IM ..
I
1.
(18)
:AI
n
L:
(expansion along jth column)
k=l akj akj
( 19)
9
and for a 3 x 3 matrix from equation 19 expanding along the first row,
!AI
a 11
al2
al3
a21
a22
a23
a31
a32
a33
all
= a 11
11 + al2
a22
12 + al3 0:13
a21
a23
a23
-al2
a32
a21
a22
a31
a32
+al3
a33
a31
a33
IAI
(20)
!A Bl
lA! !BI
(21)
= 0).
[AB=BA=II
then B is ca II ed the inverse of A and is denoted B = A-I (or
Singular matrices
-2
-4
-5
-2
-4
-6
and IB!
= 0,
therefore A is
nonsingular and has an inverse, but B is singular and does not have
an inverse.
10
(-I) 2+ I
-4
-5
-2
-4
2
(-I) 2+2
(-1)2+3
-5
-2
(-1) 1+3
-5
-2
-4 -5
(-I) 3+ I
2
(-I) I +2
-2
=t~
-I
-1
adj A
[-~
-2
I
-1 ]
-I
I
In the above example IAI
~!ar-J
A-1 =
1, thus
3
-2
-1
-1
-4
2
(23)
(-I) 3+2
-4
-4
11
and
2
-4
-2
-4
-5
-2
-1
-1
0
0
(k A)-l
= ]_ A-1
(25)
(26)
lA -ll = IAI- 1 =
rlr
(27)
pose of A (i.e. A
-1
(28)
1/12
A
-1/12
cos
-sin
sin
cos
B=
=
1/12
1/12
=r~
X
1
If
n-]
1-llv'Tj
L1/ nJ
Ll/12
and
T
XT
xl x2 = 2 xl
T
XT
xl xl = 2 x2
= 0
=
12
5.
Partitioned Matrices
A matrix can be considered to be made up of smaller parts,
A matrix can be
For
3
A=
5
3
A
=
5
If two matrices
left hand matrix (A) and the rows of the right hand matrix (B) be
partitioned in exactly the same way.
~]
B=
13
[~
A B=
~]
[Al:l\2]
---5
-[~
~][~ ~J
=
f::}
[~][
s]
[~ ]~]
f., B = -
r~
_1_
0-
[~II
8 11 + A12
821
8 11 +A22
821
[I 3
+
0 + 15
+ I
0 + 6
[All
A2l
A21
_1
A12]
11
821
A22
All
8 12 + Al2
A21
8 12 + A22
822
1:
22
12
822
Note that the submatrices follow the same rules in matrix multiplication
as
do~~~~.!_~
of a matrix,
subje~t
In
!_!_~seosing
tr~nsposing
For
14
A T
J -~
A T
2
(29)
r--
submatri~es
along
If A is partitioned
A B= B A= I
For example, if A and 6 are of order (m + n) x (m + n) A 6
All
mm
Al2
mn
8
mm 11
8
mn 12
A22
nn
8
nm 21
822
nn
mm
becomes
mn
=
A21
nm
nm
nn
where JAllJ .; 0 and IA221 .; 0 (i.e. A11 and A22 have inverses) .
Utilizing the rules of matrix multiplication
All 8 11 + Al2 821 = I m
(30)
Al 1 6 12 + Al2 822
=0
( 31)
=0
(32)
=In
(33)
= I
6 11 A12 + 6 12 A22
=0
(34)
(35)
15
821 All + 822 A21
=0
(36)
=In
(37)
=-
(381
-1
8 11 Al2 A22
(39)
-1
= A22
(40)
-1
-1
+ A22 A21 8 11 Al2 A22
6.
( 41)
(42)
8 12
=-
-1
All A12 822
(43)
821
=-
-1
822 A21 All
(44)
822
-1
-1
CA22 - A21 All A12)
(45)
Rank. of a matrix
A smaller submatrix can be obtained from a matrix by discarding some of the rows and columns of the original matrix.
Each submatrix
of a partitioned matrix is a special case of this, in which the discarded rows and columns are adjacent.
and columns need not be adjacent.
16
2
6
-1
-1
-3
-1
4 x 4.
known as
11
17
a 11 x 1 + a 12 x2 a 1 n xn
a ml X] + am2 x2
. . . . . a mn
= b1
= bm
mn
nxl
m8 1
or simply
EJ
where
all
al2
a21
a22
(46)
...
bl
X]
aln
a2n
'
a 2 a
m
mn
X=
x2
'
B=
J.
[A : B
I
= 0),
18
c)
Homo-
=2
A~ J
[:
2x 1 - 5x 2
=0
-2
-2
A=
-3
-3
-5
-5
5
i
19
given by:
( 47)
For non-homogeneous systems having rectangular coefficient matrices
(more equations than unknowns), this means that the matrix
AT
is non-singular (!AT
Thus
X=
(AT A) -1 AT B
(48)
(We will meet this solution again when we discuss the method of least
squares, which is concerned with obtaining the best average solution
from an inconsistent non-homogeneous system of equations.)
An example of a non-homogeneous system having a unique
solution is
20
A =
-3
-5
7
X=
A-l B =
1/2
e)
-1
-2
2, x 2 = 1, x 3
-5/2
1/2
If there are
2x
- 5x
2-
-1
21
-3
-5
In
x2 =
3 -
2x 3
XXC
0
c c c
U1
:l
0
U1
Value of
Constant
Vector B
:l
Q)
O'l
Q)
c 0
a> E
O'lO
0..!:
.j..J
Q)
.j..J
Rank of
Augmented
Matr 1 x
0 c
..!: 0
B]
[A
:f. 0
:f. 0
:f. 0
Ul
c
u
u c
U1
---
rank A
<
dimension of X
= dimension of
rank A
<
Q)
Q)
:l
dimension of X
Linear Transformations
The matrix equation
Q)
dimension of X
:l
B = 0
c.~.~~
C C-
= rank
:l
rank A
U1U1Ul4-J
==
B = 0
7.
Rank of
Coefficient
Matr 1x
U1 -
:f. rank A
Q)
Q)4-J
U1
.j..J
c
0
.j..J
(49)
22
that both X and Yare the same vector, however their elements refer
to different coordinate systems, in which case the transformation
matrix describes the relationship between the two coordinate systems,
or the operations which must be performed on the coordinate system to
which X refers to transform it into the coordinate system to which Y
refers.
Both of these interpretations of linear transformations will
be of interest.
The discussion will be restricted to transformation matrices
which are square and nonsingular
(iAI
~ 0)
X = A-l Y
This restricted class of linear transformations are called projective
transformations.
a)
Orthogonal transformations
23
There is a class of transformations which leave the lengths
of vectors unchanged.
by XTX.
For example, if
but
Y= AX
Therefore
transformation.
vectors unchanged.
There are two kinds of orthogonal transformations, called
reflections and rotations.
matrices (that is !AI
b)
=+
Reflections
=-
24
An example of a reflection in two dimensions is
-,.r
..--------
__.-.(!:!, I~~)
-v [-~_:_ __ __....._
Rotations
25
- sine
R = [case
sine
(51 )
case
= r cos
x2
r sin
r cos case - r sin sine
yl = r cos (+8)
Y2
= r sin (+e)
or
-s i neJ
case
Note that R is orthogonal (R RT =I), that is
RRT
"[c~
"~os 2 e
sin
s1n e
+ s in 2 e
-sin
J[
cos e
cos e
sin
-sin e
cos
:]
case]
. 2e
+ s1n
[:
~]
We confirm
26
R(-e)
= [
cos (-e)
-sin
(-e)] [
cos (-e)
sin (-e)
cos
8~
e~
sin
-sin e
cos
(52)
. 0T1tfif111.1 .
srs+e""
-rofaleJ
CoorJ tM:fe
srsfeiVt
Note that the two Interpretations are related by the obvious fact
that a rotation of the vector is equivalent
to~e
We will now
27
For a right
axis is grasped by the right hand such that the thumb points in the
positive direction along that axis, then the fingers point in the
direction of positive rotation.
The rotation
R3 (e):
cose
sine
-sine
cose
(53)
where R3 (e) denotes a positive rotation of angle e about the ''3 axis" (or w axis in this case}.
28
Rl (e)
R2 (e)
cos e
sin e
-sin 6
cos e
cos e
(54)
-sin e
(55)
sin e
cos e
They
=
where
cose
-sine
R3 (-e)= sine
cose
*
individual rotations.
29
w
!;(.
R~(Cfoo) R.('fo'')[~]
d)
Scalar transformations
which changes vector lengths (or coordinate scales), but produces the
same change in length (or scale) whatever the vector.
Such trans-
= [:
=k
so that
Y= A X
30
can be written
Y= k X
e)
Affine transformations
For example
and
in different ways.
= A x1
v2 =A x2
Y1
23]
[44]
31
(213)
by a rotation (e
transformation matrices
Rl =
sl
sl Rl
so that
Gos8 -sinJ
sine
case
'li3), having
[2/ffi m]
-3/
311T3
[: :] [7
[: -:1
~
2/113
~]
and
which equals
v1
above.
= 4)
is required,
32
Further discussion of affine transformations will be
restricted to the special case in which the transformation matrix
is symmetric.
An example of a symmetric
affine transformation is
A=[:
which changes the vectors
[b J and
:]
[~]
(Note, it is only a coincidence that both this and the previous example
leave the
rn
6')
(5' "3)
f)
[n
(56l
Solutions will exist for any A, but this discussion will be restricted
to non-singular symmetric matrices A.
The above matrix equation can be rewritten as
(A -
;>..
T) X = 0 J
(57)
33
which is a system of homogeneous equations.
IIA - ).
1- 0
(58)
ser~es
matrix A.
symmetric matrix
A= [ :
:]
(5 - A)
3
= (5-A)
- 9 = 0
(5 - A)
or
A2
which has the solutions Al
=8
lOA + 16
and A2
=0
= 2,
A are 8 and 2.
For each eigenvalue A. there will be a
I
non~zero
value of X
that satisfies equation 56, and these are called the eigenvectors (or
characteristic vectors or latent vectors) of A corresponding the
34
The rank of the coefficient matrix is one less than the number of
unknowns, therefore, as we found in the section on 1 inear equations
(section 6e), we must specify one of the unknowns (x 1 , x 2 ) arbitrarily,
and the remaining unknown will then be uniquely determined.
case if x 1
x1
r:J.
c 1 then x 2
In this
Similarly for :\ 2 = 2,
[-o.
x2
c2
These
are the vectors which are changed by A only in length and not in
direction.
Often the arbitrary constants c 1 , c 2 are chosen so that the
eigenvectors have unit length (or are normalized).
This condition is
expressed by
For X1
XTX
[cl
ell [::]
cl + cl
(59)
l or c 1
xl =
[1/fi]
x2 =
[-l/i2]
and
/2'
1/12
Similarly for X2
1/1"2
and
A
X1
A
A x2
= A.l xl
A
:\2 x2
(60)
35
or
where
(6 l )
-1/
[1112
l/12
v~ J
l I 12
and
D= [A 1
0
OJ
\2
OJ
x~
x2
x~
x1
x~
x1
x~
x2
PT P
= I
Exp 1 i cit J y
PT
p =
[xl
AT
xl
--
AT
xl
AT
x2
x2]
[x l
x2] =
xl
T
xl x
2
xl
AT
x2
~T
lx l
x2]
[ ]
x2
p-1 A p
D\
or
p T A p = _D
(62)
( 63)
36
Now two square matrices are called similar If there
exist~
If R Is orthogonal,
eigenvalues of A and
b)
Quadratic forms
XT X
2
+ . . , . + X
n
(64)
There
XT A X k
(65)
37
For example the quadratic polynomial equation
5x 21 + 6x 1 x2 + Sx 22 8
can be written as
[~
~]
transform~tion).
If X has been obtained from some other vector Y by the orthogonal transformation
(66)
then the quadratic form Is
where the value k of the quadratic form has not changed since S Is an
orthogonal transformation.
For YT (BT A 8) Y to be a sum of squares (y~) and have no
cross product terms (y 1 yj) then
8T A 8 0
In
this case B must be the orthogonal matrix whose columns are the
eigenvectors of A, and
yl 0 y k
(67)
38
For the above example it has already been shown that
B [1//2
=
1/ 12
-1/
12]
and D =
1/12
[8
0
:]
therefore
can be written
or
where
or
2
Y2
Note that y 1 + Lf
ell ipse was given and referred to a coordinate system whose axes were
not coincident with the axes of the ell ipse.
39
The coordinate system was then rotated counterclockwise ~.,. 45
(which is equivalent to rotating the ell ipse clockwise by 45) using
the rotation matrix
[1/ 12
-111"2]
1//2
1/12
of the ell ipse are related to the eigenvalues A. of A and the value
I
(68)
In our case k
= 8,
and A. = 8, 2 so a; = 1, 2.
I
40
EIGENVALUES OF A
VALUE OF XT A X
a 11 positive
positive definite
all negative
negative definite
VALUE CLASS
x,/
indefinite
8.
Derivative of a matrix
LA
dx
dal2
--ax-
""""'Ci>T
da21
da22
dX
dX
(69)
41
b)
A :::: B C
and the (i, j)th element of A is given by
so that
d
::::
~k\X~I
fdd /b. k) ck.
J
~k
bik
~x (ckj) .
d ( BC)
= CiX
=~
dx
Therefore,
C + B~
dx
(70)
dB. C + B ~
dx
= dx
dA
B~
~c :::: dXdx
dx
=~
dx
dC
dx
AC -1
dC
dx
-1
(71)
(Note that both the above results are analogous to the scalar formulae
42
for a
be and b
= ale,
Partial differentiation
x2,
(xl'
yl
x3)
xl
and X = x2
xz,
(xl '
Yz
v1
are
x3)
x3
() y 1
8 y1
3 x2 '
3 yl
a x3
Adopt the
--=
[~
ax1
d y1
a xz
~]
3 x3
- () y 1
() yl
3 yl
3 x1
() xz
3 x3
'2 y
=
3X
(72)
3 Yz
a Yz
a Yz
a x1
a x2
3 x3
~
J
ClY
=ax-
d X
(73)
43
where dY and dX are column vectors.
When X andY have the same order, the matrix ~~
is square
form is
dk
= dXT
A X + XT Ad X
and
dk
but A is symmetric (AT
= A)
= XT
AT dX + XT A dX
so
dk = 2XT A dX
or
(74)
e)
(x-a)n
1 x
nl + iiT J(x-t)"f(t)dt
a
(x-a) + .
a
a
44
For values of x close to a the 1 inear approximation is used.
f(x) = f(a) + -()cf
X
(75)
(x-a)
a
{(t)
~__
_ _ _ _ _..___--'--------+ t
X
= a 1,
= a2 ,
x2
.l.f.
()X
Setting
X
= [ ::] '
r:,x =
[ xl - al]
x2
() f
-a X =-
[H
a xl
a2
'
xo =
[:J
3f]
a x2
Then
f(X)
r:,x
(76)
45
If we now have more than one function of X we have a set
of equations
af 1
t:,.X
af2
= f2 (Xo) +ax
xo
t:,.X
f 2 (X)
Setting
fl
aF
-=
F =
af 1
df1
a x2
f2
ax1
f2
a x2
2X
f2
Then
F(X)
= F (X
+ :
/:,.X
xo
(77)
46
REFERENCES
Ayres, F.
(1962).
Theory and Problems of Matrices.
Outline Series, McGraw-Hill, Toronto.
Schaum's
47
APPENDIX A:
EXAMPLES IN MATRIX MANIPULATION
Page
I)
48
I I)
. 49
I I I)
IV)
V)
VI)
VII)
51
52
. 53
. 54
. 55
48
l)
of these?
a)
[~
b)
:]
[c~s
c)
s1n
e)
-sin
cos
-1
:]
d)
[7
f)
[3
a]
4]
0
0
g)
-1
h)
[:]
2)
\~hich
none of these?
a)
l~
d)
0
0
0
b)
:]
0
0
0
e)
c)
-1
[~ :]
f)
0
0
0
0
0
0
are
49
(cont 'd)
2)
~]
g)
[:
Answers:
I I)
1)
h)
diagonal
d' f
scalar
e, f' g' h
co 1umn
b' h
identity
f' 9
none
a' 9
none
a, d
square
c, e
row
2)
:]
4)
UJ
-[~
:]
indicated.
:]
by 3
b)
by k
:]
5)
A~ [~
:J
B = [
i] =[~
c
D=
50
6)
[:
c)
[: -:] [: -:]
e)
-:]
[:
[:
-:]
7)
-:]
b)
[:
-:]
[~
d)
~ ~]
:J UJ
-J
[:
Show that (A B)
= BT AT
matrices.
a)
8)
at
Answers:
3)
4)
5)
[~
:]
b)
[:
-J
:]
b)
A+ C= [:
a) [:
AB =[
3
15
~~]
[~
3
10
:] [~ ~] [~ :]
1:] B+D=[i] E+ F[: :]
c)
12]
b)
DC
a, b, c
d)
[ 3k
'
27
= [:17
4
12
10
5:]
46]
BD =
6)
-:1
[:
6
18
15
CA
= [D8
21
2
2f]
20
2~
8
26 49
49 97
10
18
51
Answers (contd):
7)
8)
I I I)
n]
a) [32
b)
[ 10
30
-8
-2
b, c
are singular?
a)
[:
d)
2
-2
10)
each other?
A=
[:
[:/3 ~,J
~!
= -2 -4
11)
of matrices.
[:
e)
-4 -5
-2
:J
c)
3 f)
[: -J
[: :]
-4 -6
:]
2
5
:J
b)
Which
B [:
-J
c = [:
=[:
:]
F [ S
J]
t~
-2
:]
-J
-~
-2
1 -1
0
1
= B-l
[: :] [: :]
52
Which of the following matrices are orthogonal? (Prove
12)
= AT
by showing A AT
a)
[c~s
(e)
= I).
-sin
(a)l
s1n ( 8)
[:
Answers:
9)
I 0)
1I )
12)
IV)
-1/
12]
1/12
l/.f2
01
d)
.J
14, -24, 9, I, 0, 0
AD
[1/12
cos ( 8)
:]
c)
b)
e, fare singular
= BE = CF = GH = I
-2/5]
5/3
t2/3
1/5
a,b,d,f
Answers:
13)
~]
~~]
b)
0
Q
b)
0
0
53
V)
14)
b)
[: :]
[: n
c)
[:
d) [ :
15)
notation.
5
-4
-2
[_:
_n
2x - 3y + 4z
=
=5
2x - 5y
2y +
2y +
2x - 3y + 4z
5
2
6
-1
3
2
-1
x + 2y + 3z = 0
2x + 5y + 7z = 0
-2x - 4y - 6z = 0
d)
=
=5
e)
X +
X
=
=5
2x - 5y
=-1
14)
+ 2y
=5
=7
2x + 3y =12
2y + Z
2x - 3y + -4z
X -
x + 2y + 3z = 0
2x + 5y + 7z = 0
f)
-2x - 4y - 5z
=0
Ranks= l, 2, 2, 2, 3,. 3
Largest nonsingular matrices forb, c,
d
~ l -4 -5~
2
-2
25
Which
2x - 5y + 2z =
Answers:
-~]
c)
5
-4
f)
2
5
-3
are non-homogeneous?
b)
a)
~]
e)
L~
i]
=n
54
Answers (cont'd)
Non-homogeneous - a. b, c_ e
Homogeneous - d, f
15)
b, c, d, e, f lnconsEstent - a
Consistent -
Unique solutions:
VI}
'
16)
Draw a
=[:]
b) [
c)
~ _~ ]
~ ~J
[c~s
~J
g) [
:~ ~
e) [ :
~]
h) [
:~~
-sin
cos
s1n 8
17)
d) [ :
-3/
vff]
2/ Y13
. 1/ll]
l/~
ee]
b)
[: ~]
[~
:]
c)
d)
[~ ~1
[ 5
1.
I]
e)
f)
.
[!
-:1
[-s ~l
2
-2
!]
[-:
~]
g) [
h)
55
18)
forms.
a)
5x 2 + 6xy + 5/
b)
5x
c)
7x
d)
5x
Answers:
2+
2
2
16)
4xy +
+ 8xy +
e)
2/
y
+ 2xy + 3y
f)
-5x
9l
g)
-2x
h)
Projective
a 11 but f.
Orthogonal
a, c, g, h, j.
Reflections
a.
Rotations
c, g' h' j.
Scalar
b, i.
Affine
d, e.
a..
I, I)
+ 4xy - 2y
+ 6xy +
+ 4xy +
2
2
56
Answers (Cont 1 d)
17) a)
8, 2.
e)
b)
6, l.
f)
-6, -1.
c)
9, -1.
g)
l 0' 0.
d)
18)
'
h)
Pos Def
a, b, d.
Neg Def
f.
Pos Semidef
9.
3, -2.
Neg Semidef
c, e, h.
lndef
VI I)
following matrices.
b)
[c~s
Sin X
20)
-sin
cos
=
21)
2XTA.
= f (a)
Uj
at
(x - a) .
a
57
a)
f(t)
+ t2
about a
=0
b)
f ( t) =
+ t2
about a
c)
f(t)
( 1 + t)
d)
f(t)
= cos t
e)
f ( t) = tan
-1
1/2
about a
=0
about a
about a
-rr/2
Answers:
19)
a)
c)
20)
21)
b)
[02x 3:2]
[:X
[ -s l n x
cos
-cos
-sin
:]
2~]
a)
[ 1Ox + 6y
6x + lOy ]
e)
6x + 8y
8x - 6y]
b)
[ 1Ox + 4y
4x + 4y]
f)
[ -1 Ox + 4y
4x - 4y]
c)
[ 14x + 8y
8x + 2y
g)
18x + 6y
6x + 2y]
d)
[lox+ 2y
2x + 6y]
h)
[- 4x + 4y
4x + 2y]
a)
f(x)
=1
d)
f (x)
b)
f(x)
= 2x
e)
f(x)
= 'IT/4 +
c)
f(x)
+~
7T
/2 -
X
X -
58
APPENDIX
= Tr(A) = I:i
a ...
ll
then
()'l'r (
tl = [ a
aA
rr(F)
aa lJ
..
Properties (rrheorems):
Given a constant k
Tr(kA) = k Tr(A)
Given two matrices A and B conformable under
additj~on
59
Given tvo matrices A and B conformable under both multiplications A'l'B
and AB
From the above properties it is evident that similar matrices have the
same trace, that i.s for any nonsingular matrix R, and any matrix A of
same order as R
Tr (R-l A R) = Tr (A)
and in particular if R is the orthogonal matrix which diagonalizes A
we have
'rr (A) = L:
A..
l
a 'l'r( F)
rr
aA
d Tr(F)
'I'
aA
F = AB
a Tr(A
aA
B)
a Tr
aA
Cl 'rr (A B ATC)
3A
(B A)
rr
=B
60
APPENDIX C
ALGORITHM FOR
T~
61
PROGRAM NO.
EQUIPMENT
370 /
IBM
J 55
DATE
D. Wells
PROGRAM NAME
ROT REF
PROGRAM TYPE
Subroutine
PROGRAM LANGUAGE
August 1973
FOR~L'RAN
IV
METHOD OF USE
Double precision is used.
Calling statement is
Inputs are
CALL ROTREF(NUM,NAXIS,ANGLE,ROT)
NUM = number of rotations and reflections in
the input sequence ( no limit)
NAXIS = vector of rotation and reflection axes
(for rotations use 1,2,3 and for reflections
use -l,-2,-3)
ANGLE
= vector
ATTACHMENTS
1) sunrmary of rotations and reflections
2) flowchart
3) program listing
l~)
test results
62
MA~RICES
Orthogonal Transformations
The matrix equation
=A X
then both the transformation and the matrix are said to be orthogonal.
Orthogonal matrices have the property that the product of the matrix and
its transpose (or vice versa) is the identity matrix, that is
A A=AA
=I.
The
63
to which the first, second, and third elements of X andY are referred as
the 1-axis, 2-axis, and 3-axis respectively (we could equally well label
them the x 1 , x 2 , x 3 axes or x, y, z axes).
These three axes may define either a right-handed or a left-handed
coordinate system.
if the fingers of the right hand are curled around any axis so that the
thumb points in the positive direction, then the fingers will point from a
second axis to the third axis, numbered in cyclic fashion.
Grasping the
Grasping the
Grasping the
Left-handed
coordinate systems follow the left hand rule, which differs from the above
only in that the left hand is used.
3
Reflections
If we denote a reflection of the kth axis by Pk, then the following
[-~
0
1
0
=[
1
0
0
0
-1
0
=[
1
0
0
0
1
0
pl =
p2
p3
~]
~]
-~]
64
= P 3P2 ),
so that it
4 Rotations
If we denote a rotation of angle 8 about the k
th
axis by Rk(e),
R1 (e)
R2 (e)
R3 (e)
=U
=[cos
?
cos e
-sin e
sin
cos
s1n e
[ cos ae
=
-s~n
-sin
cos
sin
cos
e
e
~
The product of several
the rotations are performed about the 3-axis of the original system, the
2-axis of the transformed system, and the l-axis of the doubly transformed
system, to yield the final triply transformed system.
If the rotation angles are all so small that their cosines can be
assumed to be unity, then the rotation matrices become commutative.
This
65
for left-handed coordinate systems.
the right hand rule given above:
curled around the rotation axis so that the thumb points in the positive
direction, then the fingers curl in the direction of a right hand rotation.
A similar statement for left hand rotations is obvious.
5 Inverse Transformations
The inverse of a transformation .A.
= A A-1 = I.
and for each of the above expressions for rotation matrices it can be shown that
[A B]-l
we have
= B-l
A-l
66
=k
if j
'f
otherwise
-1
= Rk
pj
k.
67
J/ILPul
}/V,.1
NA-XIS :::
Rol
=r
Cu~&JT
n1
f k,_, I
nI + I l
= nz + 1 S
/l :4. =
n3
DFi=-lrJi:
i\lfA-"jffX
R.l
R.l(n,,m)
~I (t1z,rtz)
(n3 1 1l3)
Rl (nz)r13)
~I (t13 1 nl)
Rl
C11r>112.)
R1Cnz.,11,)
.1 (tt~, n,)
cue~av1
=
=
Rl
i=f),e
M o Du '- o.S
l<.olft-TI oN
Cos o(N
Cos otrJ
51/J
o(,J
51"'
t-~
0
0
- -
0
0
0
-1
{J~
68
------~--~----------------------------------------
-~--SD-SROOl
I NE-
C
C
C
Nr>UT
AP
I
GU'~ E'\J
NU~
NU~RER
NAXIS(NJ~)
~ATRIX
JF A
OF ROTATI8NS
SEQUENC~
----~----------
9 ROTl---------------------~-~---~-
~J IREFTNU~fN~)(l-S,ANGL:::
c
C COMPUTE PRODUCT
c
----------
REFLECTIONS
A~D
TS
us:: -1 I
..:.2, -OR-
-=-~
------ ---------------------------
DUUALE PRECISION
DI'~FNSJrp-.
ROT,Rt,R2,AN~LEoEPS,COS,DCOS,SIN,DSIN,AAS,DABS
POT(3,3),Rl(3,3),R2(3),AN~:...E('HJ"'')
,NAXIS(NUM)
- - - - - - - - - - - - - - , - . , A T A - t=PS7TD;;;-Ts-r-------- ----------------------
COS(EPS) = DClS(EPS)
OSIN(EPS)
ABS(EPS) = OA~S(EPS)
C SET ,~OT' :: IDENTITY MATRIX
SIN(lPS)
D:l
l , 3
= 1, 3
R nr 1 I J 1 = o.
--------------- --- I F{ r- . EQ -J l R n T{ To Jl :
.- - ----- ------- --------------- ---------------------------1
CCNTI'IUE
C CHECK ELE~ENTS OF 'NAXJS' A~J SET R~FLECTI3N ELEMENTS OF 'ANGLE'
Oo
DO 2 N = I , NU\4
lF(NAXlS(N) oEOo 0 oORo NAXISCN) oLTo -3 oORo NI\XIS(N) oGTo 3)
DO 1 J
-~
-~
-~
GO
TQ
IF(NAXIS(N)
oLTo 0)
ANGLE(~)
Oo
2
CO~T INUF
-c_- fYJ:::O CFs-5- SEQUENCE -::r~~ IJTATT:::Jl'lS-ANU-REFLECTTON S ONE- AlA
00 4 N = 1, NUI/I
Tt ME _____ -----------
Rl(N2oN3l
Sl~{A~GLE(~))
R1(N3,N2) = - Rl('\J2,N3)
C DEFINE ZERO OFF-DIAGONAL ELEIIIENTS
Rl{N1o~2)
= Oo
IHTN f~ N 3T-= o.
Rl(N2oN1) = Oo
Rl(NJ,Nl) = Oe
1 ROT 1 )
C FORM PRODUCT (SET 1 RDT' = 0 Rl 1
DO 4 J = lo 3
;; ''-' ~
DO 3 I
1I 3
R2(1)
Oo
DO 3 K = lo 3
3
R2(1) = R2CI) + ~l(IoK)
ROTCKoJ)
DO 4 I
lo3
ROT(I,J):: R2(1)
_ _ _ _ _ _ _ _ _ _ _74____ ~-~~-~n 0 ~ J T ( I o J J ) L T E P S) RO T(l J~)~-==:.___:0~~--------------
RETURN
5 WRITF(6,6) N,NAXIS(N}
6 FOR'-1AT(10Xo 1 1LLEGAL VALUE NAXISC'ol3,
RETURN
END
1 }
= 'ol5o 1
IN ROTREF 1
TEST RESULTS
The program was tested by computing the product matrix for the following
sequence of rotations and reflections:
o<
f3
input to ROTREF:
NUM = 10
NAXIS
= (3,
2, -1, 3, 2, -2, 3, 1, 2, 3)
ANGLE
= { ..,.1r
-J!,
- 2..f)
~
It can be shown (by drawing the new coordinate axes after each
rotation and reflection, for example) that the above sequence results
in a product matrix which is the identity matrix (
~.e.
Attached is the test program listing and outp.tt. The product matrix
was computed and printed as each of the above .rotations and reflections
were added to the sequence .. In a production program, ROTREF would only
be called once to compute the product matrix for the entire sequence.
70
c
C
c
---------------;on~--K----=-1 -.-~w\fr-
=(
ANGLE(K)
Fhf'.: Ul>iiVE;:;:,
71
---1,.-N"'~AXEs------
-1
--------------------- - - - - - - - - - - - - - - - - - - - - - - - - - - 2
3
3
2
-2
3
45.
PRODUCT OF FIRST
o.
90.
90.
RnTATI3~S
o.
A~D
-45.
45. -90.
-90.
PFF_ECTIO~S
oo
o.70710678t2~ oo
o.ocoooooooo~ oo
-oo-------o. 7'l 710o7812D- oo ----- o. oooooooooo> -:ro --------o.ooooooooooo 00
OoOOOOOOOOOOD 00
Ool000000000) 01
o.7071067Al~D
-------~c-;7o7I0678t2D
PRODUCT OF FlRST
2
o.sooooooooon
-o.7o7too7Rt2D
Oo5000000000D
P~~nJ1flTC-T-{jf"--F--lR-!)'t
-D.5000000000D 00
-0.7071067gJ2D 00
Oo5000000000D 00
:rN~--~
AND
Rf::F~-F--C
00
00
o.soooooooooo 00
-0.~000000000~
Oo7071067R12~
Oo7071067812D 00
Oo0000000000) 00
Oo7071057812~ 00
PRODUCT OF FIRST
4 ROTATIONS ~ND RfF~ECTIONS
-0.70710678120 01)
Oo7071067A12D 00
Oo0000000000) 00
Oo5000000I)OOD 00
Oo5000000000D 00
-0.7071057812) 00
---------n~o-oomnro-rmn\r<r----rr. so o o <rrrno ooo-oo----o ;7o7ro 5 7fH2Tro...-n-o---PRODUCT OF Fir-ST
5
-o.5oocooooooo
o.soooooooooo
-0.70710678120
_ ____c.-.:.
PRODUCT OF FIRST
7
o.ooooooooooo
-o.7o71067B12D
________
-o.7o71067812D
PRODUCT OF FIRST
8
o.ooooooooooo
-o.toooooooooo
o.ooooooooooo
PRODUCT OF FIRST
9 ROTATIONS AND RFFLECTIJNS
o.oooooooooon oo
o.toooooooooo 01
o.ooooooooooJ
oo
--------o-~-1-C:foccroocnroD--oT---o~oooooo-ooo-oll"oo<---_,o,....;:_ooooo-o(yo-cm-rro"O" _ _ __
O.OOOOOOOOOOD 00
PRODUCT OF FIRST
10
o.toooooooooo
OoOOOOOOOOOOD
o.ooooooooooo
OeOOOOOOOOOOD 00
OolOOOOOOOOOD 01
72
APF:t:imiX D
73
PROGRAM NO.
EQUIPMENT
IBM
370 I 155
DATE
PURPOSE
D. Wells
PROGRAM NAME
CHOLD
PROGRAM TYPE
Subroutine
PROGRAM LANGUAGE
August 1973
FORTRAN
IV
METHOD OF USE
Double precision is used
Execution-time dimensioning of matrix is used
Matrix is inverted in place (input matrix is destroyed)
Calling statement is
CALL CHOLD(A,IRDA,NA,DETA,&n)
Inputs are
Outputs are
= now
DETA
n
ATTACHMENTS
1) discussion of algorithm
2) demonstration for
= determinant
= statement
of input matrix
4 x 4 matrix
3) flowchart
4) program listing
5) test results for 4 x 4 Hilbert matrix
(aij
=1
I (i +
j - 1) )
m~ch
simpler
process than the inversion of a full matrix. In the case of positive definite
syrmnetric (PDS) full matrices, it is possible to take advantage of this fact ..
L L
1\
-1
L
-1
A
Given below are the algorithms for each of the three steps,
assu.m.ing A to be positive definite
be noted that when A is PDS and has a banded structure, these algoritruns
can be modified to be more efficient.
has been arranged so that A, L, ).
Operations are omitted 1vhich would compute or use the zero elements of L and
and which would compute the redundant elements of B (due to its symmetry)o
Each algorithm is demonstrated for the case when A is a 4 x 4 matrix.
A,
75
First column of L
i = 2,3, ,n
Subsequent columns of
L(
= 2,3, ,n)
.itj =
~tj =
= j+l,j+2, ,n
<
(omitted)
>.
)\ t~ =
I/
l t:..
_A .. = -AU
l.j
~v=
i=l,2, ,n
.C::::::. -"lk
k.:::.J
IJ
<kj
= j+l,j+2, ,n
<j
(omitted)
First column of B
i =
Subsequent columns of
B(
= 2,3,o ,n)
b.
I.J
b 0
"'j
i
b
J c..
1~2,
,n
= j,j+l, ,n
76
Heferences:
Carnahan, Luther and Wilkes (1969). "Applied Numerical Methods 11
Wiley. (page 334)
77
Demonstration for 4 x l+ matrix
STEP 1.
LT
wl1ere we know A and want to find L. For the 4 x 4 case the equation is
a.. I/
Q,;t
Cl..,'3
Ct,1
(,,
a,u
au.
4.1..3
Ll7.-4
~2./
a.3 i
ajl.
L{B
it34
a. r,
r.Lp.
t\43
Ct-+<f
13i
e.q,
1.2.2.
1-n. ~B
Ltz
t33
lt3 L11-
l.-,3
l44
We now give the component equations for this matrix equation, and their solutions
for the components of L, in the sequence in which they are determined in
the above algorithm:
Component Equations
Solutions for
1,,"'
.e,,-2.
a,_, - l{l.J 1,,
a 11
C\.31
a4,
=-
.t
'31
~41
:::
lz,
f1H
a3z ""
d-tz
:::.
'l-
a+t
f-
131. 1z.z
J..,.l. .lu
2.
'Z.
t3i + l3z.
+.f33
!4,{~, +- l.,.~
2.
:::
z..
+ f'J.~
- f4, ~7.1
Cln a13
..f.,,
f ]/ l,_,
lz., . . a.z.,
l.o
2.
l.
f-+t + 11-2
in
fl"~- 3 l33
~
1..,.:$ +lt-4:
IJ
.{. '-,J
1.e"
1~ 1
= a~ , I l,,
!1,
==
a.. , I
R. ,,
78
STEP 2
D~onstration
for
4 x 4 matrix
= I
For the
;L
p,,
~l:Z.
l~, 13~
J.z,,
;t,
:lu
an
.1..., L,?,
~B
J3Z
~1. ~n J.f-3
1#
p/r3
)1-l
A+4
The components of this matrix equation and their solutions for the components
of
A.
U.L
Component Equations
Solutions for
~ tl:. I/~,,
=fzz Az.z. =-
111 ).,
R.u :::ln
-~H ,:)"14
/lzz. = /l'Z.Z
::.
/133
::.
;}.,...,_::. 1/4t
fz., J + l 'Z-2 J
/31 ;),, 1- f31.- A11
il
~~
f 32.
11
Z.l :::..
fi3
e.-fz.
A-z.."L +-
ltz. An
A:.;
+-
)z_(
43
la3
An = 0
f..,3 ) 3z +- I#
')53+ f44A+3 ~o
A31 ~ o
)3/
+ 1..,..,.1,,::. O
A4~
=-
1/li3
+ lu
':&
;I,)
79
STEP 3
Demonstration for
b., b,1.
b;_J
A.
b,"f.
b2-4
4 matrix
::13:;
b31
:::J,,
)1Z
)z.,
~n
J.., 3
;)~I
"A3'-
)53
~I
.-l~z.
;1.'13
)#
?. I -::.
b41 "'
7144 ;)_.,,
bl"t ..
b:~.7... ::;.
b32 ;
b<\ Z- =
bl+"' b4 1
h,_t::. h. . z.
b:H =
bH.:
b43
):.,
IL
\ L
lHb .. ) in the
lJ
80
Ste
Additions
Multi lications
3
Roots
- 4n
n3 + 3n2 - 4n
- n
Divisions
+ 3n
6
3
- 3n
+ 2n
6
3
Total
n3 - n
n3 + 3n 2 + 2n
n3 - n
2
n 3 + 3n 2 - 2n
2
81
---,:::=::::::---~
c 1-ic'LESK. 1
t:;l=
PEco~o~Pos,nco/o.(
IN/'VT HATteiX INI?:> ~ .
L Ow/Z
TleliW6r ULAtll..
MA- T#:U(
r-
'
I
I
L __
SuM :: o
:n ::.
:s-1
L-
* ( A.S~- SuM)
AJ~
-- ..J A....
u -
Su fv1 1
. 82
,_
I
I
I
L
L __
83
L.ow&"'R..
r--
I
I
I
L -I
L
L
--
84
oF ltv P~.rr
L ___ _
L
I
~Ana \X
85
------------------------------
MATRTX-INVERSIO~
USING CHOLESKI
~ECOMPOSITION
C
C
C
C
INPUT ARGU~ENTS
A= ARRAY CONTAI~ING POSITIVE DEFlNITF. SY~M~TRIC IN~UT MATRIX
IRDA = ROW DI~E~SIO~ OF ARQAY CJNTAININ~ INPUT MATRIX
NA = SIZE OF INPUT MATRIX
OUT-PITT___ AR GUM E-\1 r"s"" --- ------ ----------------------c A= CONTAINS INVE~SE OF INPUT MATRIX (INPUT DESTROY~D)
C DETA = DETERMINANT JF I~PUT ~ATRIX
C * = ERROR P.ETUR~ (TAKEN IF NA oLTo l OR IF DETA oLTo SING)
---c:c
**
-------r;=n--;~:a; -NAT-G1f--fo-s-~=~------------
J2 = J + l
DO 4 I = J 2o NA
SUM = Oo
DO 3 K = 1o J 1
3
SUM= SU14 + A(loK)
A(J,K)
4
A(l,J)
(A( loJ) - SUM) / A(JoJ)
5
CONTI\IIJE
--------::61F'TAEI5TbEt-A J LT. sING ) Go to 1 6 - - - - - - ' - - - - - - - - - - c INVERSION OF LOwE~ TRIANGULAR MATRIX
DO 7 1
1oNA
7
A(lol) = 1o / A(lol)
IF(NA oEOo 1) GO TO 10
N1 = NA - 1
DO 9 J = t,Nt
------~J 2
=J
+ l
DO 9 I - J 2o NA
SUM = Oo
It= I - I
DO 8 K = J,Il
* *
a
su~ = su~ + A(J,K)
ACKoJ)
9
A{ I , J ) = - A( l o I )
SUM
C CONSTRUCTION OF I~VERSE OF l~PUT MATRIX
10 DO 15 J = loNA
IF(J oEOo I) GO TO 12
Jl
J - 1
DO 11 I = lo J 1
------~11
A(I,J)
A(i-J~o~l~)~--------------------------------------------z---D1JT4-----r=:-:rtN
SUM
0o
DO 13 K = I,NA
13
SUM = SU~ + A(Koi)
A(K,J)
t4
A!I.JJ = su~
15
CONTINUE
RETURN
16 WRITE(6o17) DETA
----IT-1'-L! RMAT"fTt:fXOT"S-~1-r;Nr..G....-U""Lr-A-r-..R,........M""A'"""'T""'R'""I,.,X..-~I~N~C~A~m::n o t> E T = 1 , E 2 0 o 5 J
RETURN 1
18 WRITEC6o 19)
19 FnR~AT(10Xo 0 MATRIX OF DI~ENSION ZERO IN CHOLD')
RETURN 1
.
END
r. '- -- ,
86
-c
= 50MATRIX
C OBTAIN TEST
1
READ
-rf:n-~--~
oo
2
2 [
XI =
,N
r::o .-crr-Gl:r-To--6"---
=I
1 o'N
DO 2 J = loN
XJ = J
A( I , J ) = I /
( XI
+ XJ -
1 )
'IIRITEC6ol0)
DO 3 I
1, N
=
------:.-----vn<TlT'TntTrl\l\TT'OJ',., J= r::,,.rr--------------------C
CALL
CHOLD(A,NDIM~N,OETo&1J
INVE~SE,
DfA~ONAL
ELEMENTS
WRITF(6ol3) DET
WRITE (bo 14)
4
DO 4 I
1, N
WRITEC!>oll)
(A(IoJ),J=1oN)
DO 5 I
DET
= loN
WRITE(6,ll) (A(loJ)oJ=l,N)
---------~W~RITE(6ol2) (A(J,J)oJ=lo'l)
t11'0
6 RETURN
10 FOPMATC 1 l"o5Xo 1 TEST MAT~IX 1 )
5
11
12
13
FOR"1AT('0'o5(10Xo12E102o/Jl
87
-TESIM"ATrrrx------------ -------------------------------------
0.100 01
Oo500 00
Oo33D 00
Oo25D 00
0.500 00
Oo330 00
Oo250
Oo20) 00
Oo33D 00
Oo25D 00
Oo20D 00
00
----------o-;zsu--o<:r-o~.-2 oo-oo----o~-~--,D---ocr
Oo17)
00
-d-~r4o-cn:r--
DIAGONAL ELEMENTS
OolOOOOOOOOOO 01
0.33333333330 00
Oo2000000000D 00
0.14285714290 00
OETERI\'INANT
Oo16534Jg153D-06
INVERSE OF TEST MATRIX
Oo16D 02 -0.120 03
Oo24D 03 -0.140
03
--------=:u-;rzo<J:r--(J-;r21J--o -+-;::-u-;-z7U-o4---uor7::r--u4-
Oo24D 03 -0.270 04
-o.t4D 03
Oo650 04 -Oe42) 04
o.t7o 04 -o.42D 04
o.2eo 04
DIAGONAL ELEMENTS
02
--------------oOol6000000000
2 oo oo ooo o oo 4-----------------------~-t
o.6ttfloooooooo 04
Oo28000000000 04
DfTERMI NANT
0.60480000000 07
~NV"E"RIELrlolATT<nit"--=--SR001:1J--E~UAc-TEST-l'fATQrx--
0.100 01
o.soo
o.soo
Oo33D 00
00
00
0. 330 00
0.250 00
0. 250
0.200 00
00
OJ AGONAL
ELEMENTS
OelOOOOOOOOOD
0.33333333330
Oo2000000000D
0.14285714290
01
00
00
00