• Nakafa

    Nakafa

    Learn free and with quality.
Subject
    • Grade 10
    • Grade 11
    • Grade 12
Exercises
Holy
  • Quran
Articles
  • Politics
  • Community
  • About

Command Palette

Search for a command to run...

Matrix

Matrix Multiplication

Understanding the Multiplication of Two Matrices

Matrix multiplication is a fundamental operation in linear algebra. Unlike matrix addition or subtraction where elements are operated on directly, matrix multiplication has its own specific rules.

Condition for Matrix Multiplication

Two matrices, let's say matrix AAA and matrix BBB, can be multiplied (A×BA \times BA×B) only if the number of columns in matrix AAA is equal to the number of rows in matrix BBB.

Suppose matrix AAA has an order of m×nm \times nm×n (meaning mmm rows and nnn columns) and matrix BBB has an order of n×pn \times pn×p (meaning nnn rows and ppp columns).

Since the number of columns in matrix AAA (nnn) is equal to the number of rows in matrix BBB (nnn), then matrix AAA and BBB can be multiplied.

The result of the multiplication, let's call it matrix C=ABC = ABC=AB, will have an order of m×pm \times pm×p.

How to Calculate the Elements of the Resultant Matrix

The element cijc_{ij}cij​ in matrix CCC (i.e., the element in the iii-th row and jjj-th column) is calculated by multiplying each element in the iii-th row of matrix AAA by the corresponding element in the jjj-th column of matrix BBB, and then summing all these products.

Mathematically, if A=[aik]A = [a_{ik}]A=[aik​] and B=[bkj]B = [b_{kj}]B=[bkj​], then the element cijc_{ij}cij​ of matrix C=ABC = ABC=AB is:

cij=∑k=1naikbkj=ai1b1j+ai2b2j+⋯+ainbnjc_{ij} = \sum_{k=1}^{n} a_{ik}b_{kj} = a_{i1}b_{1j} + a_{i2}b_{2j} + \dots + a_{in}b_{nj}cij​=k=1∑n​aik​bkj​=ai1​b1j​+ai2​b2j​+⋯+ain​bnj​

The notation ∑\sum∑ (sigma) means summation.

In the formula above, we sum the products aikbkja_{ik}b_{kj}aik​bkj​ for all values of kkk from 1 to nnn.

Steps to Multiply Matrices

Let's look at a simple example to understand the process.

Suppose we have matrices P=[p11p12p21p22]P = \begin{bmatrix} p_{11} & p_{12} \\ p_{21} & p_{22} \end{bmatrix}P=[p11​p21​​p12​p22​​] and Q=[q11q12q21q22]Q = \begin{bmatrix} q_{11} & q_{12} \\ q_{21} & q_{22} \end{bmatrix}Q=[q11​q21​​q12​q22​​].

Matrix PPP has an order of 2×22 \times 22×2 and matrix QQQ also has an order of 2×22 \times 22×2. The number of columns in PPP (which is 2) is equal to the number of rows in QQQ (which is 2), so we can multiply them. The result, R=PQR = PQR=PQ, will have an order of 2×22 \times 22×2.

R=[r11r12r21r22]R = \begin{bmatrix} r_{11} & r_{12} \\ r_{21} & r_{22} \end{bmatrix}R=[r11​r21​​r12​r22​​]

The elements of matrix RRR are calculated as follows:

r11=(row 1 of P)⋅(column 1 of Q)=p11q11+p12q21r_{11} = (\text{row 1 of } P) \cdot (\text{column 1 of } Q) = p_{11}q_{11} + p_{12}q_{21}r11​=(row 1 of P)⋅(column 1 of Q)=p11​q11​+p12​q21​
r12=(row 1 of P)⋅(column 2 of Q)=p11q12+p12q22r_{12} = (\text{row 1 of } P) \cdot (\text{column 2 of } Q) = p_{11}q_{12} + p_{12}q_{22}r12​=(row 1 of P)⋅(column 2 of Q)=p11​q12​+p12​q22​
r21=(row 2 of P)⋅(column 1 of Q)=p21q11+p22q21r_{21} = (\text{row 2 of } P) \cdot (\text{column 1 of } Q) = p_{21}q_{11} + p_{22}q_{21}r21​=(row 2 of P)⋅(column 1 of Q)=p21​q11​+p22​q21​
r22=(row 2 of P)⋅(column 2 of Q)=p21q12+p22q22r_{22} = (\text{row 2 of } P) \cdot (\text{column 2 of } Q) = p_{21}q_{12} + p_{22}q_{22}r22​=(row 2 of P)⋅(column 2 of Q)=p21​q12​+p22​q22​

