0% found this document useful (0 votes)
22 views33 pages

Matrix Operations Tutorial for MATH1853

Uploaded by

lksfjaoiwepa34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views33 pages

Matrix Operations Tutorial for MATH1853

Uploaded by

lksfjaoiwepa34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MATH1853 Tutorial 1

Matrix Addition and Multiplication

1
Who am I
• Yuxin Cheng
• Contact me: yxcheng@[Link]
• Office: Rm 806 A, Chow Yei Ching Building

Ø Before coming, please send me an email about:


• when will you come
• what ques1ons you have

Note: The tutorial and lecture contents cannot be in sync due to the 9ght
scheduling. You should treat tutorials as extra materials for Math 1853 to help
recap and enhance you study.

2
Tutorial Schedule
Ø Tutorials run for 5 weeks, held every Monday and Thursday.
Ø There are 7 on-site sessions and 1 online session (Thursday).
Ø Each week is led by one of the 5 teaching assistants.

❗ Important Notes:
Ø All 8 sessions each week cover the same content. You may choose to aBend
any one.
Ø A7endance is not recorded. You can change your 9me slot each week.
Ø Exercises are for prac<ce only. Submission is not required and does not affect
your grade. Answers will be posted on Moodle aIer each tutorial.

3
During Tutorial …
• : Examples we will go through together in the tutorial

• : Exercises you should do yourself in the tutorial

• The remaining questions: you can do them after tutorial as a practice

4
Ques%on 1: Matrix Addi%on
1 2
0. Consider matrix 𝐴 = . What happens when you add the zero scalar B=0 and the zero matrix
3 4
0 0
𝑂= to A ?
0 0

1 2 1+0 2+0
𝐴+𝐵 = +0= = A, add 0 to each element of A
3 4 3+0 4+0

1 2 0 0 1+0 2+0 0 0
𝐴+𝑂= + = = A, add the corresponding elements of and A
3 4 0 0 3+0 4+0 0 0

Key points: different opera0ons, same results


• Adding a scalar 0 to A: Add 0 to each element of the matrix A;
• Adding a zero matrix to A: Add the corresponding elements for the zero matrix O and A together
• Adding the zero matrix and scalar leaves A unchanged, which is similar to adding zero to a scalar.
• The result will have the same dimensions as the original matrix
• Mathema@cally no defini@on of addi@on between scalar and matrix, but in engineering programming, it 5
some@mes conforms the above defini@on for calcula@on
Question 1: Matrix Addition
1 2
0. Consider matrix 𝐴 = . What happens when you add the zero scalar B=0 and the zero matrix
3 4
0 0
𝑂= to A ?
0 0

1 2 1+0 2+0
𝐴+𝐵 = +0= = A, add 0 to each element of A
3 4 3+0 4+0

0 0 0
Now what happens, if I change the zero matrix to 𝑂 = ?
0 0 0
𝐴+𝑂=?

Key rule
• you can only add matrices if they have the same number of rows and the same number of columns.
6
Question 1: Matrix Addition

7
Key points:
• The dimensions of addends must match.
Question 1: Matrix Addition •

Perform element-wise [Link].
When mulBplying with a scalar, do mulBplicaBon
with each element.

• (a) cannot add because unmatched dimension (3×2 with 3×3)

• (b) Element-wise addiBon


1 2 3 𝟐 1 0 1+𝟐 2+1 3+0 3 3 3
4 𝟓 6 + 0 𝟏 1 = 4+0 𝟓+𝟏 6+1 = 4 6 7
7 8 9 1 0 3 7+1 8+0 9+3 8 8 12

• (c) MulBply with the scalar first, then element-wise addiBon

2 0 4 2 1 0
3 1 3 −3⋅ 0 1 1
2 5 9 1 0 3
2 0 4 3×2 3×1 3×0
= 3 1 3 − 3×0 3×1 3×1
2 5 9 3×1 3×0 3×3
2−6 0−3 4−0 −4 −3 4
= 3 − 0 1 − 3 3 − 3 = 3 −2 0
2−3 5−0 9−9 −1 5 0 8
Question 2: Matrix Multiplication

9
Question 2: Matrix Multiplication

(a) not possible, dimensions not fit (3×2 with 3×3)

1 ∗ 2 + 2 ∗ 0 1+∗31∗+1 2=∗51 + 3 ∗ 0 = 3

1 2 3 2 1 0 5 3 11
• (b) 4 5 6 0 1 1 = 14 9 23
7 8 9 1 0 3 23 15 35
4 ∗ 2 + 5 ∗ 0 + 6 ∗ 1 = 14

