Activity 4 Application of Matrix Operations GROUP 1

You might also like

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

Technological Institute of the Philippines - Manila Course: MATH 022A

Math & Physics Department ONLINE LECTURE

Laboratory Activity No. 4

Laboratory Activity No. 4


Application of Matrix Operations
Name: Section:
Aguilar, Jose Francis Jairus CE21S14
Espiritu, Maria Eunice
Olano, Chatterley
Paduga, Wilmar
Date Performed: 10/25/22 Date Submitted:10/27/22
1. Objective(s):

1.1 To identify matrix as the product of a lower triangular matrix L and an upper triangular matrix U.
1.2 To factor a matrix into a product of elementary matrices.
1.3 To find and use an LU – factorization of a matrix to solve a system of linear equations.
1.4 To use matrix multiplication to encode and decode messages.
1.5 To find the least squares regression line for a set of data.

2. Intended Learning Outcomes (ILOs):

The students shall be able to:


2.1 Demonstrate scientific thinking and the ability to approach scientific resources intelligently.
2.2 Utilize MATLAB software in solving linear algebra problems related to their fields of
specialization.
2.3 Infer appropriate conclusions based upon the results of the activity.
2.4 Reflect on personal transformation along the T.I.P. graduate attributes, specifically, professional
competence and critical thinking skills.

3. Discussion:
Another general approach to solve Ax = b is known as the method of LU – Factorization, which provides
new insights into matrix algebra and has many theoretical and practical uses. Efficient computer algorithms
for handling practical problems can be developed from it.

The symbols L and U denote lower triangular matrix and upper triangular matrices, respectively.

𝑎11 0 0 𝑎11 𝑎12 𝑎13


[𝑎21 𝑎22 0 ] lower triangular matrix (L) [ 0 𝑎22 𝑎23] upper triangular matrix (U)
𝑎31 𝑎32 𝑎33 0 0 𝑎33

By writing AX = Lux and letting Ux = y, variable x can be solved in two stages. First, solve Ly = b for y;
then solve Ux = y for x. Each system is easy to solve because the coefficient matrices are triangular. In
particular, neither system requires any row operations. A cryptogram is a message written according to
a secret code (the Greek word kryptos means “hidden”). The following describes a method of using
matrix multiplication to encode and decode messages.
space – 0 D–4 H–8 L – 12 P – 16 T – 20 X – 24
A–1 E–5 I –9 M – 13 Q – 17 U – 21 Y – 25
B–2 F–6 J – 10 N – 14 R – 18 V – 22 Z – 26
C–3 G–7 K – 11 O – 15 S – 19 W – 23
Matrix form a linear regression model y = Ax + E the coefficient of the least square regression line is
given by the matrix equation A = (XT X) –1(XT Y)
Technological Institute of the Philippines - Manila Course: MATH 022A
Math & Physics Department ONLINE LECTURE

4. Procedure:
Activity 1. Determine the sequence of elementary matrices and corresponding inverse of each
elementary

1 5 3 1 0 0
matrix of 𝐴 = [3 4 2] using the identity matrix 𝐼 = [0 1 0]
2 1 5 0 0 1

Using the solution on solving lower triangular matrix of A, fill up all the elementary matrices and its
inverse by row operation on each step.
elementary matrix inverse of elementary matrix
1 5 3 1 0 0 1 0 0
[3 4 2] −3𝑅1 + 𝑅2 𝐸1 = [ -3 1 0 ] 𝐸1 [3
−1 1 1 ]
2 1 5 0 0 1 0 0 1

1 5 3 1 0 0 1 0 0
[0 −11 −7] 𝐸2 = [0 1 0 ] 𝐸2 −1 [0 1 0 ]
2 1 5 −2𝑅1 + 𝑅3 -2 0 1 2 0 1

1 5 3 1 1 0 0 1 0 0
[0 𝑅
-11 -7] - 11 2 𝐸 3 =[0 -1/11 0] 𝐸3 −1 [ -11 1 0 ]
0 −9 −1 0 0 1 0 0 1

