Transcript class-17

A PRATICAL INTRODUCTION TO MATRICES
The goal is to give an introduction to the mathematical operations with matrices.
A matrix is a 2-dimensional arrangement of (real valued) data. The data entries are
organized in rows and columns, just like in a spreadsheet or a table with data.
More information can be found on Wikipedia.
( http://en.wikipedia.org/wiki/Matrix_%28mathematics%29 )
This brief introduction is by far not complete,
It is NOT a formal
mathematical introduction to Linear Algebra !
A PRATICAL INTRODUCTION TO MATRICES
1
2
3
4
5
6
7
8
A matrix with two rows and four columns
1
2
3
5
6
7
A matrix with two rows and three columns
1
2
5
6
A matrix with two rows and two columns
A PRATICAL INTRODUCTION TO MATRICES
1
2
3
4
5
6
7
8
A matrix with two rows and four columns
1
5
2
6
3
7
4
8
A matrix with two rows and two
columns
A PRATICAL INTRODUCTION TO MATRICES
column 1 column 2 column 3
row 1
row 2
x1,1
x1,2
x1,3
x1,2
x2,2
x2,3
The size of this matrix is
2 rows by 3 columns
(we say ‘2 by 3’ and write ‘2 x 3’)
A PRATICAL INTRODUCTION TO MATRICES
We use two indices
to identify an entry
in the matrix:
a row and column index
column 3
Entry in row 1, column 3:
row 1
Matrix symbols:
Capital letters ‘X’
x1,1
x1,2
x1,3
x1,2
x2,2
x2,3
The size of this matrix is
2 rows by 3 columns
(we say ‘2 by 3’ and write ‘2 x 3’)
or underlined
Capital letters ‘X’
1
2
3
4
5
6
7
8
X
entry (X) 2,3= 7
x1,3 [X] 1,3 (X) 1,3
A PRATICAL INTRODUCTION TO MATRICES
We use two indices
to identify an entry
in the matrix:
a row and column index
Matrix symbols:
Capital letters ‘X’
or underlined
Capital letters ‘X’
(
x1,1
x1,2
x1,3
x1,2
x2,2
x2,3
)
‘(‘ and ‘)’ are used to
embrace the entries,
when writing
matrix arrays
or ‘[‘ and ‘]’ or ‘|’ ‘|’
The size of this matrix is
2 rows by 3 columns
(we say ‘2 by 3’ and write ‘2 x 3’)
A PRATICAL INTRODUCTION TO MATRICES
A square matrix
of size n by n
A rectangular matrix of size
m by n
with n=3
with m=3 and n=6 (m<n)
A rectangular matrix
of size m by n
with m=4 and n=3
(m>n)
BASIC MATRIX OPERATIONS
Multiplication with a scalar:
2
1
2
3
4
5
6
7
8
cX
=
=
2
4
6
8
10
12
14
16
Z
(Z) i,j = c(x) i,j
(For all i and j)
Size: m x n
mxn
BASIC MATRIX OPERATIONS
Addition of Matrices:
1
2
3
4
5
6
7
8
X
Size: m x n
+
+
0
1
0
0
0
0
-1
1
Y
mxn
=
=
1
3
3
4
5
6
6
9
Z
mxn
(Z) i,j = (X) i,j +(Y) i,j
(For all i and j)
BASIC MATRIX OPERATIONS
Transpose of a Matrix
T
1
2
3
4
5
6
7
8
T
X
Size: m x n
=
=
1
5
2
6
3
7
4
8
Y
nxm
(X) i,j = (Y) j,i
(For all i and j)
BASIC MATRIX OPERATIONS
Matrix Multiplication:
AB
Size:
mxn
nxk
=
C
mxk
NOTE: Matrix multiplication is only defined for two matrices when the left matrix A has
the same number of columns as the right matrix B has rows! The resulting matrix
has the same number of rows as the left matrix A and the same number of columns as
the right matrix B.
BASIC MATRIX OPERATIONS
Matrix Multiplication:
A
Size:
B
=
1
5
2
6
1
0
1
3
7
0
1
1
4
8
4x2
C
?
2x3
=
4x3
BASIC MATRIX OPERATIONS
Matrix Multiplication:
A
Size:
B
=
Column 1
Vector
dot product
Row 1
1
5
2
6
1
0
1
3
7
0
1
1
4
8
4x2
C
2x3
1*1+0*5
=
4x3
BASIC MATRIX OPERATIONS
Matrix Multiplication:
A
B
=
C
Column 2
Size:
1
5
2
6
1
0
1
3
7
0
1
1
4
8
4x2
1*1+0*5
2x3
=
Row 3
3*0+7*1
4x3
BASIC MATRIX OPERATIONS
Matrix Multiplication:
A
B
=
C
Column 3
Size:
Row 1
1
5
2
6
1
0
1
3
7
0
1
1
4
8
4x2
2x3
=
1*1+0*5
1*1+5*1
3*0+7*1
4x3
BASIC MATRIX OPERATIONS
Matrix Multiplication:
A
Size:
B
=
1
5
2
6
1
0
1
3
7
0
1
1
4
8
4x2
2x3
=
C
1
5
6
2
6
8
3
7
10
4
8
12
4x3
BASIC MATRIX OPERATIONS
Matrix Multiplication:
AB = C
Size: m x n n x k
ci,j =
mxk
𝑛
𝑘=1 ai,kbk,j
Note: A B is not equal B A !
Rule to remember:
We pick from the left matrix
a row vector (row i) and
from the right
matrix a column vector (column j),
calculate the dot product between
the two vectors and enter the result
in the new matrix in row i, column j.
FINAL NOTE:
Errors can easily sneak into the slides.
 If you find a mistake, please contact me

[email protected]
Thanks!
See also a 5 minute introduction:
http://ed.ted.com/lessons/how-to-organize-add-and-multiply-matrices-bill-shillito