Key points:
• The dimensions of operands must fit (𝑛×𝑚 with 𝑚×𝑝)
• Product would have shape (𝑛×𝑝)
• Result elements: dot product of corresponding row and column. 10
Ques=on 2: Matrix Mul=plica=on (Exercise)

0 0 0 0 0
3 0 3 9 0
• (c) 0 1 3 0 =
2 0 2 6 0
4 0 4 12 0

0
3
• (d) 0 1 3 0 =9
2
Key points:
4
• The dimensions of operands must fit (𝑛×𝑚 with 𝑚×𝑝)
• Product would have shape (𝑛×𝑝)
• Result elements: dot product of corresponding row and column. 11
Question 2: Matrix Multiplication (Exercise)

e. 30 49 34
54 51 34

f.
18 9 6
0 12 9
18 15 9

12
Ques=on 3: Matrix Mul=plica=on

Key point: • Multiplication with the identity matrix.

13
Question 3: Matrix Multiplication

6 2 7 1 0 0 6 2 7
• (a) 0 1 5 0 1 0 = 0 1 5
8 0 3 0 0 1 8 0 3

14
Ques=on 3: Matrix Mul=plica=on

6 2 7 1 0 0 6 2 7
• (a) 0 1 5 0 1 0 = 0 1 5
8 0 3 0 0 1 8 0 3

1 0 0 6 2 7
• (b) 0 1 0 0 1 5 =
0 0 1 8 0 3
15
Question 3: Matrix Multiplication

6 2 7 1 0 0 6 2 7
• (a) 0 1 5 0 1 0 = 0 1 5
8 0 3 0 0 1 8 0 3

1 0 0 6 2 7 6 2 7
• (b) 0 1 0 0 1 5 = 0 1 5
0 0 1 8 0 3 8 0 3
16
Ques=on 3: Matrix Mul=plica=on

c. 0 2 1 d. 4 3 2 e. 6 4 7
2 4 3 −1 1 4 0 2 5
4 −1 1 2 1 0 8 0 3

17
Ques=on 4: Matrix Mul=plica=on Proper=es

Key point:
• Associa've property of Matrix Mul'plica'on

18
Question 4: Matrix Multiplication Properties
𝑎33 𝑎34 𝑏33 𝑏34 𝑐33 𝑐34
• (a) 𝑎43 𝑎44 𝑏43 𝑐43 𝑐44
𝑏44

𝑎33 𝑏33 + 𝑎34 𝑏43 𝑎33 𝑏34 + 𝑎34 𝑏44 𝑐33 𝑐34
=
𝑎43 𝑏33 + 𝑎44 𝑏43 𝑎43 𝑏34 + 𝑎44 𝑏44 𝑐43 𝑐44

𝑎33 𝑏33 𝑐33 + 𝑎34 𝑏43 𝑐33 + 𝑎33 𝑏34 𝑐43 + 𝑎34 𝑏44 𝑐43 𝑎33 𝑏33 𝑐34 + 𝑎34 𝑏43 𝑐34 + 𝑎33 𝑏34 𝑐44 + 𝑎34 𝑏44 𝑐44
=
𝑎43 𝑏33 𝑐33 + 𝑎44 𝑏43 𝑐33 + 𝑎43 𝑏34 𝑐43 + 𝑎44 𝑏44 𝑐43 𝑎43 𝑏33 𝑐34 + 𝑎44 𝑏43 𝑐34 + 𝑎43 𝑏34 𝑐44 + 𝑎44 𝑏44 𝑐44

𝑎33 𝑎34 𝑏33 𝑏34 𝑐33 𝑐34


• (b) 𝑎 𝑎44
43 𝑏43 𝑏44 𝑐43 𝑐44

𝑎33 𝑎34 𝑏33 𝑐33 + 𝑏34 𝑐43 𝑏33 𝑐34 + 𝑏34 𝑐44
= 𝑎 𝑎44 𝑏43 𝑐33 + 𝑏44 𝑐43
43 𝑏43 𝑐34 + 𝑏44 𝑐44

𝑎33 𝑏33 𝑐33 + 𝑎34 𝑏43 𝑐33 + 𝑎33 𝑏34 𝑐43 + 𝑎34 𝑏44 𝑐43 𝑎33 𝑏33 𝑐34 + 𝑎34 𝑏43 𝑐34 + 𝑎33 𝑏34 𝑐44 + 𝑎34 𝑏44 𝑐44
=
𝑎43 𝑏33 𝑐33 + 𝑎44 𝑏43 𝑐33 + 𝑎43 𝑏34 𝑐43 + 𝑎44 𝑏44 𝑐43 𝑎43 𝑏33 𝑐34 + 𝑎44 𝑏43 𝑐34 + 𝑎43 𝑏34 𝑐44 + 𝑎44 𝑏44 𝑐44
19
Question 4: Matrix Multiplication Properties