Example of Multiplying Two Matrices

Given two matrices:

A=[−72−210−123−1]A = \begin{bmatrix} -7 & 2 & -2 \\ 1 & 0 & -1 \\ 2 & 3 & -1 \end{bmatrix}A=​−712​203​−2−1−1​​
B=[12−1320]B = \begin{bmatrix} 1 & 2 \\ -1 & 3 \\ 2 & 0 \end{bmatrix}B=​1−12​230​​

Matrix AAA has an order of 3×33 \times 33×3 and matrix BBB has an order of 3×23 \times 23×2.

The number of columns in matrix AAA (which is 3) is equal to the number of rows in matrix BBB (which is 3).

So, ABABAB can be calculated and will result in a matrix of order 3×23 \times 23×2.

Let's calculate C=ABC = ABC=AB:

C=[c11c12c21c22c31c32]C = \begin{bmatrix} c_{11} & c_{12} \\ c_{21} & c_{22} \\ c_{31} & c_{32} \end{bmatrix}C=​c11​c21​c31​​c12​c22​c32​​​
c11=(−7)(1)+(2)(−1)+(−2)(2)=−7−2−4=−13c_{11} = (-7)(1) + (2)(-1) + (-2)(2) = -7 - 2 - 4 = -13c11​=(−7)(1)+(2)(−1)+(−2)(2)=−7−2−4=−13
c12=(−7)(2)+(2)(3)+(−2)(0)=−14+6+0=−8c_{12} = (-7)(2) + (2)(3) + (-2)(0) = -14 + 6 + 0 = -8c12​=(−7)(2)+(2)(3)+(−2)(0)=−14+6+0=−8
c21=(1)(1)+(0)(−1)+(−1)(2)=1+0−2=−1c_{21} = (1)(1) + (0)(-1) + (-1)(2) = 1 + 0 - 2 = -1c21​=(1)(1)+(0)(−1)+(−1)(2)=1+0−2=−1
c22=(1)(2)+(0)(3)+(−1)(0)=2+0+0=2c_{22} = (1)(2) + (0)(3) + (-1)(0) = 2 + 0 + 0 = 2c22​=(1)(2)+(0)(3)+(−1)(0)=2+0+0=2
c31=(2)(1)+(3)(−1)+(−1)(2)=2−3−2=−3c_{31} = (2)(1) + (3)(-1) + (-1)(2) = 2 - 3 - 2 = -3c31​=(2)(1)+(3)(−1)+(−1)(2)=2−3−2=−3
c32=(2)(2)+(3)(3)+(−1)(0)=4+9+0=13c_{32} = (2)(2) + (3)(3) + (-1)(0) = 4 + 9 + 0 = 13c32​=(2)(2)+(3)(3)+(−1)(0)=4+9+0=13

So, the result of the matrix multiplication ABABAB is:

AB=[−13−8−12−313]AB = \begin{bmatrix} -13 & -8 \\ -1 & 2 \\ -3 & 13 \end{bmatrix}AB=​−13−1−3​−8213​​

Now, what about BABABA?

Matrix BBB has an order of 3×23 \times 23×2 and matrix AAA has an order of 3×33 \times 33×3.

The number of columns in matrix BBB (which is 2) is not equal to the number of rows in matrix AAA (which is 3).

Therefore, the multiplication BABABA is undefined. This illustrates one of the important properties of matrix multiplication.

Properties of Matrix Multiplication

