Data Analysis - Matrix
Data Analysis - Matrix
[ ]
15 19
A= 11 17
51 20
[ ]
12 5
A= 10 7
5 2
It can also be written in such a way that the Rows Represent the Fruits,
and the Columns represent the People. Like:
A= [ 125 10 5
7 2 ]
Types of Matrices:
There are mainly 8 types of Matrices:
1. Row Matrix
A matrix that only has one row is known as a Row Matrix.
E.g. [ 1 3 5]
2. Column Matrix
A matrix which contains only one column is known as a Column
Matrix.
[]
2
E.g. 4
6
3. Square Matrix
A matrix having equal number of rows and columns is known as Square
Matrix.
E.g. [ 13 46]
4. Diagonal Matrix
A matrix having all elements as zeros except for its leading diagonal is
known as a Diagonal Matrix.
[ ]
13 0 0
E.g. 0 1 0
0 0 41
5. Scalar Matrix
A Matrix where all the diagonal elements in the leading diagonal has the
same value while others are zero is known as a Scalar Matrix.
[ ]
4 0 0
E.g. 0 4 0
0 0 4
6. Unit Matrix
A Matrix where all the elements in the leading diagonal are 1 and the
rest are zero is known as a Unit Matrix.
[ ]
1 0 0
E.g. 0 1 0
0 0 1
[ ]
16 40 6
E.g. 0 15 7
0 0 16
2. Difference of Matrices
The Difference of 2 matrices is taken in the same manner of their sum.
The elements of the resultant matrix are taken by subtracting their
corresponding values. Just like addition, the 2 matrices should be of the
same order.
A= [ ac bd ] B= [ ge hf ] A-B = [ (a−e) (b−f )
( c−g) (d−h) ]
E.g.
A= [ 1016 1311 ] B= [ 26 58] A-B = [ 108 83 ]
3. Transpose of a Matrix
The transpose of a matrix is obtained by interchanging the rows and
columns of a matrix. It is denoted by AT .
A= [ ac bd ] AT = [ ab cd ]
E.g.
A= [ 13 24] AT = [ 12 34]
4. Multiplication By A Scalar
When we multiply a Matrix by a scalar, we simply multiply all the
elements in the Matrix with the given Scalar.
A= [ ac bd ] A . x=
[ ac .. xx b.x
d.x ]
E.g.
A= [ 13 24] A*2 = [ 26 48 ]
5. Multiplication of Matrices
To multiply 2 given matrices, The number of columns in the first matrix
should be equal to the number of rows in the second matrix. To get the
product of a matrix we multiply the row of the first matrix and multiply
it with the column of the second matrix and take their sum. To get its
first element, We Add the product of the first row of A and first Column
of B. For its second element, we add the product of the second row of A
and second column of B
The resultant Matrix will be of the order: -
(Number of Rows of A) x (Number of Rows of B)
For example, for the given Matrices,
Order of A = 1x2
B = 2x2
AxB = 1x2
A = [1 2] B= [ 13 24]
A∗B=[ ( 1∗1 )+ ( 2∗3 ) ( 1∗2 ) + ( 2∗4 ) ] =[ 8 10 ]
Order of C = 3x2
D = 2x3
CxD = 3x3
[ ]
1 2
C= 3 4 D=
5 6
1 2 3
4 5 6 [ ]
[ ]
(1∗1 ) + ( 2∗4 ) ( 1∗2 )+ ( 2∗5 ) ( 1∗3 ) + ( 2∗6 )
C∗D= ( 3∗1 )+ ( 4∗4 ) ( 3∗2 ) + ( 4∗5 ) (3∗3 )+ ( 4∗6 )
( 5∗1 ) + ( 6∗4 ) ( 5∗2 )+ ( 6∗5 ) ( 5∗3 )+ ( 6∗6 )
[ ]
9 12 15
¿ 19 26 33
29 40 51
6. Determinants of Matrices
The Determinant of a matrix is a scalar value that can be computed from
the elements of the matrix and provides important information about the
matrix. It is denoted by either det(A) or |A|. The determinant is defined
for square matrices only.
For a 3x3 Matrix, the determinant can be found using the following
formula:
[ ]
a b c
A= d e f | A|=a ( e . i−h . f ) −b ( d .i−g . f )+ c ( d . h−g . e )
g h i
E.g.
[ ]
1 2 3
A= 2 4 3 | A|=1 ( 8−9 )−2 ( 4−3 )+3 ( 6−4 )¿−1−2+6¿ 3
1 3 2
7. Inverse of a Matrix
The inverse of a matrix is matrix which when multiplied by the original
matrix gives us an identity matrix.
It is like the reciprocal of a number. When we multiply the number by
its reciprocal, we get 1. Just like that when we multiply a matrix with its
inverse, we get an identity matrix.
2x2 Matrix:
To find the inverse of a 2x2 Matrix, First find its adjoin and then divide
the adjoin with the determinant:
−1 1
i.e. A =
| A|
∗Adjoin
A=
[ ac bd ] Adjoin=[−cd −ba ] A −1
=
1
| A|
∗
[d −b
−c a ]
E.g.
A=
[ 13 24 ]
| A|=4−6=−2
Adjoin=
[−34 −21 ]
[ ]
−2 1
−1 1
A = ∗
4 −2
−2 −3 1
= 3 −1
2 2
[ ]
3x3 Matrix:
Finding the Inverse of a 3x3 Matrix is a bit more difficult than a 2x2
Matrix. It involves Various steps, Such as:
1. Finding Determinant
2. Finding The Co-factor
3. Finding the Adjoin and,
4. Dividing the Adjoin with the Determinant
−1 1
i.e. A =
| A|
∗Adjoin
[ ]
a b c
Let A= d e f
g h i
[ ]
+ ( e . i−f . h ) −( d .i−f . g ) + ( d . h−e . g )
Co−factor= −( b . i−c . h ) + ( a . i−c . g ) − ( a . h−b . g )
+ ( a . e−b . d ) − ( a . f −c . d ) + ( b . f −c . e )
[ ]
+ ( e .i−f . h ) −( b . i−c .h ) + ( a . e−b .d )
Adjoin ¿ −( d . i−f . g ) + ( a .i−c . g ) − ( a . f −c . d )
+ ( d . h−e . g ) − ( a . h−b . g ) + ( b . f −c . e )
[ ]
+ ( e . i−f . h ) −( b . i−c . h ) + ( a . e−b . d )
−1 1
A = ∗ −( d . i−f . g ) + ( a .i−c . g ) −( a . f −c . d )
| A|
+ ( d . h−e . g ) − ( a . h−b . g ) + ( b . f −c . e )
For Example:
[ ]
1 2 3
A= 1 6 4
1 5 3
[ ]
+(18−20) −(3−4) +(5−6)
Co-Factor = −(6−15) +(3−3) −(5−2)
+(8−18) −(4−3) +(6−2)
[ ]
−2 1 −1
= 9 0 −3
−10 −1 4
[ ]
−2 9 −10
Adjoin = 1 0 −1
−1 −3 4
[ ]
2 −10
3
3 3
[ ]
−2/−3 9/3 −10 /3
1 −1
A-1 = 1/3 0/3 −1 /3 =
3
0
3
−1/3 −3/3 4 /3
−1 4
−1
3 3