1 5 3 1 0 0 1 0 0
[0 1 7/11] 𝐸 4 =[0 1 0] 𝐸4−1 [0 1 0 ]
0 −9 −1 9𝑅2 + 𝑅3 0 9 1 0 -9 1

1 5 3 1 0 0 1 0 0
[0 1 7/11] 11 𝐸5 =[ 0 1 0] 𝐸5−1 [ 0 1 0 ]
0 0 52/11 52 𝑅3 0 0 11/52 1 0 52/11

1 5 3
U= [ 0 1 7/11]
0 0 1
1. Find the product of “E5E4E3E2E1A” using MATLAB
1 5 3
Answer in fraction; 0 1 7/11
0 0 1
2. Is the answer in number 1 the same as the upper triangular matrix? YES, it’s the same.
3. Determine the lower triangle matrix by multiplying all inverse of
elementary matrix “ E1–1 E2–1 E3–1 E4–1 E5–1 “ using MATLAB

answer in fraction
1 0 0
Technological Institute of the Philippines - Manila Course: MATH 022A
Math & Physics Department ONLINE LECTURE

3 -11 0
2 -9 52/11
Is the product of lower and upper triangular matrix equal to matrix A ( LU = A ) ?

L U A
1 0 0 1 5 3 1 5 3
[3 -11 0 0 1 7/11 = 3 4 2
2 -9 52/11 0 0 1 2 1 5

Explain: A=[1 5 3;3 4 2;2 1 5] and type [L,U]=lu(A) and multiply L*U then swap by R1 ↔ R2

Solving a linear equation system Ax = b. First, we can express the coefficient matrix A in the form of the LU –
Factorization. Then we may solve the linear system by the following procedure.

Example 1

Solve the system, on MATLAB [ LU ] = lu(A)


Coefficient matrix
– x1 + 2x2 + x3 = 0 -1 2 1
8x1 + 6x3 = 10 8 0 6]
A=[
– 2x1 + 5x3 = – 11
-2 0 5

1 0 0 -1 2 1
L = [ -8 1 0] U= [ 0 16 14]
2 -1/4 1 0 0 13/2

1. Solve the system Ly = b

L y = b

1 1 0 𝑦1 0
[ -8 1 0] [𝑦2] = [ 10]
2 -1/4 1 𝑦3 −11

Back substitution now yields:

𝑦1 = 0 𝑦2 = 10 𝑦3 = -17/2
Technological Institute of the Philippines - Manila Course: MATH 022A
Math & Physics Department ONLINE LECTURE

2. Solve Ux = y

U x = y
_ -1 2 1 𝑥1 0
[_ 0 16 14 ] [𝑥2] = [10]
_0 0 13/2 𝑥3 -17/2

Back substitution now yields:

𝑥1 = 29/13 𝑥2 =23/13 𝑥3 = -17/13

Activity 2. Use the inverse of matrix B

1 1 1
𝐵 = [4 5 3] to decode the cryptograph using MATLAB
5 6 3
example on MATLAB encode: [55 63 40] * [inv(B)] = answer ( decoded row matrix )

55 63 40 204 245 143 174 207 120 47 55 38 19 20 17 42 49 35 60 70 41 86


101 57 81 96 52 91 112 63 13 16 9 127 148 86 57 71 42 82 96 55 106 132
79 109 128 71 81 97 49 84 102 55 50 62 37 90 110 69 42 49 35 90 105 61
71 84 46 34 42 25 57 71 43 92 113 64 104 125 63 100 121 72 106 129 69 92
113 64 49 61 36 103 123 72 82 102 61 14 14 14
The message is: PAGTUTULUNGAN ANG KAILANGAN NG BAWAT MAMAMAYAN SA
PAGKAKAISANG PANGALAGAAN ANG ATING INANG KALIKASAN.
Activity 3.Find the least squares regression line for the points ( 1, 0 ), ( 2, 0 ), ( 3, 0 ), ( 3, 1 ),
( 4, 1 ), ( 4, 2 ), ( 5, 2 ), and ( 6, 2 ) using MATLAB

𝖥1 1⎤ 0 ⎤
⎢1 2⎥ 0 ⎥
⎢1 3⎥ 0 ⎥
X = ⎢1 3⎥ Y= 1 ⎥
⎢1 4⎥ 1 ⎥
⎢1 4⎥ 2 ⎥
⎢1 5⎥ 2 ⎥
⎣1 6⎦ 2 ⎦

then, type on command window: rats[( inv( X’ * X ) ) * ( X’ * Y )]

answer: y=-3/4 + ½ x
Technological Institute of the Philippines - Manila Course: MATH 022A
Math & Physics Department ONLINE LECTURE

Exercises

1. Solve the system of linear equation using LU – Factorization of the matrix


Coefficient matrix
2x1 + 6x2 + 4x3 = 5 2 6 4
6x1 + 19x2 + 12x3 = 6 [6 19 12]
2x1 + 8x2 + 14x3 = 7 2 8 14
1 0 0 2 6 4
L = [3 1 0] U= [ 0 1 0]
1 2 1 0 0 10

𝑥1 =51/2 𝑥2 = -9 𝑥3 = 2

1 0 2
2. Decode the following Filipino riddles and answer it, using matrix C = [2 −1 1]
0 1 2

a.) 10 24 67 29 –14 16 16 –1 29 37 –9 47 13 10 45 1 2 6
43 –10 55 13 –1 23 28 –7 35 44 –10 47 23 –10 15

