mail  mail@stemandmusic.in
    
call  +91-9818088802
Donate

Matrix Multiplication: Inner Product of Matrices

  1. Calculating Inner Product of 2 Matrices is also called Matrix Multiplication.
  2. 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

    \(A=\begin{bmatrix}a_{11} & a_{12}\\a_{21} & a_{22}\\a_{31} & a_{32}\end{bmatrix}=\begin{bmatrix}-9 & 2\\3 & 7\\5 & 4\end{bmatrix} \hspace{5mm} B= \begin{bmatrix}b_{11} & b_{12} & b_{13}\\b_{21} & b_{22} & b_{23}\end{bmatrix}= \begin{bmatrix}6 & -2 & -1\\5 & 7 & -3\end{bmatrix}\)

    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

    \(c_{11}=a_{11} \cdot b_{11} + a_{12} \cdot b_{21},\hspace{.3cm} c_{12}=a_{11} \cdot b_{12} + a_{12} \cdot b_{22},\hspace{.3cm} c_{13}=a_{11} \cdot b_{13} + a_{12} \cdot b_{23},\)
    \(c_{21}=a_{21} \cdot b_{11} + a_{22} \cdot b_{21},\hspace{.3cm} c_{22}=a_{21} \cdot b_{12} + a_{22} \cdot b_{22},\hspace{.3cm} c_{23}=a_{21} \cdot b_{13} + a_{22} \cdot b_{23},\)
    \(c_{31}=a_{31} \cdot b_{11} + a_{32} \cdot b_{21},\hspace{.3cm} c_{32}=a_{31} \cdot b_{12} + a_{32} \cdot b_{22},\hspace{.3cm} c_{33}=a_{31} \cdot b_{13} + a_{32} \cdot b_{23}\)

    Hence Matrix \(C\) is given as

    \(C=AB=\begin{bmatrix}a_{11} & a_{12}\\a_{21} & a_{22}\\a_{31} & a_{32}\end{bmatrix}\begin{bmatrix}b_{11} & b_{12} & b_{13}\\b_{21} & b_{22} & b_{23}\end{bmatrix} =\begin{bmatrix}-9 & 2\\3 & 7\\5 & 4\end{bmatrix}\begin{bmatrix}6 & -2 & -1\\5 & 7 & -3\end{bmatrix}= \begin{bmatrix}c_{11} & c_{12} & c_{13}\\c_{21} & c_{22} & c_{23}\\c_{31} & c_{32} & c_{33}\end{bmatrix}\)

    \(\Rightarrow C=\begin{bmatrix}a_{11} \cdot b_{11} + a_{12} \cdot b_{21} & a_{11} \cdot b_{12} + a_{12} \cdot b_{22} & a_{11} \cdot b_{13} + a_{12} \cdot b_{23}\\ a_{21} \cdot b_{11} + a_{22} \cdot b_{21} & a_{21} \cdot b_{12} + a_{22} \cdot b_{22} & a_{21} \cdot b_{13} + a_{22} \cdot b_{23}\\ a_{31} \cdot b_{11} + a_{32} \cdot b_{21} & a_{31} \cdot b_{12} + a_{32} \cdot b_{22} & a_{31} \cdot b_{13} + a_{32} \cdot b_{23}\end{bmatrix} =\begin{bmatrix}-9 \cdot 6 + 2 \cdot 5 & -9 \cdot -2 + 2 \cdot 7 & -9 \cdot -1 + 2 \cdot -3\\ 3 \cdot 6 + 7 \cdot 5 & 3 \cdot -2 + 7 \cdot 7 & 3 \cdot -1 + 7 \cdot -3\\ 5 \cdot 6 + 4 \cdot 5 & 5 \cdot -2 + 4 \cdot 7 & 5 \cdot -1 + 4 \cdot -3\end{bmatrix}= \begin{bmatrix}-44 & 32 & 3 \\ 53 & 43 & -24 \\ 50 & 18 & -17\end{bmatrix} \)

    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

    \(d_{11}=b_{11} \cdot a_{11} + b_{12} \cdot a_{21} + b_{13} \cdot a_{31},\hspace{.3cm} d_{12}=b_{11} \cdot a_{12} + b_{12} \cdot a_{22} + b_{13} \cdot a_{32},\)
    \(d_{21}=b_{21} \cdot a_{11} + b_{22} \cdot a_{21} + b_{23} \cdot a_{31},\hspace{.3cm} d_{22}=b_{21} \cdot a_{12} + b_{22} \cdot a_{22} + b_{23} \cdot a_{32}\)

    Hence Matrix \(D\) is given as

    \(D=BA=\begin{bmatrix}b_{11} & b_{12} & b_{13}\\b_{21} & b_{22} & b_{23}\end{bmatrix}\begin{bmatrix}a_{11} & a_{12}\\a_{21} & a_{22}\\a_{31} & a_{32}\end{bmatrix}=\begin{bmatrix}6 & -2 & -1\\5 & 7 & -3\end{bmatrix}\begin{bmatrix}-9 & 2\\3 & 7\\5 & 4\end{bmatrix} =\begin{bmatrix}d_{11} & d_{12}\\d_{21} & d_{22}\end{bmatrix}\)

    \(\Rightarrow D=\begin{bmatrix}b_{11} \cdot a_{11} + b_{12} \cdot a_{21} + b_{13} \cdot a_{31} & b_{11} \cdot a_{12} + b_{12} \cdot a_{22} + b_{13} \cdot a_{32}\\ b_{21} \cdot a_{11} + b_{22} \cdot a_{21} + b_{23} \cdot a_{31} & b_{21} \cdot a_{12} + b_{22} \cdot a_{22} + b_{23} \cdot a_{32}\end{bmatrix}= \begin{bmatrix}6 \cdot -9 + -2 \cdot 3 + -1 \cdot 5 & 6 \cdot 2 + -2 \cdot 7 + -1 \cdot 4 \\ 5 \cdot -9 + 7 \cdot 3 + -3 \cdot 5 & 5 \cdot 2 + 7 \cdot 7 + -3 \cdot 4 \end{bmatrix}= \begin{bmatrix}-65 & -6 \\ -39 & 47\end{bmatrix}\)
  3. 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

    \(A=\begin{bmatrix} a_{11} & a_{12} & ... & a_{1n}\\ a_{21} & a_{22} & ... & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\a_{m1} & a_{m2} & ... & a_{mn}\end{bmatrix}= \begin{bmatrix}A_1 \\ A_2 \\ \vdots \\ A_m\end{bmatrix} \hspace{6mm}B=\begin{bmatrix} b_{11} & b_{12} & ... & b_{1q}\\ b_{21} & b_{22} & ... & b_{2q} \\ \vdots & \vdots & \ddots & \vdots \\b_{n1} & b_{n2} & ... & b_{nq}\end{bmatrix}=\begin{bmatrix}B_1 & B_2 & \cdots & B_q\end{bmatrix}\)

    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

    \(C_1=b_{11}\begin{bmatrix}a_{11}\\a_{21}\\\vdots\\a_{m1}\end{bmatrix} + b_{21}\begin{bmatrix}a_{12}\\a_{22}\\\vdots\\a_{m2}\end{bmatrix} + \cdots + b_{n1}\begin{bmatrix}a_{1n}\\a_{2n}\\\vdots\\a_{mn}\end{bmatrix}\)

    \(C_2=b_{12}\begin{bmatrix}a_{11}\\a_{21}\\\vdots\\a_{m1}\end{bmatrix} + b_{22}\begin{bmatrix}a_{12}\\a_{22}\\\vdots\\a_{m2}\end{bmatrix} + \cdots + b_{n2}\begin{bmatrix}a_{1n}\\a_{2n}\\\vdots\\a_{mn}\end{bmatrix}\)

    \(C_3=b_{13}\begin{bmatrix}a_{11}\\a_{21}\\\vdots\\a_{m1}\end{bmatrix} + b_{23}\begin{bmatrix}a_{12}\\a_{22}\\\vdots\\a_{m2}\end{bmatrix} + \cdots + b_{n3}\begin{bmatrix}a_{1n}\\a_{2n}\\\vdots\\a_{mn}\end{bmatrix}\)

    \(\vdots\)

    \(C_q=b_{1q}\begin{bmatrix}a_{11}\\a_{21}\\\vdots\\a_{m1}\end{bmatrix} + b_{2q}\begin{bmatrix}a_{12}\\a_{22}\\\vdots\\a_{m2}\end{bmatrix} + \cdots + b_{nq}\begin{bmatrix}a_{1n}\\a_{2n}\\\vdots\\a_{mn}\end{bmatrix}\)

    \(\Rightarrow C= \begin{bmatrix}C_1 & C_2 & \cdots & C_q\end{bmatrix} = \begin{bmatrix}AB_1 & AB_2 & \cdots & AB_q\end{bmatrix} = A \begin{bmatrix}B_1 & B_2 & \cdots & B_q\end{bmatrix}\)

    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

    \(R_1=a_{11}\begin{bmatrix}b_{11}& b_{12} &\cdots& b_{1q}\end{bmatrix} + a_{12}\begin{bmatrix}b_{21}& b_{22}& \cdots & b_{2q}\end{bmatrix} + \cdots + a_{1n}\begin{bmatrix}b_{n1}&b_{n2}& \cdots & b_{nq}\end{bmatrix}\)

    \(R_2=a_{21}\begin{bmatrix}b_{11}& b_{12} &\cdots& b_{1q}\end{bmatrix} + a_{22}\begin{bmatrix}b_{21}& b_{22}& \cdots & b_{2q}\end{bmatrix} + \cdots + a_{2n}\begin{bmatrix}b_{n1}&b_{n2}& \cdots & b_{nq}\end{bmatrix}\)

    \(R_3=a_{31}\begin{bmatrix}b_{11}& b_{12} &\cdots& b_{1q}\end{bmatrix} + a_{32}\begin{bmatrix}b_{21}& b_{22}& \cdots & b_{2q}\end{bmatrix} + \cdots + a_{3n}\begin{bmatrix}b_{n1}&b_{n2}& \cdots & b_{nq}\end{bmatrix}\)

    \(\vdots\)

    \(R_m=a_{m1}\begin{bmatrix}b_{11}& b_{12} &\cdots& b_{1q}\end{bmatrix} + a_{m2}\begin{bmatrix}b_{21}& b_{22}& \cdots & b_{2q}\end{bmatrix} + \cdots + a_{mn}\begin{bmatrix}b_{n1}&b_{n2}& \cdots & b_{nq}\end{bmatrix}\)

    \(\Rightarrow C= \begin{bmatrix}R_1 \\ R_2 \\ \vdots \\ R_m\end{bmatrix} = \begin{bmatrix}A_1B \\ A_2B \\ \vdots \\ A_mB\end{bmatrix} = \begin{bmatrix}A_1 \\ A_2 \\ \vdots \\ A_m\end{bmatrix} B\)

    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).
  4. 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\)).
  5. You can use the Matrix Multiplication / Inner Product Calculator to calculate Inner Product of Matrices.
Related Calculators
Matrix Multiplication / Inner Product Calculator
Related Topics
Dot Product of 2 Row/Column Matrices,    Hadamard Product: Element Wise Matrix Multiplication,    Double-Dot Product of 2 Matrices,    Kronecker Product: Outer Product of Matrices,    Tensor Product of Matrices,    Introduction to Matrix Algebra
© Invincible IDeAS. All Rights Reserved