[go: up one dir, main page]

0% found this document useful (0 votes)
5 views32 pages

Lecture 3 - Intro To Matrices

Uploaded by

Vyharan Francis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views32 pages

Lecture 3 - Intro To Matrices

Uploaded by

Vyharan Francis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Intro to Matrices

Don’t be scared…
What is a matrix?

 A Matrix is just rectangular arrays of items


 A typical matrix is a rectangular array of numbers
arranged in rows and columns.

 21 62 33 93
 
A   44 95 66 13 
3x4
77 38 79 33
Sizing a matrix

 By convention matrices are “sized” using the


number of rows (m) by number of columns (n).
 21 62 33 93 7 3 2 
A   44 95 66 13  B  8 4 1 
3x4 3x3
77 38 79 33 6 5 9 
11 4 
14 7 
C   D  17 
4x2 16 8  1 x1

 
 22 3 
“Special” Matrices

 Square matrix: a square matrix is an mxn matrix in


which m = n.
7 3 2 
B  8 4 1 
3x3
6 5 9 

 Vector: a vector is an mxn matrix where either m


OR n = 1 (but not both). 12 
9
X   Y   7 22 14
4 x1  4  1x 3
 
0
“Special” Matrices

 Scalar: a scalar is an mxn matrix where BOTH m


and n = 1.
D  17 
1 x1 0 0 
 Zero matrix: an mxn matrix of zeros. 0  0 0
3x2
0 0
 Identity Matrix: a square (mxm) matrix with 1s on
the diagonal and zeros everywhere else. 1 0 0 
I  0 1 0
3x3
0 0 1 
The Identity Matrix
Identity Matrix
1 3 1 1 0 0
A= 0 −2 1 I= 0 1 0
2 0 2 0 0 1

1 3 1 1 3 1
A*I = 0 −2 1 I*A = 0 −2 1
2 0 2 2 0 2
Transposing a Matrix

 Matrix Transpose: is the mxn matrix obtained by


interchanging the rows and columns of a matrix
(converting it to an nxm matrix)
12 
9
X   X '  12 9 4 0
4 x1  4  1x 4
 
0
 21 44 77 
 21 62 33 93 62 38 
A   44 95 66 13 
95
A'  
3x4 4 x3  33 66 79 
77 38 79 33  
 93 13 33 
Matrix Addition

 Matrices can be added (or subtracted) as long as


the 2 matrices are the same size
 Simply add or subtract the corresponding components of
each matrix.
1 2 3 5 6 7
A   B 
2 x3
7 8 9  2 x3
3 4 5 
1 2 3  5 6 7  1  5 2  6 3  7   6 8 10 
A B      
7 8 9  3 4 5  7  3 8  4 9  5  10 12 14 
 

A B  B  A
1 2 3 5 6 7  1  5 2  6 3  7   4 4 4 
A B     3 4 5    7  3 8  4 9  5    4 4 4 
 7 8 9       
Matrix Multiplication

 Multiplying a matrix by a scalar: each element in


the matrix is multiplied by the scalar.

1 2 3
A   and x = 5; then
2 x3
7 8 9 1x1

 5*1 5* 2 5*3  5 10 15 
xA   
5*7 5*8 5*9  35 40 45

Matrix Multiplication

 Multiplying a matrix by a matrix:


 the product of matrices A and B (AB) is defined if the
number of columns in A equals the number of rows in B.
 Assuming A has ixj dimensions and B has jxk dimensions,
the resulting matrix, C, will have dimensions ixk
 In other words, in order to multiply them the inner
dimensions must match and the result is the outer
dimensions.
 Each element in C can by computed by:

Cik   j Aij B jk
Matrix Multiplication

 Multiplying a matrix by a matrix:


5 3
1 2 3
A   B '   6 4 
2 x3
7 8 9  3x2
7 5 
c c12  Matching inner dimensions!!
A B '  C   11
2 x3 3 x 2 2x2
c21 c22  Resulting matrix has outer dimensions!!!

c11   A1 j B j1  1*5    2*6    3*7   38


c12   A1 j B j 2  1*3   2* 4    3*5   26
c21   A2 j B j1   7 *5    8*6    9*7   155
c22   A2 j B j 2   7 *3   8* 4    9*5   98
 38 26 
A B'  C   
2 x3 3 x 2 2x2
155 98 
Reducing Square Matrices

 Determinant:
 The determinant of a matrix is a scalar representation of
matrix; considered the “volume” of the matrix or in the
case of a VCV matrix it is the generalized variance.
 Only square matrices have determinants.
 Determinants are also useful because they tell us
whether or not a matrix can be inverted (next).
 Not all square matrices can be inverted (must be full rank,
non-singular matrix)
Reducing Square Matrices

 Determinant:

C   4 C 4
1 x1

 a1 b1 
C   C   a1 * b2    b1 * a2 
2x2
 a2 b2 
3 2 
C   C   3*1   2*5   3  10  7
2x2
5 1 
Reducing Square Matrices
 Determinant:
 a1 b1 c1 
C   a2 c2 
b2 c2 a2 c2 a2 b2
b2 C  a1  b1  c1
3x3 b3 c3 a3 c3 a3 b3
 a3 b3 c3 
2 2 0 
C   1 5 1 
3x3
 34 5 
