1. Trang chủ
  2. » Luận Văn - Báo Cáo

group project linear algebra

18 0 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Group Project Linear Algebra
Tác giả Tran Thi Hoai An, Hoang Thi Diộp Suong, Nguyễn Tuan Phong, Nguyễn Vũ Duy Bảo, Lờ Quang Đăng
Người hướng dẫn Dau Thế Phiệt, Mr.
Trường học HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY
Chuyên ngành Linear Algebra
Thể loại Project
Năm xuất bản 2023
Thành phố Ho Chi Minh City
Định dạng
Số trang 18
Dung lượng 3,26 MB

Nội dung

= The report must have 3 parts: 1 The theory and algorithm as your understanding; 11 The Matlab or Python commands it isn’t allowed any direct command to solve the problem, explain impor

Trang 1

VIETNAM NATIONAL UNIVERSITY

HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY

GROUP 1 - CLASS CC12 - SEMESTER 222 FACULTY OF APPLIED SCIENCE

GROUP PROJECT LINEAR ALGEBRA PROJECT 1

Instructor: Mr Dau Thế Phiệt

1 2153187 Tran Thi Hoai An Manual solving

2 2153771 Hoang Thi Diép Suong Manual solving

3 2252611 Nguyễn Tuan Phong Code programming

5 2252152 Lê Quang Đăng Code programming

Ho Chi Minh City, April 27, 2023

Trang 2

TABLE OF CONTENT REQUIREMENTS

CALCULATION

2.1 Problem |

2.1.1 Theory and algorithm

2.1.2 Python commands

2.2 Problem 2

2.2.1 Theory and algorithm

2.2.2 Python commands

2.3 Problem 3

2.3.1 Theory and algorithm

2.3.2 Python commands

REFERENCES

Trang 3

REQUIREMENTS

The students work in a group and write a report for the given project (See the team information)

= Using Matlab or Python to solve the following problems and write a report

= The report must have 3 parts:

1) The theory and algorithm (as your understanding);

11) The Matlab or Python commands (it isn’t allowed any direct command to solve the problem, explain important steps);

ui) The results and conclusion

CALCULATION

2.1 Problem 1

A code breaker intercepted the encoded message below

45 -35 38 -30 18 -18 35 -30 81 -60 42 -28 75 -55 2 -2 22 -21 15 -10 Let the inverse of the encoding matrix be A~! = E v |

(a) You know that [45 — 35]A ! =[10 15] and [38 — 30|A"! =

[8 14] Write and solve two systems of equations to find w, x, y, and (b) Decode the message

2.1.1 Theory and algorithm

Theory

Systems of equations with unique solutions

If A is an invertible matrix, then the system of linear equations Ax = b has a

unique solution x = A”b

Ax=b

A-lAx=A-Ib

Trang 4

lx= A-Ib

x=A-Ib

Then you could apply solve each system by computing the product A—1 to find w,X,y and z

Cryptography

A message written in a secret code is known as a cryptogram (the Greek word kryptos meaning "hidden") Matrix multiplication is one of the methods for encoding and decoding secret messages

In this application procedure, we must gain alphabet letters to each number, which is comprehensively illustrated below

5=E

6=F

7=

8=

= Step 1: Utilize the row of coded matrices and multiply it by the inverse of the matrix that was used to encode the message

= Step 2: Associate the numbers with their corresponding letters

Algorithm

Trang 5

(a) Write and solve two systems of equations to find w.x,y and z

, ` == mm

= 10 C1)

[ 3@ - 30] |

=>

38x - 3Ò0z = Ìh Cx)

wo s 4

Trang 6

4L -9

MM Tan : | | = | I£ -lI€ ieC2) -\e C3)

= [0 !1#|

seu nies on " 1¬ 35C2) - 3oC 3) |

`

L $4 eol[ h an xa -60 g1 2) -60C-3) |

= ve \8|

-C 0]

¬= ai i" ˆ -[ 745 -55 E2

- [ 20 \5}

(b) Decode the message

ae Ï 7 a a 2(-2) -2(-3)]

aay -zñ[ " xà: pen 220-2) -71(-a) 1

=fL1 1a]

joe raf 5s aap Cen Cm [era Teo

-L5 o]

