# Matrices

Sub Topics
Matrices are arrangements of numbers in rectangular arrays. The plural for Matrix is Matrices.

$\begin{bmatrix} a_{11} & a_{12} & a_{13} & . &. & . &a_{1n} \\ a_{21} & a_{22} & a_{23} & . &. & . &a_{2n} \\ .& . & .& .&. & . &.\\ .& . & .& . & . & . &. \\ . & . & . & . & . & . & .\\ a_{m1} &a_{m2} & a_{m3} & . &. & . & a_{mn} \end{bmatrix}$

The entries are done in m rows (horizontal lines) and n columns (vertical lines). Each entry $a_{ij}$ is generally a number and is also called an element of the matrix.A matrix with m rows and n columns is called a m x n (read as "m by n") Matrix.  The size of a matrix is indicated by (m x n). If each entry in a matrix is a real number, then the matrix is called a real matrix.

## Notations for a Matrix

1. A matrix can be denoted by uppercase letters like A,B,C.....
2. A matrix can be denoted by writing the representative element inside a bracket like $[a_{ij}]$, $[b_{ij}]$.......
3. A matrix can be written in a rectangular array.

## Matrix Equality

Two Matrices of equal sizes are equal if each entry in one matrix is equal to the corresponding entry in the other matrix.
Matrices $A=[a_{ij}]$ and $B=[b_{ij}]$  of size (m x n) are equal if
$[a_{ij}]=[b_{ij}]$ for 1 ≤ i ≤ m and 1 ≤ j ≤ n.

Example:
Consider the matrices

 $A=\begin{bmatrix} 2 &-1 \\ 0& 3 \end{bmatrix}$ $B=\begin{bmatrix} 2 &-1 \\ 0& 3 \end{bmatrix}$ Matrices A and B are equal as they are of equal size (2 x 2) and each element in Matrix A is equal to corresponding element in B $C=\begin{bmatrix} 1 & 2 & 3 \end{bmatrix}$ $D=\begin{bmatrix} 1\\ 2\\ 3 \end{bmatrix}$ Even though the same elements are used in forming the matricesC and D, they are of different sizes (1 x 3) and (3 x 1)

## Row and Column Matrices

A matrix with only one row as the Matrix C in the above example is called a row matrix. A general row matrix is of size (1 x n).
Similarly a matrix with only one column as Matrix D is known as a column matrix. The size of a general column matrix is (m x 1).
Any matrix can be partitioned into row and column matrices.

## Squrare Matrices

#### Square Matrix

If a matrix has equal number of rows and columns then it is called a square matrix. A general square matrix is of size (n x n).

Example:
$\begin{bmatrix} 1 & -2\\ 3 & 0 \end{bmatrix}$

#### Diagonal matrix

The entries in a diagonal matrix is all zero except the diagonal elements.

Example:
$\begin{bmatrix} 2 & 0 &0 \\ 0 & -1 &0 \\ 0 & 0 & 1 \end{bmatrix}$
If all the elements of a diagonal matrix are equal, then it is called a scalar matrix.

#### Unit or identity matrix

Unit matrix is a scalar (diagonal matrix) with all diagonal elements as unity.

Example:
 $\begin{bmatrix} 1 & 0 &0 \\ 0 & 1 &0 \\ 0 & 0 & 1 \end{bmatrix}$ $\begin{bmatrix}1 & 0 & 0 &0\\ 0& 1 &0 & 0\\ 0& 0 & 1 &0\\ 0& 0& 0 & 1\end{bmatrix}$

## Matrix Operations

Matrix arithmetic consists of addition, subtraction, Scalar multiplication and Matrix multiplication in a manner similar to operations on numbers.

Matrix is addition is defined only for matrices of same size as follows:
If A = $[a_{ij}]$ and B = $[b_{ij}]$ are two matrices of size (m x n) then
A + B = $[a_{ij}+b_{ij}]$

Addition of two matrices of different sizes is not defined.

Example:

 $\begin{bmatrix}3 & 0 &-1 \\ -2 & 5 & 3\end{bmatrix}$ + $\begin{bmatrix}-1 & 2 &3 \\ 0 & -2 & 1\end{bmatrix}$ = $\begin{bmatrix}2 & 2 &2 \\ -2 & 3 & 4\end{bmatrix}$

#### Scalar Multiplication

A scalar refers to a real number.

If A = $[a_{ij}]$ is a m x n  matrix and c a scalar(a real number), then the scalar multiple of A by c is a m x n matrix given by
cA = $[ca_{ij}]$.

