HO 2 Matrix Operations (Part 1)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

2 MATRIX OPERATIONS

In the previous chapter, matrices were described as a means of meaningful data


presentation. However, the application of matrices is not limited to that of convenient
notation. Knowledge of the basic operations performed on matrices and of the rules
they obey will facilitate their use in solving linear systems and other computational
problems in a fast and efficient manner.

In Sections 2.1 to 2.8, the basic operations performed on matrices are discussed.
A thorough understanding of such operations is required in grasping the lessons in
the succeeding chapters of the course. In Section 2.9, the laws of matrix algebra are
outlined. A summary of the contrasts of matrix algebra with scalar algebra follows in
Section 2.10.

2.0 Equality of Matrices

Two 𝑟x𝑐 matrices A = {𝑎𝑖𝑗 } and B = {𝑏𝑖𝑗 } are equal if their corresponding
elements are equal, i.e., if 𝑎𝑖𝑗 =𝑏𝑖𝑗 for 𝑖=1,2,…,r and 𝑗=1,2,…,c. Equality of two
matrices has no meaning unless they are of the same order.
1 −2 𝑥 −2
Let A = [ ] and B = [ ], for what values of 𝑥 and 𝑦 will A = B?
3 √2 3 𝑦

2.1 Matrix Addition

If A = {𝑎𝑖𝑗 } and B = {𝑏𝑖𝑗 } are both 𝑟x𝑐 matrices, then the sum A + B is an 𝑟x𝑐
matrix E = {𝑒𝑖𝑗 } defined by 𝑒𝑖𝑗 = 𝑎𝑖𝑗 + 𝑏𝑖𝑗 , 𝑖=1,2,…r and 𝑗=1,2,…,c.

Examples:

1 5 3 −2
1. Let A = [ ] and B = [ ] then
−4 6 4 −5

4 3
E=A+B=[ ]
0 1

5 2 2 0
2. Let U = [1 0] and V = [3 −2]
4 3 6 −8

U+V=[ ]

8|Stat 135: Matrix Theory for Statistics


Remarks:

• Two matrices can be added only if they are of the same order, i.e., they have
the same number of rows and the same number of columns. We then say
that the two matrices are conformable for addition.
• The sum of matrix Arxc and the null matrix Orxc is Arxc.

Exercises

1. A manufacturer of a certain product makes three models, A, B, and C.


Each model is partially made in a factory in the Philippines and then
finished in a factory in the United States. Given in the tables below are
the manufacturing and shipping costs (in dollars) for each product in the
first and second factories respectively.

Factory (Philippines) Manufacturing Cost Shipping Cost


Model A 30 41
Model B 52 75
Model C 68 17

Factory (US) Manufacturing Cost Shipping Cost


Model A 34 58
Model B 50 46
Model C 133 19

The total cost of each product consists of the manufacturing cost and
the shipping cost.
a. Represent the data sets in matrix form.
b. Give the total manufacturing and shipping costs for each product.

𝜋 3
√𝜋 −𝑖 cos ( ) 𝑒 −3 √787
2. Find K + L if K = [ 1
2
] and L = [ 3 0 ].
log(5) 0 6.23 −2
11

2.2 Scalar Multiplication

If A = {𝑎𝑖𝑗 } is an 𝑟x𝑐 matrix and 𝑘 is a real number, then the scalar multiple of A
by k, denoted by 𝑘A is the 𝑟x𝑐 matrix E = {𝑒𝑖𝑗 } where 𝑒𝑖𝑗 =𝑘𝑎𝑖𝑗 , 𝑖=1,2,…,r and
j=1,2,…,c

Example:
0 −1 0 −2
Let A = [ ], then 2A = [ ]
2 3 4 6

9|Stat 135: Matrix Theory for Statistics


Remark: The negative of an 𝑟x𝑐 matrix A = {𝑎𝑖𝑗 } is the 𝑟x𝑐 matrix −A where
−A = (-1)A = {−𝑎𝑖𝑗 }.