Matrix multiplication has several important properties:

  1. Generally Not Commutative:

    This means AB≠BAAB \neq BAAB=BA. We have already seen an example above where ABABAB is defined but BABABA is not. Even if both are defined, the results are not necessarily the same.

  2. Associative:

    If the matrix multiplications A,B,A, B,A,B, and CCC are defined, then (AB)C=A(BC)(AB)C = A(BC)(AB)C=A(BC) holds. This means the order of grouping the multiplication does not change the final result.

  3. Distributive:

    Matrix multiplication is distributive over matrix addition or subtraction:

    A(B+C)=AB+ACA(B + C) = AB + ACA(B+C)=AB+AC
    (A+B)C=AC+BC(A + B)C = AC + BC(A+B)C=AC+BC

    This holds if all involved addition and multiplication operations are defined.

  4. Multiplication by Identity Matrix (III):

    If AAA is a square matrix of order n×nn \times nn×n and III is the identity matrix of order n×nn \times nn×n, then:

    AI=IA=AAI = IA = AAI=IA=A

    The identity matrix acts like the number 1 in ordinary number multiplication.

  5. Multiplication by a Scalar (kkk):

    If kkk is a scalar (real number), then:

    k(AB)=(kA)B=A(kB)k(AB) = (kA)B = A(kB)k(AB)=(kA)B=A(kB)

Calculating Revenue

Matrix multiplication is very useful in various fields, one of which is for managing data and calculating aggregate values.

Imagine a home industry produces three types of food: tempeh chips, banana chips, and potato chips.

These foods are marketed in three places: Place A, Place B, and Place C.

The number of chips (in jars) sold in each place is presented in matrix PPP. The columns in matrix PPP respectively represent Place A, Place B, and Place C, while the rows respectively represent tempeh chips, banana chips, and potato chips.

P=[151220251015151520]Tempeh ChipsBanana ChipsPotato ChipsP = \begin{bmatrix} 15 & 12 & 20 \\ 25 & 10 & 15 \\ 15 & 15 & 20 \end{bmatrix} \begin{matrix} \text{Tempeh Chips} \\ \text{Banana Chips} \\ \text{Potato Chips} \end{matrix}P=​152515​121015​201520​​Tempeh ChipsBanana ChipsPotato Chips​

The first row ([151220]\begin{bmatrix} 15 & 12 & 20 \end{bmatrix}[15​12​20​]) means 15 jars of tempeh chips were sold in Place A, 12 in Place B, and 20 in Place C.

The price for each jar of chips (in rupiah) is stated in the column matrix QQQ below:

Q=[20,00015,00030,000]Price of Tempeh ChipsPrice of Banana ChipsPrice of Potato ChipsQ = \begin{bmatrix} 20,000 \\ 15,000 \\ 30,000 \end{bmatrix} \begin{matrix} \text{Price of Tempeh Chips} \\ \text{Price of Banana Chips} \\ \text{Price of Potato Chips} \end{matrix}Q=​20,00015,00030,000​​Price of Tempeh ChipsPrice of Banana ChipsPrice of Potato Chips​

To determine the total revenue from each type of chip across all places, we can multiply matrix PPP by matrix QQQ.

However, pay attention to the order of the matrices. Matrix PPP has an order of 3×33 \times 33×3 and matrix QQQ has an order of 3×13 \times 13×1. The number of columns in PPP (3) is equal to the number of rows in QQQ (3), so PQPQPQ can be calculated and will result in a matrix RRR of order 3×13 \times 13×1.

Matrix R=PQR = PQR=PQ will show the total revenue for each type of chip.