Key point:
• Distribu've property of Matrix Mul'plica'on

20
Ques=on 4: Matrix Mul=plica=on Proper=es
𝑎!! 𝑎!" 𝑏!! 𝑏!" 𝑐!! 𝑐!"
• (c) 𝑎 +
"! 𝑎"" 𝑏"! 𝑏"" 𝑐"! 𝑐""
𝑎!! 𝑎!" 𝑏!! + 𝑐!! 𝑏!" + 𝑐!"
= 𝑎
"! 𝑎"" 𝑏"! + 𝑐"! 𝑏"" + 𝑐""

𝑎33 𝑏33 + 𝑎33 𝑐33 + 𝑎34 𝑏43 + 𝑎34 𝑐43 𝑎33 𝑏34 + 𝑎33 𝑐34 + 𝑎34 𝑏44 + 𝑎34 𝑐44
=
𝑎43 𝑏33 + 𝑎43 𝑐33 + 𝑎44 𝑏43 + 𝑎44 𝑐43 𝑎43 𝑏34 + 𝑎43 𝑐34 + 𝑎44 𝑏44 + 𝑎44 𝑐44

𝑎!! 𝑎!" 𝑏!! 𝑏!" 𝑎!! 𝑎!" 𝑐!! 𝑐!"


• (d) 𝑎 𝑎"" 𝑏"! + 𝑎 𝑎"" 𝑐"! 𝑐""
"! 𝑏"" "!

21
Question 4: Matrix Multiplication Properties
𝑎!! 𝑎!" 𝑏!! 𝑏!" 𝑐!! 𝑐!"
• (c) 𝑎 +
"! 𝑎"" 𝑏"! 𝑏"" 𝑐"! 𝑐""
𝑎!! 𝑎!" 𝑏!! + 𝑐!! 𝑏!" + 𝑐!"
= 𝑎
"! 𝑎"" 𝑏"! + 𝑐"! 𝑏"" + 𝑐""

𝑎33 𝑏33 + 𝑎33 𝑐33 + 𝑎34 𝑏43 + 𝑎34 𝑐43 𝑎33 𝑏34 + 𝑎33 𝑐34 + 𝑎34 𝑏44 + 𝑎34 𝑐44
=
𝑎43 𝑏33 + 𝑎43 𝑐33 + 𝑎44 𝑏43 + 𝑎44 𝑐43 𝑎43 𝑏34 + 𝑎43 𝑐34 + 𝑎44 𝑏44 + 𝑎44 𝑐44

𝑎!! 𝑎!" 𝑏!! 𝑏!" 𝑎!! 𝑎!" 𝑐!! 𝑐!"


• (d) 𝑎 𝑎"" 𝑏"! + 𝑎 𝑎"" 𝑐"! 𝑐""
"! 𝑏"" "!

𝑎!! 𝑏!! + 𝑎!" 𝑏"! 𝑎!! 𝑏!" + 𝑎!" 𝑏"" 𝑎 𝑐 +𝑎 𝑐 𝑎!! 𝑐!" + 𝑎!" 𝑐""
= + 𝑎!! 𝑐!! + 𝑎!" 𝑐"! 𝑎"! 𝑐!" + 𝑎"" 𝑐""
𝑎"! 𝑏!! + 𝑎"" 𝑏"! 𝑎"! 𝑏!" + 𝑎"" 𝑏"" "! !! "" "!

𝑎!! 𝑏!! + 𝑎!! 𝑐!! + 𝑎!" 𝑏"! + 𝑎!" 𝑐"! 𝑎!! 𝑏!" + 𝑎!! 𝑐!" + 𝑎!" 𝑏"" + 𝑎!" 𝑐""
=
𝑎"! 𝑏!! + 𝑎"! 𝑐!! + 𝑎"" 𝑏"! + 𝑎"" 𝑐"! 𝑎"! 𝑏!" + 𝑎"! 𝑐!" + 𝑎"" 𝑏"" + 𝑎"" 𝑐""
22
Ques=on 5: Mul=plica=on by a Scalar

[Link] Property:

[Link] Property:
23
Question 5: Multiplication by a Scalar
6*4

4 3 4 3 24 18
• (a) 3×2 ⋅ =6⋅ =
5 2 5 2 30 12

• (b) same answer as (a)

4 3 4 3 20 15
• (c) 3 + 2 =5 =
5 2 5 2 25 10

• (d) same answer as (c)

24
Question 5: Multiplication by a Scalar (Exercise)

1 3 5 3 2 0
(e) 2 +2 =
2 4 6 1 5 4

25
Question 5: Multiplication by a Scalar (Exercise)

