Calculating Inner Product of 2 Matrices is also called Matrix Multiplication.
Inner Product of 2 Matrices can be calculated Only if Number of Columns in First Matrix is same as Number of Rows in Second Matrix.
The Resulting Matrix has the Same Number of Rows as the First Matrix and Same Number of Columns as the Second Matrix.
For example let's consider an \(M \times N \) Matrix \(A\) consisting of elements \(a_{ij}\) and a \(P \times Q\) Matrix \(B\) consisting of elements \(b_{ij}\).
Inner Product \(AB\) of Matrices \(A\) and \(B\) can be calculated only if \(N=P\). In this case, the Resulting Matrix \(C=AB\) consisting of elements \(c_{ij}\)
shall be an \(M \times Q\) Matrix. The Elements \(c_{ij}\) of Matrix \(C\) is calculated as Dot Product between Vectors formed by elements of \(i^{th}\) Row of Matrix \(A\) and elements of \(j^{th}\) Column of Matrix \(B\) and is given follows
\(c_{ij}= \sum_{k=1}^{N}(a_{ik} \cdot b_{kj})\) (Where \(N=P\) is the Number of Columns in Matrix \(A\) and Number of Rows in Matrix \(B\))
Similary, Inner Product \(BA\) of Matrices \(A\) and \(B\) can be calculated only if \(Q=M\). In this case, the Resulting Matrix \(D=BA\) consisting of elements \(d_{ij}\)
shall be an \(P \times N\) Matrix. The Elements \(d_{ij}\) of Matrix \(D\) is calculated as Dot Product between Vectors formed by elements of \(i^{th}\) Row of Matrix \(B\) and elements of \(j^{th}\) Column of Matrix \(A\) and is given follows
\(d_{ij}= \sum_{k=1}^{Q}(b_{ik} \cdot a_{kj})\) (Where \(Q=M\) is the Number of Columns in Matrix \(B\) and Number of Rows in Matrix \(A\))
To demonstrate how the Matrix Multiplication/Inner Product works, let's consider a \(3 \times 2\) Matrix \(A\) and a \(2 \times 3\) Matrix \(B\) given as follows
The Matrix \(C=AB\) can be calculated as Number of Columns in Matrix \(A\) is same as Number of Rows in Matrix \(B\) (equal to \(2\)). The Matrix \(C\) shall have \(3\) Rows (same Number of Rows as Matrix \(A\)) and
\(3\) Columns (same Number of Columns as Matrix \(B\)). The elements \(c_{ij}\) of Matrix \(C\) is calculated as Dot Product between Vectors formed by elements of \(i^{th}\) Row of Matrix \(A\) and elements of \(j^{th}\) Column of Matrix \(B\) as follows
The Matrix \(D=BA\) can also be calculated as Number of Columns in Matrix \(B\) is same as Number of Rows in Matrix \(A\) (equal to \(3\)). The Matrix \(D\) shall have \(2\) Rows (same Number of Rows as Matrix \(B\)) and
\(2\) Columns (same Number of Columns as Matrix \(A\)). The elements \(d_{ij}\) of Matrix \(D\) is calculated as Dot Product between Vectors formed by elements of \(i^{th}\) Row of Matrix \(B\) and elements of \(j^{th}\) Column of Matrix \(A\) as follows
Let's consider an \(M \times N \) Matrix \(A\) consisting of elements \(a_{ij}\) and a \(N \times Q\) Matrix \(B\) consisting of elements \(b_{ij}\) as given below
Matrix \(A\) above can be considered to have it's Rows (Co-Vectors) given as \(A_1, A_2, \cdots, A_m\) and Matrix \(B\) above can be considered to have it's Columns (Vectors) given as \(B_1, B_2, \cdots, B_q\)
Each Column (Vector) of Resultant Matrix of Inner Product \(AB\) is the Sum of Vectors of the Matrix \(A\) (First Matrix) each Scaled by the Values of Corresponding Column of the Matrix \(B\) (Second Matrix).
Therefore, the Resultant \(M \times Q\) Matrix \(C=AB\) shall have Columns (Vectors) \(C_1, C_2, ..., C_q\) as follows
Thus, Columns (Vectors) of the Resultant Matrix \(C\) are Corresponding Columns (Vectors) of the Matrix \(B\) (Second Matrix) each Pre-Multiplied by Matrix \(A\) (First Matrix).
Also, Each Row (Co-Vector) of Resultant Matrix of Inner Product \(AB\) is the Sum of Co-Vectors of the Matrix \(B\) (Second Matrix) each Scaled by the Values of Corresponding Row of the Matrix \(A\) (First Matrix).
Therefore, the Resultant \(M \times Q\) Matrix \(C=AB\) shall have Rows (Co-Vectors) \(R_1, R_2, ..., R_m\) as follows
Thus, Rows (Co-Vectors) of the Resultant Matrix \(C\) are Corresponding Rows (Co-Vectors) of the Matrix \(A\) (First Matrix) each Post-Multiplied by Matrix \(B\) (Second Matrix).
For any 2 Matrices \(A\) and \(B\), Matrix Multiplication/Inner Product may be Commutative (i.e. \(AB = BA\)), Anti-Commutative (i.e. \(AB = -BA\)) or Non-Commutative (i.e. \(AB \neq BA\) and \(AB \neq -BA\)).