We use ALZ26 rT a ale decode rmaseoae (S :

[ 1D !S][ƒ 9 IzIƒO 1#1†fƒS 26\ƒ21 1g]{ 1l of

[2o is} Foz] C4 aal Cs ol]

import numpy as np

Trang 7

x, y, Z, t, h=0, 0, 0, 0, 0.01

for 1 in range (100000):

x=x-h* (45*x-35*y-10)

x =x -h * (38*x-30*y-8)

y =y -h * (45*x-35*y-10)

y =y -h* (38*x-30*y-8)

z=z-h* (45*z-35*t-15)

z=z-h* (38*z-30*t-14)

t=t-h * (45*z-35*t-15)

t=t-h* (38*z-30*t-14)

#find the inverse matrix

A= np.array([[round(x, 1), round(z, 1)], [round(y, 1), round(t, 1)]]) #inverse matrix

#declare the remaining pair of encoded message

mat = np.array([18, -18])

mat2 = np.array([35, -30])

mat3 = np.array([81, -60])

mat4 = np.array([42, -28])

mat5 = np.array([75, -55])

mat6 = np.array(([2, -2])

mat7 = np.array([(22, -21])

Trang 8

mat8 = np.array([15, -10])

#decoded message

resl =matl@A

res2 = mat2@A

res3 = mat3@A

res4 = mat4@A

res5 = mat5()A

res6 = mat6@A

res7 = mat7@A

res8 = mat8@A

print("JOHN RETURN TO BASE")

Result

2.2 Problem 2

Construct an inner product in R" In that inner product, write a pro- gram to input any number of vectors in R" and return the orthogonal basis and orthonormal basis of the subspace spanned by these vectors (Use Gram - Schmidt process) From that, given any vector in R", find the coordinates in that basis and find the length of the vector

2.2.1 Theory and algorithm

Theory

Gram-Schmidt Orthonormalization process

Trang 9

Let B = {vl, v2, ., v7} an inner product space basis V

Let B’ = {wl, w2, w2}, where

wl=vl

w2=v2-wl

w3=v3-wl-w2

wn=vn-wl-w2- -

Then B’ is an orthogonal basis for V

Let u= Then 8” = {ul, w2, uz} is an orthonormal basis for V

And, span{vl, v2, , vk} =span{ul, u2, , uk} fork=1, 2, 19 H

Coordinates Relative to Orthonormal Bases

One way to express a vector u as a linear combination of basis vectors S={vl, v2, , vn} is to convert the vector equation

U = CIVI+ C2V2T T CnVn

to a linear system and solve for the coefficlents cị,ca, c„ However, if the basis

is orthogonal or orthonormal, then the following theorem shows that the coefficients can be obtained more simply by identify appropriate inner products IfS = {vl, v2, vn} is an orthogonal basis for an inner product space V, and if

u is any vector in V, then

u=vịir+z +

Algorithm

Trang 10

Tee hath sabe | fat} —

Ù B=} ny = 4,4, OS uy 44,3,0) tạ =(6,4,4))-

© 4 baCIic

ay ind outer and rrr bas b

/ Find ornrdnale> and rn me “ˆ vecslir.u = C4, 4, 4)

BƑ TrhằẶ< -(4,4, 9)

| 2 ay KY V vy hao 2 2 r | 5:0

#Ò- 3 th —S<M „t3 4 <wy ,vv> 72

| | oh, 2 20440) C h2 ) el > - “(+41 2 ,d)+ 2 4⁄4 C £14 10) = C0,0,2)

PWT Huda OO Sg 9 0.2.)6 (erthaganal bers)

a Gerthanar ena basis) —— "TN

Trang 11

b/ Lm l alate d

Wehave 8" is arthonermel b4}j $ , sa ie R?

SW,~> + Kyu? _ Ky, Qy wv? - 4

yt l zy “Wall | , Hest —P

thot is (A,4,4) = = Ee io) + 0Á: £¡9)*100s2

TU TT

| + >l ¡0i 0 |

ull = \(¢) +0 42 =

2.2.2 Python commands

mman

# -*- coding: utf-8 -*-

111111

Created on Mon May 1 08:29:09 2023

@author: Tuan Phong

111111

# Import modules

from sympy import *

import numpy as np

import math

Trang 12

# Input basis E

R = int(input("Enter the number of rows of matrix E:"))