For example if A is the column matrix $\begin{bmatrix} -2\\ 1\\ \end{bmatrix}$             and c = 3, then cA is a 3 x 1 matrix
cA = 3A = $\begin{bmatrix} -6\\ 3\\ 9 \end{bmatrix}$.

#### Matrix subtraction

Matrix subtraction is defined combining the definitions of matrix addition and scalar multiplication.
If A = $[a_{ij}]$  then -A represent the scalar product (-1)A. Hence -A = $[-a_{ij}]$.

If A and B are matrices of same size then the difference A - B is the sum of A and (-1)B.
Thus A - B = A + (-1)B.

Example :

If A = $\begin{bmatrix} 1 & 2\\ 2 & 1 \end{bmatrix}$  and B = $\begin{bmatrix} -3 & -2\\ 4 & 2 \end{bmatrix}$, Find 2A - B.
 2A-B = 2$\begin{bmatrix}1 & 2\\ 2 & 1\end{bmatrix}$ + (-1)$\begin{bmatrix}-3 & -2\\ 4 & 2\end{bmatrix}$ = $\begin{bmatrix}2 &4 \\ 4 & 2\end{bmatrix}$ + $\begin{bmatrix}3 &2 \\ -4 & -2\end{bmatrix}$ = $\begin{bmatrix}5 &6 \\ 0 & 0\end{bmatrix}$

#### Properties of Matrix addition and scalar multiplication

 If A,B and C are m x n Matrices and c and d are scalars, then the following properties hold good.

 1. A + B = B + A Commutative property of addition 2. A + (B + C) = (A + B) + C Associative property of addition 3. (cd)A =c(dA) Associative property of scalar multiplication 4. 1A = 1 Multiplicative identity 5. c(A + B) = cA + cB Distributive property 6.(c + d)A = cA + dA Distributive property

## Matrix Multiplication

If matrices are useful to display information, matrix multiplication is used to manipulate and organize the information for the requirement.

#### Definition - Matrix multiplication

If A = $[a_{ij}]$ is a m x n matrix and B = $[b_{ij}]$ is a n x p matrix, then product AB = $[c_{ij}]$ is the m x p matrix where
$c_{ij}=\sum_{k=1}^{n}a_{ik}b_{kj}=a_{i1}b_{1k}+a_{i2}b_{2k}+a_{i3}b_{3k}+.......+a_{in}b_{nj}$

