matrices msu cse 260. outline introduction matrix arithmetic: –sum, product transposes and powers...
TRANSCRIPT
Matrices
MSU CSE 260
Outline
• Introduction• Matrix Arithmetic:
– Sum, Product• Transposes and Powers of Matrices
– Identity matrix, Transpose, Symmetric matrices• Zero-one Matrices:
– Join, Meet, Boolean product• Exercise 2.6
Introduction
mnmm
ij
n
n
aaa
a
aaa
aaa
A
21
22221
11211
m rows
n columns
mn matrix
element in ith row, jth column
When m=n, A is called a square matrix.
Also written as A=aij
Definition A matrix is a rectangular array of numbers.
Matrix Equality
• Definition Let A and B be two matrices.A=B if they have the same number of rows and columns, and every element at each position in A equals element at corresponding position in B.
Matrix Addition, Subtraction
Let A = aij , B = bij be mn matrices. Then:A + B = aij + bij, and A - B = aij - bij
34
04
34
32
41
43
02
43
11
30
82
52
32
41
43
02
43
11
Matrix MultiplicationLet A be a mk matrix, and B be a kn matrix,
k
tkjikjijitjitij
ij
babababac
cAB
12211 ...
24232221
14131211
34333231
24232221
14131211
232221
131211
cccc
cccc
bbbb
bbbb
bbbb
aaa
aaa
12321322121211 cbababa
Matching Dimensions
24232221
14131211
34333231
24232221
14131211
232221
131211
cccc
cccc
bbbb
bbbb
bbbb
aaa
aaa
To multiply two matrices, inner numbers must match:
23 34
have to be equal
24 matrix
23 3424
Otherwise,not defined.
Multiplicative Properties
Note that just because AB is defined, BA may not be.Example If A is 34, B is 46, then AB=36, but BA is not defined (46 . 34).Even if both AB and BA are defined, they may not havethe same size. Even if they do, matrices do not commute.
23
34
35
23
11
12
12
11
BAAB
BA
match dimensions assuming
, however )()( BCACAB
Efficiency of Multiplication
24232221
14131211
34333231
24232221
14131211
232221
131211
cccc
cccc
bbbb
bbbb
bbbb
aaa
aaa
a11b12 + a12b22 + a13b32 = c12
Takes 3 multiplications, and 2 additions for each element.This has to be done 24 (=8) times (since product matrix is 24). So 243 multiplications are needed.•(mk) (kn) matrix product requires m.k.n multiplications.
23 34
Best Order?
Let A be a 2030 matrix, B 3040, C 4010. (AB)C or A(BC)?
(2030 3040) 4010
2030 (3040 4010)
operations24000403020
operations 8000104020
operations 12000104030 operations 6000103020
32000
18000
So, A(BC) is best in this case.
Identity Matrix
100
010
001
3I
The identity matrix has 1’s down the diagonal, e.g.:
fe
dc
ba
fe
dc
ba
0000
0000
0000
100
010
001
For a mn matrix A, Im A = A In
mm mn = mn nn
Inverse Matrix
Let A and B be nn matrices.If AB=BA=In then B is called the inverse of A,
denoted B=A-1.
Not all square matrices are invertible.
Use of Inverse to Solve Equations
r
q
p
z
y
x
ccc
bbb
aaa
321
321
321
r
q
p
zcycxc
zbybxb
zayaxa
321
321
321KAIX
KAAXA
KAX
1
11
r
q
p
ccc
bbb
aaa
z
y
x
31
21
11
31
21
11
31
21
11
Please note that a-1j is
NOT necessarily (aj)-1.
Transposes of Matrices
ija
jia
Flip across diagonal
654
321
63
52
41tA written
Transposes are used frequently in various algorithms.
Symmetric Matrix
AAt If A is called symmetric.
201
034
141is symmetric. Note, for A to besymmetric, is has to be square.
nI is trivially symmetric...
Examples
k
xxijx
k
xjxxi
k
x
xjt
ixttt
k
xxijxji
tij
t
k
xxjixij
ttt
baababAB
baccAB
bacAB
ABAB
111
1
)(
)(
Power Matrix
• For a nn square matrix A, the power matrix is defined as:
Ar = A A … A r times
• A0 is defined as In.
Zero-one Matrices
• All entries are 0 or 1.
• Operations are and .• Boolean product is defined using:
for multiplication, and
for addition.
Boolean Operations
011
010
010
101BA
010
000BABA meet"" called
011
111BABA join"" called
Terminology is from Boolean Algebra.Think“join” is “put together”, like union, and“meet” is “where they meet”, or intersect.
Boolean Product
110
011,
01
10
01
BA
nkbBkmaA ijij be and be , )()()(, 2211 kjikjijiijij bababaccBA
(Should be a ‘dot’)
011
110
011
01)00()11(
11)01()10(
01)00()11(
BA
Since this is “or’d”, youcan stop when you finda ‘1’
Boolean Product Properties
111
100
100
,
011
110
011
BA
100
111
100
BA
111
011
011
AB
• In general, A B B A• Example
Boolean Power
• A Boolean power matrix can be defined in exactly the same way as a power matrix. For a nn square matrix A, the power matrix is defined as:
A[r] = A A … Ar times
A[0] is defined as In.
Exercise 2.6