C = int(input("Enter the number of columns of matrix E:")) matrixE = []

print("Enter the entries rowwise of matrix E:")

for 1 in range(R): # Input the entries by rows

a=]

for j in range(C):

a.append(int(input()))

matrixE.append(a)

# Print matrix for checking

print("Your input basis E is:")

for 1 in range(R):

for j in range(C):

print(matrixE[i][j], end ="")

print()

#Create functions calculating the norm of a vector def norm(A):

result = math.sqrt(np.dot(A, A))

return result

#CALCULATE THE ORTHOGONAL BASIS

#The first vector fl:

el = matrixE[0]

fl =el

Trang 13

#The second vector f2:

e2 = matrixE[1]

dot e2 fl =np.dot(e2, fl) #Calculate the dot product of e2 and fl

dot fl_ fl =np.dot(fl, f1) #Calculate the dot product of fl and fl

f2 = np.subtract(e2, (dot_e2 fl /dot fl fl) * np.array(fl)) #Calculate the second vector of orthogonal basis by using Gram Schmidt

#The third vector £3:

e3 = matrixE[len(matrixE)-1]

dot_e3_ fl =np.dot(e3, fl) #Calculate the dot product of e3 and fl

dot_e3_ f2 =np.dot(e3, £2) #Calculate the dot product of e3 and f2

dot f2 2 =np.dot(f2, 2) #Calculate the dot product of f2 and f2

mid_ f3 =np.subtract(e3, (dot_e3_ fl /dot_fl_fl) * np.array(f1))

f3 =np.subtract(mid_ f3, (dot e3 f2 /dot f2 f2) * np.array(f2)) #Calculate the third vector of orthogonal basis by using Gram Schmidt

F= np.array([f1,f2,f3])

print("The orthogonal basis of E is: ", F)

#CALCULATE THE ORTHONORMAL BASIS

W=II

for 1 in range(len(F)):

w = F[i] / (norm(F[i]))

Trang 14

W.append(w)

print("The orthonormal basis of E is: ", np.array(W))

# Given a vector in Rn, find the coordinates in that basis and find the length of the

vector

# Input vector x

R=1

C = int(input("Enter the number of columns of vector x:"))

x=[]

print("Enter the entries wise of vector x:")

for 1 in range(R): # Input the entries by rowwise

a=]

for j in range(C):

a.append(int(input()))

x.append(a)

# Print vector for checking

print("Your input vector x is:")

for 1 in range(R):

for j in range(C):

print(x[1][j], end =" ")

print()

# Finding the coordinate vector of x related to E

x_ WI =np.dot(x, W[0])

Trang 15

x_W2 =np.dot(x, W[I])

x_W3 =np.dot(x, W[2])

x W=np.array([x WI,x W2,x W3])

#Calculate the coordinates

print("The coordinate vector of x related to W is", x_W)

#The length of the vector x_E

1 = math sqrt((x_W1)**2 +(x _W2)**2 +(x W3)**2 )

print("The length of the vector is ", 1)

Result

Your input basis E is:

119

12.9

is

The orthogonal basis of E is: [[ 1

`

[9 9 2 1]

The orthonormal basis of E 1s: [[ 9.70710678 90.70710678 9

[-@.70710678 9.70710678 @ i

Enter the number of columns of vector x:3

Enter the entries wise of vector x:

1

1

Trang 16

Enter the entries wise of vector x:

Your input vector x is:

24

The coordinate vector of x related to Wis [[1.41421356]

The length of the vector is 1.7320508075688772

2.3 Problem 3

In R?, the weighted inner product is given by

(x,y) = axyy, + breye where a and b are positive Find a weighted inner product such that the graph represents a unit circle as

In that inner product space, reflect that unit circle about an input plane

2.3.1, Theory and algorithm

Theory

Algorithm

Trang 17

2.3.2 Matlab/Python Solution

Trang 18

REFERENCES

1 Anton, H., Rorres, C (2005) Elementary Linear Algebra: Applications Version Wiley ISBN: 9781118434413 1118434412 9781118474228

1118474228

2 Dang Van Vinh, Gido trinh dai số tuyến tỉnh, Đại học Bách khoa, Đại học

Quốc gia TPHCM), 2020.

Ngày đăng: 22/07/2024, 17:45