0 −1 0 1
Example: For A = [ ], then −A = [ ]
2 3 −2 −3

2.3 Matrix Subtraction

If A and B are 𝑟x𝑐 matrices, then the difference between A and B, denoted by

A − B, is defined as A – B = A + (-1)B.

Examples:
1 5 3 −2
1. Let A = [ ] and B = [ ] then
−4 6 4 −5

−2 7
A-B=[ ]
−8 11

5 2 2 0
2. Let U = [1 0] and V = [3 −2]
4 3 6 −8

U-V=[ ]

Remarks:

• As with addition, only matrices that are of the same order can be subtracted
from one another. Thus, matrices that are conformable for addition are also
conformable for subtraction, and vice versa.
• The negative of a matrix Arxc, −Arxc, can be defined as the (unique) matrix
whose sum with A is the null matrix, i.e., A+(−A) = Arxc – Arxc = Orxc

Exercises

Shown below are the gross income and expenses of an international


corporation for 1981 and 1982 in four countries.

Gross Income (in $1,000,000)


Year US Canada Australia UK
1981 27 15 18 21
1982 32 14 21 30

10 | S t a t 1 3 5 : M a t r i x T h e o r y f o r S t a t i s t i c s
Expenses (in $1,000,000)
Year US Canada Australia UK
1981 19 9 11 17
1982 22 10 13 24

Gross profit is computed as the difference of expenses from the gross


income.
a) Represent the data sets in matrix form.
b) For the years 1981 and 1982, give the international corporations’ gross profit
in each country.

2.4 Matrix Multiplication

If A = {𝑎𝑖𝑗 } is an 𝑟x𝑐 matrix and B = {𝑏𝑖𝑗 } is a 𝑐x𝑠 matrix, then the product of A
and B, AB = E = {𝑒𝑖𝑗 } is an 𝑟x𝑠 matrix defined by
𝑐

𝑒𝑖𝑗 = ∑ 𝑎𝑖𝑘 𝑏𝑘𝑗


𝑘=1

= 𝑎𝑖1 𝑏1𝑗 + 𝑎𝑖2 𝑏2𝑗 + ⋯ + 𝑎𝑖𝑐 𝑏𝑐𝑗

𝑖=1,2,…,r, 𝑗=1,2,…,s and 𝑘=1,2,…,c

Schematically, the operation can be represented as follows:

𝑖𝑡ℎ 𝑟𝑜𝑤
[→ ] [↓ 𝑗 𝑡ℎ 𝑐𝑜𝑙𝑢𝑚𝑛] = [{(𝑖, 𝑗)𝑡ℎ 𝑒𝑙𝑒𝑚𝑒𝑛𝑡}]𝑟x𝑠
𝑟x𝑐 𝑐x𝑠

For 𝑖=1,2,…,r and 𝑗 =1,2,…s

Example:
1 2 1 2 −1
Let A2x2 = [ ] and B2x3 = [ ].
0 4 6 0 −2
13 2 −5
Then AB2x3 = [ ]
24 0 −8
2.4.1 Inner Product of Two Vectors
𝑥1
𝑥2
If 𝑎’ = [𝑎1 𝑎2 𝑎3 … 𝑎𝑛 ] and 𝑥 = 𝑥3 , then the inner product of 𝑎 and 𝑥,

[𝑥𝑛 ]
𝑎′ 𝑥 is a scalar where 𝑎′ 𝑥 = 𝑎1 𝑥1 + 𝑎2 𝑥2 + 𝑎3 𝑥3 … + 𝑎𝑛 𝑥𝑛 = ∑𝑛𝑖=1 𝑎𝑖 𝑥𝑖

