LINEAR ALGEBRA FOR DATA SCIENCE – ADDS 24.
1F (M03)
Lecture Note - 1
Matrices
Square Matrix
A matrix with an equal number of rows and columns is called a square matrix.
eg
1 0 1 2 4
2 1 0 3 5
6 0 -1
Matrices of the same size
Equal Matrices
Addition of Matrices
Subtraction of a Matrix
eg.
1 2 3 4 0 1
0 -1 2 0 2 3
= -3 2 2
0 -3 -1
Multiplication by a Scalar
Exercise 1
Multiplication of Matrices
Exercise 2
The Product of Two Matrices
Consider equations [1] and [ 2] below,
By adjoining the column vectors in [1] and [2], these two equations can be expressed as the single matrix
equation
3 4 2 -1 10 5
=
5 6 1 2 16 7 [3]
As equation [3] is equivalent to equations [1] and [2], this equivalence defines the product,
3 4 2 -1
5 6 1 2
As a 2 x 2 matrix each of whose entries is the product of the appropriate row from the first matrix and the
appropriate column from the second matrix.
(1st row of A) . (1st column of B) (1st row of A) . (2nd column of B)
=
(2nd row of A) . (1st column of B) (2nd row of A) . (2nd column of B)
Example
In general if A is of size m x n, and B is of size n x p then AB is of size m x p.
Summary
Exercise 3
The Meaning of An where n is a Positive Integer
The Associative Law
Special Matrices
The Unit Matrix (Identity Matrix)
A square matrix which has 1 s down the diagonal from top left to bottom right and has 0s elsewhere is
called an identity matrix.
AI = IA =A
where I is the identity matrix and A is a square matrix of the same size.
The Null Matrix (Zero Matrix)
However, from the below example it can be seen that the product of two non-zero matrices can be a zero
matrix.
5 2 2 4 0 0
=
10 4 -5 -10 0 0
The Sub Matrix
The sub matrix of a matrix A is any matrix obtained from A by omitting some rows and columns in A. A
is a sub matrix of itself (obtained by deleting zero rows and columns).
Diagonal Matrix
A diagonal matrix is a square matrix which has zero entries at all points off the main diagonal. One
particular sort of diagonal matrix is an identity matrix.
Examples for diagonal matrices,
3 0 3 0 6 0 0 1 0 0 0
, , ,
0 2 0 0 0 -2 0 0 2 0 0
0 0 1 0 0 4 0
0 0 0 7
Transpose of a Matrix
If any matrix whose (i , j) entry is aij , the transpose of A (denoted by AT) is the matrix whose ( i , j ) entry
aji.
Notice that the rows of AT are the columns of A and vice versa. If A is an m x n matrix, then AT is an
n x m matrix.
T
T 1 2 3
1 2 1 3 1 4
=
=
3 4 2 4 4 5 6 2 5
3 6
The transpose operation on matrices satisfies the following properties,
1)
(A + B)T = AT + BT
2)
(AT)T = A
3)
(kA)T = kAT , for k a scalar
4)
(AB)T = BT AT
Symmetric Matrices
A square matrix is symmetric if the refection in the main diagonal leaves the matrix unchanged. A is
symmetric if AT = A. Sums of symmetric matrices are symmetric, but products are generally not.
T
3 1 2 3 1 2
1 1 -4 = 1 1 -4
2 -4 -1 2 -4 -1
Therefore, above is a symmetric matrix.
Skew Symmetric matrices
A skew symmetric matrix is a matrix for which AT = - A, where all diagonal elements are 0. (The off
diagonal entries are equal but opposite in sign.
eg
( ) =( )=-( )
= = -
Orthogonal Matrices
An orthogonal matrix is a square matrix for which AT A = I and A AT = I.
Examples for orthogonal matrices,
1)
2)
Exercise 4
Determinants
Determinant of a 2 x 2 matrix
Example
Exercises 5
The determinant of a 3 x 3 Matrix
The minor of aij is denoted by |Mij| The signed minor, (-1)i +j |Mij| is called the cofactor of aij
Applications of Determinant
Exercise 6
Properties of Determinants
Let A be a square matrix
1) |A| = |AT |
2) If A has a row (column) of zeros, then |A| = 0
3) If A has two identical rows (columns), then |A| = 0
Singular Matrices and Non Singular Matrices
1) If |A| ≠ 0, A is non-singular
2) If |A| = 0, A is singular
If A is non –singular, the rows (columns) of A are linearly independent.
Dot Product (Scalar Product)
This product of two vectors results in a scalar quantity. You multiply one vector by the component of the
second vector that is parallel to the first vector.
a . b = |a||b| cosθ
i.i=1 i.j=0
j.j=1 i.k=0
|a|
k.k=1 j.k=0
θ
|b|
a . b = (x1i + y1j + z1k) . (x2i + y2j + z2k)
= x1x2 + y1y2 + z1z2
Cross Product (Vector Product)
Vector Product of Parallel Vectors
Vector Product of Perpendicular Vectors
Vector Product of Vectors in Cartesian Component Form
Examples
Exercise 7
Simplify the following.
a) (a + b) x b
b) (a + b) x (a + b)
c) (a - b) x (a + b)
d) a x (b + c) . b
e) a . (b + c) x a
If a = i + j – k and b = 2i - j + k find
1) a x b 2) a x (a + b)
Applications of the Vector Product
1) Area of a Parallelogram
2) Area of a Triangle
Example
3) Volume of a Parallelepiped
4) Volume of Tetrahedron
Example
Triple Scalar Product Property
axb.c = a.bxc
The Vector Product is Distributive
a x b + a x c = a x (b + c)
Inverse of a Matrix
The Inverse of 2 X 2 Matrix
Steps to find the Inverse of a 2 x 2 matrix
Example
Exercise 8
Find where it exists, the inverse of
a) b) c) d)
2 0 3 -1 3 -1 0 1
0 1 4 2 -6 2 0 2
Steps to find the Inverse of a 3 x 3 matrix
Properties of Inverse Matrices
Exercise 5
For each of the matrices given below, find a) the transpose matrix, b) the adjoint matrix, c) where
it exists the inverse matrix