1 3 5 3 2 0
(e) 2 +2
2 4 6 1 5 4
2 6 10 6 4 0 8 10 10
= + =
4 8 12 2 10 8 6 18 20

• (f) same answer as (e)

26
Ques%on 6: Mul%plica%on by 0
1 2 4
6.0. Consider matrix 𝐴 = . What happens if A is multiplied by a zero scalar B=0 and the zero matrix
3 4 5
0 0 0 0 0
𝑂 = 0 0 ? And what happens if the zero matrix 𝑂′ = 0 0 0 ?
0 0 0 0 0

1 2 4 1×0 2×0 4×0 0 0 0


𝐴×0= ×0= =
3 4 5 3×0 4×0 5×0 0 0 0

0 0 0
0 0 1 2 4 0 0 0
1 2 4 0 0 𝐴 × 𝑂′ = × 0 0 0 =
𝐴×𝑂 = × 0 0 = 3 4 5 0 0 0
3 4 5 0 0 0 0 0
0 0
2×3 with 3×3 −→ 2×3
2×3 with 3×2 −→ 2×2
Key point:
• Result: Both operations will yield a zero matrix, but the dimension may differ.
• Operation type:
• By a scalar is a simple operation, affecting each element individually
• By a zero matrix is a matrix multiplication, involving row-by-column multiplication 27
Extra Question : Systems of Linear Equations
Key point:
• Get a feeling of how to use
matrix to represent linear
equations!

28
Extra Ques=on: Systems of Linear Equa=ons
2𝑥! + 7𝑥" + 8𝑥# = −9 (1)
6𝑥! − 3𝑥" − 7𝑥# = 14 2 in high-school way
4𝑥! + 5𝑥" − 3𝑥# = −10 (3)

𝐸𝑞. 2 − 3×𝐸𝑞. (1):


6𝑥! − 3𝑥" − 7𝑥# − 3 2𝑥! + 7𝑥" + 8𝑥# = −24𝑥" − 31𝑥# = 14 − 3× −9 = 41

𝐸𝑞. 3 − 2×𝐸𝑞. 1 :
4𝑥! + 5𝑥" − 3𝑥# − 2 2𝑥! + 7𝑥" + 8𝑥# = −9𝑥" − 19𝑥# = −10 − 2× −9 = 8

3 −24𝑥" − 31𝑥# − 8 −9𝑥" − 19𝑥# = 59x# = 3×41 − 8×8 = 59

𝑥# = 1
𝑥" = −3
𝑥! = 2
29
Extra Question: Systems of Linear Equations
Q7.1
𝐸𝑞. 2 − 3×𝐸𝑞. (1):
6𝑥! − 3𝑥" − 7𝑥# − 3 2𝑥! + 7𝑥" + 8𝑥# = −24𝑥" − 31𝑥# = 14 − 3× −9 = 41
2𝑥! + 7𝑥" + 8𝑥# = −9 (1)
6𝑥! − 3𝑥" − 7𝑥# = 14 2 𝐸𝑞. 3 − 2×𝐸𝑞. 1 :
4𝑥! + 5𝑥" − 3𝑥# = −10 (3) 4𝑥! + 5𝑥" − 3𝑥# − 2 2𝑥! + 7𝑥" + 8𝑥# = −9𝑥" − 19𝑥# = −10 − 2× −9 = 8

Ax=b 3 −24𝑥" − 31𝑥# − 8 −9𝑥" − 19𝑥# = 59x# = 3×41 − 8×8 = 59


2 7 8 𝑥! 2 −9 𝑥# = 1
A= 6 −3 −7 X= 𝑥" = −3 b= 14 𝑥" = −3
4 5 −3 𝑥# 1 −10 𝑥! = 2
Q7.2
2 7 8 2 2 7 8 2 −9
6 −3 −7 −3 = 14
6 −3 −7 −3 = 4 5 −3 1 −10
4 5 −3 1

30
Key point:
2 7 8 2 −9
•Get a feeling of how to
use matrix to represent 6 −3 −7 −3 = 14
linear equations! 4 5 −3 1 −10

Q6 (cont.) 𝑥! = 2
𝑥" = −3
𝑥# = 1
Notes:
p Gaussian EliminaBon
p Inverse matrix
p…

31
Summary
• Matrix addition
pThe dimensions of addends must match.
pPerform element-wise addition.
pWhen multiply with a scalar, do multiplication with each element.
• Matrix multiplication
p Matrix multiplication with the identity matrix
• Matrix(-Scalar) multiplication properties
p Associative Property
p Distributive Property
• Systems of Linear Equations
p Get a feeling of how to use matrix to represent linear equations.

32
Thanks

33

You might also like