The element in the $i^{th}$ row and the $j^{th}$ column of the product AB is got by multiplying the entries in the $i^{th}$
row of matrix A by the corresponding entries in the $j^{th}^ column of Matrix B and adding up the results. Note: You cannot multiply any two matrices or even any matrices of same size. The condition that makes the matrix multiplication AB possible is Number of columns in the first matrix A = Number of rows in the second matrix B. Example: Find the product AB if it exist for A =$\begin{bmatrix}
-1 & 3\\
4& -5\\
0& 2
\end{bmatrix}$and B =$\begin{bmatrix}
1 & 2\\
0& 7
\end{bmatrix}$A is a 3 x 2 matrix and B a 2 x 2 matrices. Number of columns in matrix A = number of columns in matrix B = 2 Hence A and B are compatible for multiplication and the product AB is a matrix of size 3 x 2. If AB =$\begin{bmatrix}
c_{11} & c_{12}\\
c_{21}& c_{22}\\
c_{31}& c_{32}
\end{bmatrix}$then$c_{11}= (-1)1 +3(0) =-1$First row in A and First column in B$c_{12}= (-1)2 +3(7) =19$First row in A and second column in B$c_{21}= 4(1) -5(0)=4$Second row in A and first column in B$c_{22}= 4(2)-5(7)=-27$Second row in A and second column in B$c_{31}= 0(1)+2(0)=0$Third row in A and first column in B$c_{32}= 0(2)+2(7)=14$Third row in A and second column in B AB =$\begin{bmatrix}
-1 & 19\\
4 & -27\\
0& 14
\end{bmatrix}$#### Properties of Matrix multiplication  If A, B and C are matrices compatible for the products defined and c is a scalar, then the following properties hold good.  1. A(BC) = (AB)C Associative property 2. A(B + C) = AB + AC Left distributive property 3. (A + B)C = AC + BC Right distributive property 4. c(AB) = (cA)B = A(cB) Associative property ## Transpose of a matrix The transpose of a matrix is formed by writing its columns as rows and rows as columns. It is denoted by$A^{T}$If A =$[a_{ij}]$is a m x n matrix then its transpose$A^{T}$=$[a_{ji}]$is a n x m matrix. Example:$A =\begin{bmatrix}
0 & 2 & 1\\
1 & 4 & -1
\end{bmatrix}$A is a 2 x 3 matrix. Then its transpose$A^{T}$is a 3 x 2 matrix.$A^{T}= \begin{bmatrix}
0 &1 \\
2 &4 \\
1& -1
1 & 2 & -2\\
2 & 1 &0 \\
-2 & 0 & 3
0 & -1 &-2 \\
1 & 0 & -1\\
2&1 & 0
\end{bmatrix}$#### Properties of Transposes $(A^{T})^{T}=A$Transpose of the transpose matrix is the matrix.$(A+B)^{T}=A^{T}+B^{T}$Transpose of a sum is the sum of the transposes.${(cA)}^{T}=c(A)^{T}$Scalar Multiple of a transpose$(AB)^{T}=(B)^{T}(A)^{T}$Transpose of a product. ## Deterrminant of a Matrix Determinant is a function that associates a square matrix to a real number. Determinant of a square matrix A is denoted by |A|. Determinant of a 2 x 2 matrix. The determinant of a matrix$A=\begin{vmatrix}
a_{11} & a_{12}\\
a_{21} & a_{22}
\end{vmatrix}$is given by det(A) = |A| =$a_{11}a_{22}-a_{21}a_{12}$Example:$A=\begin{vmatrix}
2&-3 \\
1 & 2
\end{vmatrix}$|A| = 2(2) -1(-3) = 4 + 3 =7 #### Minor of a Matrix Let A =$[a_{ij}]$be a square Matrix. Then the minor$M_{ij}$of the element$a_{ij}$is the determinant of a Matrix obtained by deleting the$i^{th}$row and the$j^{th}$column of A. Example:$A=\begin{bmatrix}
0 &2  & 1\\
3 &  -1&2 \\
4& 0 & 1
\end{bmatrix}$Find the minor of the element 3 A is a 3 x 3 Matrix. The element 3 is row 2 and column 1. Removing row 2 and column from |A|, the minor of 3 is Minor of 3 =$M_{21}$=$\begin{vmatrix}
2 & 1\\
0 & 1
\end{vmatrix}$.=2(1)-0(1) =2 #### Cofactor of a Matrix The cofactor$C_{ij}$of the element$a_{ij}$is$C_{ij}=(-1)^{i+j}M_{ij}$For the example given above the element 3 is row 2 and column 1. i =2 and j =1. Hence Cofactor of 3 =$C_{21}=(-1)^{2+1}M_{21}=(-1)^{3}(2)=-2$#### Expansion of Determinant using cofactors Using Cofactors the determinant of a Square Matrix of order n can be defined. The determinant can be evaluated along any row or any column of the determinant.  Expansion of |A| along the$i^{th}$row$det(A)=|A|=\sum_{j=1}^{n}a_{ij}C_{ij}= a_{i1}C_{i1}+a_{i2}C_{i2}+.......a_{in}C_{in}$Expansion of |A| along the$j^{th}$column$det(A)=|A|=\sum_{i=1}^{n}a_{ij}C_{ij}= a_{1j}C_{1j}+a_{2j}C_{2j}+.......a_{nj}C_{nj}$## Ajoint of a Matrix If C is the matrix formed by the cofactors of Matrix A, then the adjoint of the Matrix A is the transpose of Matrix C. Let A =$\begin{bmatrix}
a_{11} & a_{12} & a_{13} & . &.  & . &a_{1n} \\
a_{21} & a_{22} & a_{23} & . &.  & . &a_{2n} \\
.& . & .&  .&. & . &.\\
.& . &  .& . & . & . &. \\
. & . & . & . & . & . & .\\
a_{n1} &a_{n2}  & a_{n3} & . &.  & . & a_{nn}

\end{bmatrix}$Then the Cofactor Matrix C =$\begin{bmatrix}
C_{11} & C_{12} & C_{13} & . &.  & . &C_{1n} \\
C_{21} & C_{22} & C_{23} & . &.  & . &C_{2n} \\
.& . & .&  .&. & . &.\\
.& . &  .& . & . & . &. \\
. & . & . & . & . & . & .\\
C_{n1} &C_{n2}  & a_{n3} & . &.  & . & C_{nn}

\end{bmatrix}$Then the adjoint of Matrix A adj(A) =$\begin{bmatrix}
a_{11} & a_{21} & a_{31} & . &.  & . &a_{n1} \\
a_{12} & a_{22} & a_{32} & . &.  & . &a_{n2} \\
.& . & .&  .&. & . &.\\
.& . &  .& . & . & . &. \\
. & . & . & . & . & . & .\\
a_{m1} &a_{m2}  & a_{m3} & . &.  & . & a_{mn}