11 | S t a t 1 3 5 : M a t r i x T h e o r y f o r S t a t i s t i c s
Examples:
3 20
1. Let 𝑎 = [2] and 𝑥 = [40]. Then 𝑎′𝑥 = 3(20) + 2(40) + 5(60) = 440.
5 60
2 0
2. Let 𝑥 = [1] and 𝑦 = [−1]. Then 𝑥’𝑦 =
3 2
4 2

Exercises (Buying Laboratory Animals)


Consider buying supplies of experimental rats, mice, and rabbits for
laboratory courses in the chemistry, biochemistry, nutrition and physiology
departments of a university. Suppose the price per animal of rats, mice, and
rabbits in the hometown is $3, $1, and $10, and that the chemistry
department needs 50, 100, and 30 animals respectively.
a. Write the prices as a row vector 𝑝’ and the number of animals needed
as a column vector 𝑛.
b. What is the total cost of the required animals bought in the
hometown to the chemistry department?

Remarks:

• The inner product 𝑎′𝑥 of the vector 𝑎 and 𝑥 exists only when 𝑎 and 𝑥 have
the same order, i.e., when the number of columns in 𝑎’ is equal to the
number of rows in 𝑥.
• 𝑎’𝑥 and 𝑥’𝑎 are equal but are not equal to 𝑥𝑎’.

2.4.2 Outer Product of Two Vectors


𝑥1
𝑥2
If 𝑎’ = [𝑎1 𝑎2 𝑎3 … 𝑎𝑛 ] and 𝑥 = 𝑥3 , then the outer product of 𝑎 and 𝑥

[𝑥𝑛 ]
is
𝑥1 𝑎1 𝑥1 𝑎2 ⋯ 𝑥1 𝑎𝑗 ⋯ 𝑥1 𝑎𝑛
𝑥2 𝑎1 𝑥2 𝑎2 ⋯ 𝑥2 𝑎𝑗 ⋯ 𝑥2 𝑎𝑛
⋮ ⋮ ⋮ ⋮ ⋮ ⋮
𝑥 𝑎′ = 𝑥 𝑎 𝑥𝑖 𝑎2 ⋯ 𝑥𝑖 𝑎𝑗 ⋯ 𝑥𝑖 𝑎𝑛
𝑖 1
⋮ ⋮ ⋮ ⋮ ⋮ ⋮
[𝑥𝑛 𝑎1 𝑥𝑛 𝑎2 ⋯ 𝑥𝑛 𝑎𝑗 ⋯ 𝑥𝑛 𝑎𝑛 ]

Exercises (Refer to Buying Laboratory Animals Exercise)

1. Get p n’. What do the elements of this matrix represent?


2. Get n p’. What do the elements of this matrix represent?

12 | S t a t 1 3 5 : M a t r i x T h e o r y f o r S t a t i s t i c s
2.4.3 Matrix-Vector Product
If A = {𝑎𝑖𝑗 } and x = {𝑥𝑖𝑗 } for 𝑖=1,2,…,r and 𝑗=1,2,…,c, then
Ax = {∑𝑐𝑗=1 𝑎𝑖𝑗 𝑥𝑗 } for 𝑖=1,2,…,r

Exercises (Buying Laboratory Animals Exercise – Continued)

Suppose the animal prices in neighboring town were $2, $2, and $8,
respectively.

1. Present the prices of the animals in the hometown and neighboring town
in matrix form. Denote it by P.
2. How much would it cost the chemistry department to purchase the
required animals in the hometown? Present the total costs simultaneously.

2.4.4 Product of Two Matrices


Multiplying two matrices can be explained as a simple repetitive extension
of multiplying a matrix by a vector.

Exercises (Buying Laboratory Animals Exercise – continued further)

Suppose the biochemistry department needed 60 rats, 80 mice, and 40 rabbits.


The nutrition department needed 90, 30, and 20 animals. The physiology
department needed 30, 20, and 10 animals.

1. How much would it cost the biochemistry department to purchase the


