In: Computer Science
Why matrix can be multiplied by itself if and only if it is a square matrix?
The solution to the above program is:-
A matrix is said to be a square matrix if the number of rows is equal to the number of columns.
Matrix multiplication means multiplying each row of 1 st matrix with each column of the 2nd matrix. that is A=[[1,2],[3,4]]
and B=[[4,5],[8,6]] then A*B = [[1*4+2*8,1*5+2*8],[3*4+4*8,3*5+4*6]]. Here each row element is multiplied with corresponding column element in the 2nd matrix. This is the reason if two matrices can't be multiplied if the number of columns of the first matrix is not equal to the number of rows of the second matrix.
consider a 2-dimensional matrix with rows =3 and columns=2
ex:-
A=[[1 2 3],[4 5 6]]
matrix multiplication is possible if and only the number of columns of the 1st matrix is equal to the number of rows of the second matrix.
consider A=(2,3) -------> here writing only the dimensions, not the actual elements.
B=(3,2) --->here matrix has 3 rows and w columns .
A* B ------> multiplying two matrices A and B.
Then the resultant product will be of the dimensions. (2,2) That is it is having 2 rows and 2 columns.
Multiplication of two matrices is not possible if the number of columns of the 1st matrix is not equal to the number of rows of the 2nd matrix.
A=(2,3) and B=(2,3) Here matrix multiplication will not be possible.
A square matrix can be multiplied by itself as the required criteria are satisfied.
A=(2,2) ---> dimensions 2 rows and 2 columns.
A * A =(2,2) X (2,2) ------> number of columns of the 2nd matrix is equal to the number of rows of the second matrix.
That is why a square matrix can be multiplied by itself.
Another example:-
A=(2,3) ----> 2 rows and 3 columns. dimensions of the matrix.
A * A ----> (2,3)X(2,3) ---------> Number of columns of 1 st matrix is not equal to the number of rows of 2nd matrix.
So a normal matrix can't be multiplied by itself.
Thank you.