C   2(5*5  1* 4)    2(1*5  1*3)   0( 1*5  5*3
C   2(25  5)    2(5  3)    0(5  15
C   40  16   0  24
Find the determinant of below matrix

2 −1 0
A= 1 0 3
1 1 0

0 3 −1 0 −1 0
deter A = 2 −1 +1
1 0 1 0 0 3

= 2(-3) – 1(0) +1(-3)


=-9

0 3 1 3 1 0
deter A = 2 − (−1) +0
1 0 1 0 1 1

= 2(-3) + 1(-3) +0(1)


=-9
Find determinant of below matrix
2 −2 0
A = −1 5 1
3 4 5

5 1 −1 1 −1 5
det. A = 2 − −2 +0
4 5 3 5 3 4

= 2 (25-4) +2 (-5-3) +0
=42 -16 +0
= 26
Matrix Inverse

 Matrix Inverse: Needed to perform the “division” of


2 square matrices
 In scalar terms A/B is the same as A * 1/B
 When we want to divide matrix A by matrix B we simply
multiply by A by the inverse of B
 An inverse matrix is defined as

1 1 1
A  A A  I AND A
Defined
A I
nxn nxn nxn nxn nxn nxn nxn
Matrix Inverse
Matrix Inverse
Singular Matrix

 Singular Matrix: A matrix is considered singular if


the determinant of the matrix is zero
 The matrix cannot be inverted
 Usually caused by linear dependencies between vectors
 When a matrix is not full rank

2 6
A   A   2*3  1*6   0
2x2
1 3
 An extreme form of multicollinearity in the matrix
Solving Set of Linear Equations
Solution
2 −1 0
A= 1 0 3 𝑓𝑖𝑛𝑑 𝐴 𝑖𝑛𝑣𝑒𝑟𝑠?
1 1 0

Step 1 – find the determinant Step 3- find adjugated matrix

det. A = -9

Step 2 – Get Transpose of A

2 1 1
AT = −1 0 1
0 3 0
2 1 1
AT = −1 0 1
0 3 0

−3 0 −3 + − + −3 0 −3
Adjugate matrix = −3 0 6 ∗ − + − = 3 0 −6
1 3 1 + − + 1 −3 1
1
A- = 𝑑𝑒𝑡. 𝐴𝑑𝑢𝑔𝑎𝑡𝑒 𝑚𝑎𝑡𝑟𝑖𝑥

−3 0 −3 1/3 0 1/3
1
= 3 0 −6 = −1/3 0 2/3
−9
1 −3 1 −1/9 1/3 −1/9
1/3 0 1/3
−1/3 0 2/3
A- =
−1/9 1/3 −1/9

𝑥1 1/3 0 1/3 20
𝑥2 = −1/3 0 2/3 40
𝑥3 −1/9 1/3 −1/9 15

1 1
(3 ∗ 20 + 0 ∗ 40 + 3 ∗ 15)
11.667
1 2
= (− 3 ∗ 20 + 0 ∗ 40 + 3 ∗ 15) = 3.333
1 1 1 9.444
(− 9 ∗ 20 + 3 ∗ 40 − 9 ∗ 15)

{ x1 = 11.667, x2 = 3.333 , x3 = 9.444}


3 ways of finding Inverse Matrix

Method 1 : Creating adjugate Matrix


Step 1 – find the determinant of the matrix
2 −1 0
A= 1 0 3
1 1 0

det (A) = 2 (0-3) -1 (0-0) +1(-3-0) = -6-3 = -9

If the determinant is “0” your work is finished because the matrix


does not have inverse.

Step 2 – Transpose the matrix

2 1 1
AT = −1 0 1
0 3 0
Creating Adjugate Method

Step 3 – Find the determinant of 2X2 minor matrices

0 1 −1 1 1 0 2 1 1
= 0 − 3 = −3 =0 =3
3 0 0 0 0 3 AT = −1 0 1
0 3 0
1 1 2 1 2 1
= -3 =0 =6
3 0 0 0 0 3

1 1 2 1 2 1
=1 =3 =1
0 1 −1 1 −1 0

−3 0 −3 + − + −3 0 −3
Adj (A) = −3 0 6 X − + − = 3 0 −6
1 3 1 + − + 1 −3 1
−3 0 −3 0.333 0 0.333
1 1
A-1 = 𝑋 𝐴𝑑𝑗 𝐴 = 3 0 −6 = −0.333 0 0.666
det(𝐴) −9
1 −3 1 −0.111 0.333 −0.111
Example 2:

2𝑥1 − 𝑥2 = 20 ---1
𝑥1 + 3𝑥3 = 40 --- 2 det. A = 0
𝑥1 − 0.5𝑥2 = 10 − −3 𝑡ℎ𝑖𝑠 𝑠𝑒𝑡 𝑜𝑓 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛𝑠 ℎ𝑎𝑠 𝑖𝑛𝑓𝑖𝑛𝑖𝑡𝑦 𝑛𝑜. 𝑠

equations 1 & 3 are same.


2 −1 0 𝑥1 20
1 0 3 𝑥2 = 40
1 −0.5 0 𝑥3 10

A *X =b

40 − 𝑥1
2𝑥1 − 𝑥2 = 20, 𝑥1 + 3𝑥3 = 40, 𝑥3 = , 𝑥2 = 2𝑥1 − 20
3
Home work
2𝑥1 − 𝑥2 = 20
𝑥1 + 3𝑥3 = 40
3𝑥1 − 𝑥2 + 3𝑥3 = 60

You might also like