Skip to content

Mathematics · Ch 3 — Matrices

Multiplication of Matrices

3.4.5

Multiplication of Matrices

3.4.5 Multiplication of Matrices

Understanding the Need for Matrix Multiplication

Meera wants 2 pens and 5 story books; Nadeem needs 8 pens and 10 story books. At the first shop a pen costs ₹5 and a story book ₹50, so Meera needs 5×2+50×5=2605 \times 2 + 50 \times 5 = 260 rupees and Nadeem 8×5+10×50=5408 \times 5 + 10 \times 50 = 540 rupees.

The requirements form a 2×22 \times 2 matrix and the prices a 2×12 \times 1 matrix; multiplying each row of requirements by the price column gives the money needed:

[25810][550]=[5×2+50×58×5+10×50]=[260540]\begin{bmatrix} 2 & 5 \\ 8 & 10 \end{bmatrix}\begin{bmatrix} 5 \\ 50 \end{bmatrix} = \begin{bmatrix} 5 \times 2 + 50 \times 5 \\ 8 \times 5 + 10 \times 50 \end{bmatrix} = \begin{bmatrix} 260 \\ 540 \end{bmatrix}

Now suppose they check another shop where pens cost ₹4 and story books ₹40. Then Meera needs 4×2+40×5=2084 \times 2 + 40 \times 5 = 208 rupees and Nadeem 8×4+10×40=4328 \times 4 + 10 \times 40 = 432 rupees. Combining both price scenarios into one 2×22 \times 2 price matrix:

[25810][545040]=[5×2+50×54×2+40×58×5+10×508×4+10×40]=[260208540432]\begin{bmatrix} 2 & 5 \\ 8 & 10 \end{bmatrix} \begin{bmatrix} 5 & 4 \\ 50 & 40 \end{bmatrix} = \begin{bmatrix} 5 \times 2 + 50 \times 5 & 4 \times 2 + 40 \times 5 \\ 8 \times 5 + 10 \times 50 & 8 \times 4 + 10 \times 40 \end{bmatrix} = \begin{bmatrix} 260 & 208 \\ 540 & 432 \end{bmatrix}

The idea: take rows from the first matrix and columns from the second, multiply corresponding entries, and add them up.

Important

For matrix multiplication to be defined, the number of columns in the first matrix must equal the number of rows in the second matrix.

Formal Definition of Matrix Multiplication

Let A=[aij]A = [a_{ij}] be an m×nm \times n matrix and B=[bjk]B = [b_{jk}] an n×pn \times p matrix. The product ABAB is a matrix C=[cik]C = [c_{ik}] of order m×pm \times p. To find the element cikc_{ik} (in the ii-th row and kk-th column of the product), take the ii-th row of AA,

[ai1  ai2  …  ain],[a_{i1}\; a_{i2}\; \dots\; a_{in}],

and the kk-th column of BB,

[b1kb2k⋮bnk],\begin{bmatrix} b_{1k} \\ b_{2k} \\ \vdots \\ b_{nk} \end{bmatrix},

multiply corresponding elements, and sum them:

cik=ai1b1k+ai2b2k+ai3b3k+⋯+ainbnk=∑j=1naijbjk.c_{ik} = a_{i1}b_{1k} + a_{i2}b_{2k} + a_{i3}b_{3k} + \dots + a_{in}b_{nk} = \sum_{j=1}^{n} a_{ij}b_{jk}.

The index jj runs from 1 to nn, matching the columns of AA with the rows of BB.

Worked Example: Computing a Product

Let

C=[1−12034]2×3,D=[27−115−4]3×2C = \begin{bmatrix} 1 & -1 & 2 \\ 0 & 3 & 4 \end{bmatrix}_{2 \times 3}, \quad D = \begin{bmatrix} 2 & 7 \\ -1 & 1 \\ 5 & -4 \end{bmatrix}_{3 \times 2}

Since CC has 3 columns and DD has 3 rows, the product CDCD is defined and is a 2×22 \times 2 matrix. Computing each entry as (row of CC) · (column of DD):

c11=1(2)+(−1)(−1)+2(5)=2+1+10=13,c12=1(7)+(−1)(1)+2(−4)=7−1−8=−2,c21=0(2)+3(−1)+4(5)=0−3+20=17,c22=0(7)+3(1)+4(−4)=0+3−16=−13.\begin{aligned} c_{11} &= 1(2) + (-1)(-1) + 2(5) = 2 + 1 + 10 = 13, \\ c_{12} &= 1(7) + (-1)(1) + 2(-4) = 7 - 1 - 8 = -2, \\ c_{21} &= 0(2) + 3(-1) + 4(5) = 0 - 3 + 20 = 17, \\ c_{22} &= 0(7) + 3(1) + 4(-4) = 0 + 3 - 16 = -13. \end{aligned}

Therefore

CD=[13−217−13].CD = \begin{bmatrix} 13 & -2 \\ 17 & -13 \end{bmatrix}.

Conditions for Both Products to Exist

If AA is m×nm \times n and BB is k×lk \times l, then ABAB is defined iff n=kn = k, and BABA is defined iff l=ml = m. Both ABAB and BABA are defined iff n=kn = k and l=ml = m. In particular, if AA and BB are square of the same order n×nn \times n, both products are defined and are n×nn \times n.

Non-Commutativity of Matrix Multiplication

Even when both ABAB and BABA are defined, they are not necessarily equal — matrix multiplication is not commutative. …