Apart from the vector operations that we learnt previously, we need some knowledge of matrix operations as well. Let’s hear from Mirza as he explains the idea of matrix multiplication.
As you saw in the video, the process of matrix multiplication is quite simple, and it involves the element-wise multiplication followed by addition of all the elements present in it. The one key rule that it must satisfy is when you multiply 2 matrices, say A and B, the number of columns of A must equal the number of rows in B. Visually, you can take a look at the following image to get the idea of how that should be:
As shown in the example, since the number of columns in the first matrix and the number of rows in the second matrix are equal to 4, matrix multiplication is possible and the resultant matrix has a shape of 5 x 6.
The element-wise multiplication followed by addition is also pretty straightforward as can be seen in the following example:
Here is a short video that shows how to do matrix multiplication in Python.
Now answer the following questions to make sure that you’ve understood this concept in detail.
Inverse of a Matrix
To understand what the inverse of a matrix is, let’s take a look at the following example:
Let’s say you have 2 matrices A and B such that A= [2−111] and B = [1/31/3−1/32/3]
If you multiply B with A like this: B x A = [1/31/3−1/32/3][2−111] you get the following result- [1001]
The matrix that you got after the multiplication above is also known as an Identity matrix. In matrix notation, it serves the same function as that of the number 1 in the real number system. To establish an analogy, in the real number system if you multiply any number by 1, you get the number itself. Similarly, when you multiply any matrix with the identity matrix, also denoted by I, you get the same matrix once again. ( You can calculate this and verify yourselves)
Now taking the analogy of the real number system, when you multiply 2 numbers a and b and it comes out to be 1, i.e.
a×b=1
then a and b are called reciprocal of each other.
In the matrix world, if you have two matrices A and B , and their multiplication results in the identity matrix I, i.e.
B x A = I,
then A and B are called inverses of each other.
The inverse of A is also written as A−1. Therefore B=A−1
In a later segment, we’ll get to know as to how these inverses are useful.
Note that A−1A=I=AA−1. You can verify this using the above matrix.
Here’s a short video showing how to find the inverse of a matrix in Python.
Now, use Numpy to calculate the inverse of the matrix in the following question.
Additional Reading
If you want to learn how to find the inverse of a Matrix mathematically, please refer to this link.
Report an error