R=PQ=[151220251015151520][20,00015,00030,000]R = PQ = \begin{bmatrix} 15 & 12 & 20 \\ 25 & 10 & 15 \\ 15 & 15 & 20 \end{bmatrix} \begin{bmatrix} 20,000 \\ 15,000 \\ 30,000 \end{bmatrix}R=PQ=​152515​121015​201520​​​20,00015,00030,000​​
R=[(15)(20,000)+(12)(15,000)+(20)(30,000)(25)(20,000)+(10)(15,000)+(15)(30,000)(15)(20,000)+(15)(15,000)+(20)(30,000)]R = \begin{bmatrix} (15)(20,000) + (12)(15,000) + (20)(30,000) \\ (25)(20,000) + (10)(15,000) + (15)(30,000) \\ (15)(20,000) + (15)(15,000) + (20)(30,000) \end{bmatrix}R=​(15)(20,000)+(12)(15,000)+(20)(30,000)(25)(20,000)+(10)(15,000)+(15)(30,000)(15)(20,000)+(15)(15,000)+(20)(30,000)​​
R=[300,000+180,000+600,000500,000+150,000+450,000300,000+225,000+600,000]R = \begin{bmatrix} 300,000 + 180,000 + 600,000 \\ 500,000 + 150,000 + 450,000 \\ 300,000 + 225,000 + 600,000 \end{bmatrix}R=​300,000+180,000+600,000500,000+150,000+450,000300,000+225,000+600,000​​
R=[1,080,0001,100,0001,125,000]Total Revenue from Tempeh ChipsTotal Revenue from Banana ChipsTotal Revenue from Potato ChipsR = \begin{bmatrix} 1,080,000 \\ 1,100,000 \\ 1,125,000 \end{bmatrix} \begin{matrix} \text{Total Revenue from Tempeh Chips} \\ \text{Total Revenue from Banana Chips} \\ \text{Total Revenue from Potato Chips} \end{matrix}R=​1,080,0001,100,0001,125,000​​Total Revenue from Tempeh ChipsTotal Revenue from Banana ChipsTotal Revenue from Potato Chips​

From matrix RRR, we can see that the total revenue from the sale of tempeh chips is Rp1,080,000, banana chips Rp1,100,000, and potato chips Rp1,125,000.

If the question is "determine the revenue matrix for each place", then we need to arrange the price matrix QQQ differently or perform multiplication with the transpose of PPP.

Suppose we want to find the total revenue in Place A, Place B, and Place C. We can use the price matrix as a row matrix QT=[20,00015,00030,000]Q^T = \begin{bmatrix} 20,000 & 15,000 & 30,000 \end{bmatrix}QT=[20,000​15,000​30,000​] and multiply it by matrix PPP: S=QTPS = Q^T PS=QTP.

Matrix QTQ^TQT has an order of 1×31 \times 31×3 and PPP has an order of 3×33 \times 33×3. The result SSS will have an order of 1×31 \times 31×3.

S=[20,00015,00030,000][151220251015151520]S = \begin{bmatrix} 20,000 & 15,000 & 30,000 \end{bmatrix} \begin{bmatrix} 15 & 12 & 20 \\ 25 & 10 & 15 \\ 15 & 15 & 20 \end{bmatrix}S=[20,000​15,000​30,000​]​152515​121015​201520​​
s11=(20,000)(15)+(15,000)(25)+(30,000)(15)=300,000+375,000+450,000=1,125,000s_{11} = (20,000)(15) + (15,000)(25) + (30,000)(15) = 300,000 + 375,000 + 450,000 = 1,125,000s11​=(20,000)(15)+(15,000)(25)+(30,000)(15)=300,000+375,000+450,000=1,125,000
s12=(20,000)(12)+(15,000)(10)+(30,000)(15)=240,000+150,000+450,000=840,000s_{12} = (20,000)(12) + (15,000)(10) + (30,000)(15) = 240,000 + 150,000 + 450,000 = 840,000s12​=(20,000)(12)+(15,000)(10)+(30,000)(15)=240,000+150,000+450,000=840,000
s13=(20,000)(20)+(15,000)(15)+(30,000)(20)=400,000+225,000+600,000=1,225,000s_{13} = (20,000)(20) + (15,000)(15) + (30,000)(20) = 400,000 + 225,000 + 600,000 = 1,225,000s13​=(20,000)(20)+(15,000)(15)+(30,000)(20)=400,000+225,000+600,000=1,225,000

Thus, S=[1,125,000840,0001,225,000]S = \begin{bmatrix} 1,125,000 & 840,000 & 1,225,000 \end{bmatrix}S=[1,125,000​840,000​1,225,000​].

This means the total revenue from Place A is Rp1,125,000, from Place B is Rp840,000, and from Place C is Rp1,225,000.

The interpretation of the elements of the resulting matrix greatly depends on how the initial matrices are defined and how the multiplication is performed.

Exercises

Given the following matrices:

C=[1−312]C = \begin{bmatrix} 1 & -3 \\ 1 & 2 \end{bmatrix}C=[11​−32​]
D=[1−482]D = \begin{bmatrix} 1 & -4 \\ 8 & 2 \end{bmatrix}D=[18​−42​]

Determine the matrices CDCDCD and DCDCDC.

Is CD=DCCD = DCCD=DC?

Answer Key

  1. Calculating CDCDCD:

    Matrix CCC has an order of 2×22 \times 22×2 and DDD has an order of 2×22 \times 22×2. The result will have an order of 2×22 \times 22×2.

    CD=[1−312][1−482]CD = \begin{bmatrix} 1 & -3 \\ 1 & 2 \end{bmatrix} \begin{bmatrix} 1 & -4 \\ 8 & 2 \end{bmatrix}CD=[11​−32​][18​−42​]
    CD=[(1)(1)+(−3)(8)(1)(−4)+(−3)(2)(1)(1)+(2)(8)(1)(−4)+(2)(2)]CD = \begin{bmatrix} (1)(1) + (-3)(8) & (1)(-4) + (-3)(2) \\ (1)(1) + (2)(8) & (1)(-4) + (2)(2) \end{bmatrix}CD=[(1)(1)+(−3)(8)(1)(1)+(2)(8)​(1)(−4)+(−3)(2)(1)(−4)+(2)(2)​]
    CD=[1−24−4−61+16−4+4]CD = \begin{bmatrix} 1 - 24 & -4 - 6 \\ 1 + 16 & -4 + 4 \end{bmatrix}CD=[1−241+16​−4−6−4+4​]
    CD=[−23−10170]CD = \begin{bmatrix} -23 & -10 \\ 17 & 0 \end{bmatrix}CD=[−2317​−100​]
  2. Calculating DCDCDC:

    Matrix DDD has an order of 2×22 \times 22×2 and CCC has an order of 2×22 \times 22×2. The result will have an order of 2×22 \times 22×2.

    DC=[1−482][1−312]DC = \begin{bmatrix} 1 & -4 \\ 8 & 2 \end{bmatrix} \begin{bmatrix} 1 & -3 \\ 1 & 2 \end{bmatrix}DC=[18​−42​][11​−32​]
    DC=[(1)(1)+(−4)(1)(1)(−3)+(−4)(2)(8)(1)+(2)(1)(8)(−3)+(2)(2)]DC = \begin{bmatrix} (1)(1) + (-4)(1) & (1)(-3) + (-4)(2) \\ (8)(1) + (2)(1) & (8)(-3) + (2)(2) \end{bmatrix}DC=[(1)(1)+(−4)(1)(8)(1)+(2)(1)​(1)(−3)+(−4)(2)(8)(−3)+(2)(2)​]
    DC=[1−4−3−88+2−24+4]DC = \begin{bmatrix} 1 - 4 & -3 - 8 \\ 8 + 2 & -24 + 4 \end{bmatrix}DC=[1−48+2​−3−8−24+4​]
    DC=[−3−1110−20]DC = \begin{bmatrix} -3 & -11 \\ 10 & -20 \end{bmatrix}DC=[−310​−11−20​]

From the results above, it is clear that CD=[−23−10170]CD = \begin{bmatrix} -23 & -10 \\ 17 & 0 \end{bmatrix}CD=[−2317​−100​] and DC=[−3−1110−20]DC = \begin{bmatrix} -3 & -11 \\ 10 & -20 \end{bmatrix}DC=[−310​−11−20​].

So, CD≠DCCD \neq DCCD=DC. This is another example showing that matrix multiplication is generally not commutative.

Previous

Matrix Scalar Multiplication

Next

Matrix Determinant

  • Matrix MultiplicationMaster matrix multiplication rules, conditions, and calculations. Learn step-by-step methods, properties, and real-world applications with examples.
On this page
  • Understanding the Multiplication of Two Matrices
    • Condition for Matrix Multiplication
    • How to Calculate the Elements of the Resultant Matrix
  • Steps to Multiply Matrices
  • Example of Multiplying Two Matrices
  • Properties of Matrix Multiplication
  • Calculating Revenue
  • Exercises
    • Answer Key
  • Comments
  • Report
  • Source code