Matrix Operations
The most common matrix operations are addition, subtraction, multiplication, power, transpose, inverse, and calculating determinant. Let's learn all of them one by one.
Matrix Addition
Matrix addition is only performed if both matrices are the same size. In other words, the matrices to be added should have the exact same number of rows and columns. This means they should have the same dimensions.
Addition Process: When the size/dimensions of the matrices are the same, you need to add the corresponding elements of the matrices to find the sum.
Formula: Ci , j = Ai , j + Bi , j
Here, A and B are the elements of the matrices to be added and C is the resultant matrix.
Matrix Subtraction
Matrix subtraction is very much similar to the matrix addition. It is also performed if both matrices are the same size. In other words, both matrices should have exact same number of rows and columns.
Subtraction Process: You need to subtract the corresponding elements of the matrices.
Formula: Ci , j = Ai , j - Bi , j
Let's understand it with an example.
Example:
C = | | 24 - 12 | | 17 - 8 | 9 - 2 | | 12 - 18 |
| |
---|
|
Matrix Multiplication
There are two types of matrix multiplication to be performed.
1. Scalar Multiplication
In scalar multiplication, each element of the single matrix is multiplied by a scalar value. Let's take an example to understand it.
2. Matrix Multiplication with Other Matrix
To multiply two matrices, the number of columns of the first matrix should be equal to the number of rows of the second matrix.
For example, you can multiply 3 × 4 with 4 × 2. But you can not multiply 3 × 4 with 2 × 4.
Note: Matrix multiplication is not a commutative property. It means, it is not necessary that A × B will always be equal to B × A.
Multiplication Process: Two matrices are multiplied by finding the dot product between the corresponding elements of the row of the first matrix and the column of the second matrix.
Formula:
C1 , 1 = (A1 , 1 , A1 , 2) × (B1 , 1 , B2 , 2)
Or
C1 , 1 = A1 , 1 × B1 , 1 + A1 , 2 × B2 , 2
Here, A and B are the elements of the matrices to be multiplied and c is the resultant matrix.
Example:
C = | | (4 × 1)+(2 × 0) | | (3 × 1)+(5 × 0) | (4 × 6)+(2 × 5) | | (3 × 6)+(5 × 5) |
| |
---|
|
Power of Matrix
Power of matrix meaning is to raise a matrix to a given power.
For example, the given matrix is A. Now calculate matrix A with the power of 2 means: A2 = A × A.
Most importantly, the power can be raised to only square matrices. Because a non-square matrix can not be multiplied by itself.
Matrix Transpose
The transpose of a matrix flips its elements over its diagonal. The row elements become column elements whereas the column elements become row elements. Most importantly, the matrix should not be empty.
Transpose Process: To transpose a matrix just switch the rows and column elements. If the matrix contains 2 rows and 3 columns the matrix will now consist of 3 rows and 2 columns.
Formula: Tm , n = Tn , m = T'
Here, T is a matrix containing m rows and n columns that will become n rows and m columns after transpose.
Matrix Determinant
The Laplace formula is widely used to calculate the determinant of the matrix of any size. Let's understand the process through this formula and example:
Formula:
= a(ei-fh) - b(di-fg) + c(dh-eg)
Example:
= 3(1×4 - 5×3) – 5(7×4 – 5×3) + 2(7×3 – 3×1)
= 3(-11) – 5(13) + 2(18)
= -62
Matrix Inverse
Pre-requisites: The matrix should not be empty and you should know the determinant of that matrix. Also, the determinant should not be equal to zero.
Process: To find the inverse of the matrix we use a simple formula where the inverse of the determinant is multiplied with the adjoint of the matrix.
Formula: A-1 = ( 1 / |A| ) × adj(A)
Where, the adjoint of a matrix is the collection of its cofactors which are the determinants of the minor matrices.