required animals in the hometown? In the neighboring town? Present the
total costs simultaneously.
2. How much would it cost the nutrition department to purchase the required
animals in the hometown? In the neighboring town? Present the total costs
simultaneously.
3. How much would it cost the physiology department to purchase the
required animals in the hometown? In the neighboring town? Present the
total costs simultaneously.
4. Present the animal requirements of the four departments in matrix form.
Denote it by A.
5. Present the total costs of buying the animals in the hometown and in the
neighboring town to the four departments simultaneously.

Remarks:

• The product AB of two matrices A and B is defined and therefore exist only
if the number of columns in A equals the number of rows in B; the matrices
are then said to be conformable for multiplication for the product AB.

13 | S t a t 1 3 5 : M a t r i x T h e o r y f o r S t a t i s t i c s
• From the definition of matrix multiplication, the product BA does not
necessarily exist, even if AB does.
• If A is of order 𝑟x𝑐:
o B must have ___ rows for AB to exist.
o B must have ___ columns for BA to exist.
o B must be of order ________ for AB and BA to both exist.
• Both AB and BA always exist and are of the same order when A and B are
square matrices and of the same order. AB and BA are not necessarily equal.
• Assuming that the matrix products under consideration exist,
o In getting the product AB, we premultiply A to B or premultiply B
by A. Equivalently, we postmultiply B to A or postmultiply A by B.
o A row vector postmultiplied by a column vector is a scalar.
o A column vector postmultiplied by a row vector is a matrix.
o A matrix postmultiplied by a column vector is a column vector.
o A row vector postmultiplied by a matrix is a row vector.

2.5 Transpose of a Matrix


If A = {𝑎𝑖𝑗 } is an 𝑟x𝑐 matrix, then the transpose of A, denoted by A’ = {𝑎𝑖𝑗 ’}, is a
𝑐x𝑟 matrix defined by 𝑎𝑖𝑗 ′ = 𝑎𝑗𝑖 . Thus, A’ is the matrix whose columns are the
rows of A with order retained from first to last.

Example:

0 4 8
0 1 2 3
Let A4x3 = [1 5 9 ]. Then A’ = [
3x4 4 5 6 7 ].
2 6 10
8 9 10 11
3 7 11

Remarks:
• The rows of A’ are the same as the columns of A.
• If A is an 𝑟x𝑐 matrix, then A’ is a 𝑐x𝑟 matrix.
• If 𝑎𝑖𝑗 is the term in the 𝑖 𝑡ℎ row and the 𝑗 𝑡ℎ column of Arxc, it is also the term
in the 𝑗 𝑡ℎ row and 𝑖 𝑡ℎ column of A’cxr.
• The notation for the transpose of A is A’. For clarity, one of the equivalent
forms (Arxc)’ or (A’)cxr must be used whenever it is necessary to have a
subscript notation for the order of the transposed matrix.

14 | S t a t 1 3 5 : M a t r i x T h e o r y f o r S t a t i s t i c s
Some Properties of the Transpose of a Matrix
1. Reflexive Property: For any 𝑟x𝑐 matrix A, (A’)’ = A.
Proof:

2. For any 𝑟x𝑐 matrices A and B, (A + B)’ = A’ + B’.


Proof:

3. Let A be an 𝑟x𝑐 matrix and 𝑘 a real number. Then, (kA)’ = kA’


Proof:

4. Let A be an 𝑟x𝑐 matrix and B be a 𝑐x𝑠 matrix. Then (AB)’ = B’A’


Proof:

Remarks:

• The fourth property can be extended directly to the transpose of the product
of more than 2 matrices. Thus, for a finite number of matrices,
(A1 A2 A3… Ak-1 Ak)’ = (Ak’ Ak-1’… A3’ A2’ A1’)
• The transpose of a column vector is a row vector and vice-versa.

Example:
1
If 𝑥 3x1 = [2], then 𝑥’1x3 = [1 2 3].
3

15 | S t a t 1 3 5 : M a t r i x T h e o r y f o r S t a t i s t i c s

You might also like