the message is: HAYAN NA SI KAKA BUKAKA NG BUKAKA

b.) 23 4 43 2 24 51 26 –12 15 25 11 72 19 –7 15 23 –6 27
14 11 50 39 –18 23 15 –1 27 41 –15 37 13 7 39 49 –20 38
21 0 41 14 0 28

the message is: AKO AY MAY KAIBIGAN KASAMA KO KAHIT SAAN

c.) 53 –7 71 7 11 36 19 3 35 29 –14 16 43 –15 41 34 5 69


41 –19 24 25 19 88 23 –10 15 32 –15 18 16 13 50 15 1 31
1 1 4 28 –7 35 44 –13 41 51 –25 27

the message is: KUNG KAILAN MO PINATAY SAKA PA HUMABA ANG BUHAY
Technological Institute of the Philippines - Manila Course: MATH 022A
Math & Physics Department ONLINE LECTURE

3. A notebook manufacturing company has experience the following costs ( in P1000 ) for the
first half of the year.

Month January February March April May June


Notebook (X) 3 3.4 2.8 3.3 3 3.5
Costs (Y) 219 221 216 225 218 223

𝖥 1 3⎤ 219 ⎤
⎢1 3.4⎥ 221 ⎥
⎢1 2.8⎥ 216 ⎥
X =⎢1 3.3⎥ Y= 225 ⎥
⎢1 3⎥ 218 ⎥
⎢1 3.5⎥ 223 ⎥

a.) Find the least squares regression line for the cost from January to June.

y=259/25 x + 375/2

b.) If the company produce a 3.8 notebook, predict the cost of the company.

y=226.868

c.) If the company produce a 5.35 notebook, predict the cost of the company.

y=242.926
Technological Institute of the Philippines - Manila Course: MATH 022A
Math & Physics Department ONLINE LECTURE

Conclusion:
We concluded that in LU factorization we can solve the variable x. Applying these
techniques to a certain matrix, we can decode the matrices into a message. The
letter's equivalent number can be obtained by multiplying the inverse by the matrix.
Using least square regression, we may predict the costs in a specific organization
based on the information given. We can easily compute and get results faster by using
MATLAB.

Proprietary Clause

Property of the Technological Institute of the Philippines (T.I.P.). No part of the materials made
and uploaded in this learning management system by T.I.P. may be copied, photographed, printed,
reproduced, shared, transmitted, translated or reduced to any electronic medium or medium-
readable form, in whole or in part, without prior consent of T.I.P.
Technological Institute of the Philippines - Manila Course: MATH 022A
Math & Physics Department ONLINE LECTURE

You might also like