Group assignments given a linear transformation as below, find the f dimension and one basic of im( )

20 28 0
Group assignments given a linear transformation as below, find the f dimension and one basic of im( )

Đ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

VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY FACULTY OF APPLIED SCIENCE -*** Linear Algebra (MT1008) Group Assignments Topic: Group: Team members: Trần Quốc Thái - 2153795 Bùi Văn Nhật Thanh - 2152280 Hà Huy Thành - 2152967 Lê Thành - 2052706 Trịnh Hoài Thanh - 2053427 Semester: HK212 Lecturer: Phan Thi Huong Submission date: Saturday, May 14th, 2022 0 REQUIREMENTS: ● Students work on your assigned groups ● Detailed explanations must be provided to get full scores ● To solve the following questions, please let the constant a be your group ID ● All given exercises must be done by both methods: manual solving and using Matlab or Python TABLE OF CONTENT Project details for each question: I Theories summary II Solution details III Coding details Question 1: Given a linear transformation f as below, find the dimension and one basic of Im(f): f(x1,x2,x3) = (x1 + x2;x2 + x3;x1 - ax3), (a = 9) I Theory: The set of all vectors in F that are images under f of at least one vector in E is called the range of f: �㔼�㕚(Ā) = {ỵ : ý , ỵ = (ý)} = Ā(Ā) If f: E ↦ F is a linear transformation, then: Im(f) of f is a subspace of f II Solution details: Manual solving: MATLAB code and explanation: a Coding details: clc; syms e1 e2 e3 %y=f(x)=x1(e1)+x2(e2)+x3(e3) %a,b,c are constants 0 e1 = input('e1 = [a b c]='); e2 = input('e2 = [a b c]='); e3 = input('e3 = [a b c]='); A = [e1', e2', e3']; %Find the rank of A r = rank(A); %Find basics of Im(f) if (r == 1) Basic = [e1]; disp('Basic of Imf = ');disp([e1]) dimImf = elseif (r == 2) Basic = [e1;e2]; disp('Basic of Imf = ');disp([e1',e2']) dimImf = elseif (r == 3) Basic = [e1;e2;e3]; disp('Basic of Imf = ');disp([e1',e2',e3']) dimImf = end b Results: e1 = [a b c]=[1 1] e2 = [a b c]=[1 0] e3 = [a b c]=[0 -9] Basic of Imf = 1 0 1 -9 dimImf = Question 2: Given f : �㕅3 ³ �㕅2 and the matrix representation of f in E = {(1; 1; 1); (1; 0; 1); (1; 1; 0)}, and F = {(1; 1); (2; 1)} is ýỵ = ; find f(1; 2; 9) I Theory: - Every linear transformation from �㕅Ā ³ �㕅 ÿ can be represented by an m×n matrix Conversely, every matrix m×n represents a linear transformation from �㕅Ā ³ �㕅 ÿ , i.e, we can always write a linear transformation in the form [Ā(ý)]� 㕇 = �㔴ý �㕇 where �㔴ÿ×Ā matrix - If we are given vector images of a basis E in �㕅ÿ , that is we know f(E), then 0 Ā(Ā) = �㔴Ā 21 ⇔putting �㔴 =image Ā(Ā)Ā where f(E), E are two matrices formed by vector of basis, vector of basis in column, respectively - Let f : �㕅Ā ³ �㕅ÿ be a linear transformation and Ā = {ÿ1 , ÿ2 , , ÿĀ } be a basis for �㕅Ā , ā = {Ā1 , Ā2 , , ĀĀ } be a basis for �㕅ÿ Then is called the matrix representation of f with respect to E and F ý,ỵ = 21 () II Solution details: Manual solving: E= F= ýỵ = ý = *ý,ỵ = 21 () = 21 = ý,ỵ Ā 21 = [Ā(ý)]� 㕇 = = �㔴ý �㕇 ⇔ f(1;2;9) = = MATLAB code and explanation: 2.1 MATLAB code: 0 2.2 Explanation: Line 1, 2, 3, 4: Create the matrix E, F, x, AEF respectively Line 5: Find the matrix A through the formula A = F × AEF × E-1 Line 6: Find f(1;2;9) by using the formula [f(x)]T = A × xT Question 3: Let F = {(2; -1; 3); (1; 1; 2); (3; 0; 1); (-1; -4; a)} be a subspace of R3 with the inner product < x; y >= 3x1y1 - x1y2 - x2y1 + 4x2y2 + 4x3y3 a) Find a basis and the dimension of F⊥ b) Find the vector projection of w = (3; -2; 1) onto F I Theory: Definition 1: Two vectors x, y V in an inner product space V is called orthogonal  =0 We denote it by x ⊥ y (x perp y) Vector x is orthogonal to the set M  V if x is orthogonal to every vector in M We denote it by x ⊥ M 0 Theorem 1: Vector x is orthogonal to a subspace F if and only if x is orthogonal with a basic of F Definition 2: A set of two or more vectors in a real inner product space {x1, x2, …, xn} is called orthogonal  all pairs of distinct vectors in the set are orthogonal An orthogonal set in which each vector has norm is said to be orthogonal xk = 1, ( k = 1, 2, , n) Definition 3: If F is a subspace of a real inner product space V, then the set F⊥ of all vectors in V that are orthogonal to F is called the orthogonal complement of F Theorem 2: Let R be a subspace of a real inner product space V then F⊥ is a subspace of V, and: dim F + dim F⊥ = dim V Scheme of finding F⊥ of a subspace F: Find a basis of F Assume that basic of F contains vectors {e1, e2, …, en} ü e1 , y = ü ÿ ÿ F = ý( y1 , y2 , , y n ) e2 , y = ý ÿ en , y = ỵ ỵ Find the dim and a basic of this null space Scheme of finding y = projFx - Find a basis of F, let it be S = {e1, e2, …, em} - Since y  F => y = 1e1 + 2e2 + + mem - x = y + z, then: y = 1e1 + 2e2 + + mem + z ü x , e1 = e1 ,e1 1 + e ,e1 2 + + e m ,e1 m ÿ ÿ x, e2 = e1, e2 1 + e2 , e2 2 + + em, e2 m  y = proj F x = 1e1 + 2e2 + + mem ý ÿ ÿ x , em = e1 ,em 1 + e2 ,e m 2 + + em , em m ỵ II Solution details: Manual solving: a) Find a basis and the dimension of F⊥ ù −1 ù A = úú −1 úú úû 0 úû Find the rank of the subspace F: 0 ù − 1ù ù − 1ù ù − 1ù r2 →2 r2 + r1 r3 → r3 − r2 ú ú ú ú → 3 − ⎯⎯⎯⎯ →ú 3 − 9ú F = ú − 1 − 4ú ⎯⎯⎯⎯ r3 → 2r3 − 3r1 ú ú ú ú úû úû úû −7 21úû úû 0 − 24 72úû  r( F ) =  dim F =  dim F ⊥ = A basis of F is S = {(2, -1, 3), (1, 1, 2), (3, 0, 1)} ö −1 3ư ù − 0ù ÷ ÷ F = null (SA ) = ÷ 1 ÷úú − 0úú  = ÷ ÷ ú 0 4ú ø øû û ⊥  A basis of F is {(0, 0, 0)} ⊥ b) Find the vector projection of w = (3; -2; 1) onto F Since y  F => y = 1e1 + 2 e2 + + m em ü x, e1 = e1 , e1 1 + e2 , e1 2 + e3 ,e1 3 ÿ ý x , e2 = e1 ,e2 1 + e2 ,e2 2 + e3 ,e 3 ÿ x , e = e ,e  + e ,e  + e ,e  3 3 3 ỵ x, e1 ửxử ữ ữ ữ e1 ÷ e ,e T T T ÷  A (e1 e2 e3 ) = ÷ 1 ÷ e , e1 ÷e ÷ ÷÷ ÷ ÷ øe ø ø e ,e1 x , e3 ö ö 45 ÷ ÷ e1 ,e ÷ ÷ 56 25 = e ,e ÷ ÷ 25 21 ÷ ÷ e ,e ÷ø ø 33 14 x , e2 e1 , e e ,e e ,e 37 ÷ 33 ÷ 14 ÷ ÷ 31 ø ü ÿ 1 = ü 45 = 561 + 25 + 33 ÿ −7 ÿ ÿ  ý = 251 + 212 + 143  ý2 = ÿ 37 = 33 +14 + 31 ỵ = ỵ y = proj Fx = 1e1 + 2 e2 + 3e3 = (3, −2,1) MATLAB code and explanation: a Coding details: clc; syms x y z A =[3 -1 0;-1 0; 0 4]; %Input the matrix of spanning set of F e1 = [2 -1 3]; e2 = [1 2]; e3 = [3 1]; e4 = [-1 -4 9]; F = [e1;e2;e3;e4]' r = rank(F) if (r == 1) S = e1 elseif (r == 2) 0 S = [e1;e2] elseif (r == 3) S = [e1;e2;e3] end %Input the matrix of the inner product %Fo: Orthogonal F Fo =(S')*A kerf=null(Fo); dimFo = size(ker,2) % b)Find the vector projection of w = (3; -2; 1) onto F x = [3;-2;1]; E = [dot(e1,e1) dot(e1,e2) dot(e1,e3); dot(e2,e1) dot(e2,e2) dot(e2,e3); dot(e3,e1) dot(e3,e2) dot(e3,e3)] D = [dot(x,e1); dot(x,e2) ; dot(x,e3)]; X = mldivide(sym(E), sym(D)) ; fprintf('The projection of w onto F: ') (X(1,1)*e1 + X(2,1)*e2 + X(3,1)*e3) b Results: F= -1 1 -1 -4 r= S= -1 1 Fo = -4 dimFo = E= 14 7 12 10 The projection of w onto F: ans= [ 3, -2, 1] 0 Question 4: Determine the currents I1, I2, I3 and for the given electrical network 4�㔼1 3�㔼2 = 4�㔼1 + 3�㔼2 = ³ (1) 1�㕅3 3�㔼2 = �㕅3 + 3�㔼2 = ³ (2) 4�㔼1 + 1�㕅3 = 4�㔼1 �㕅3 = ³ (3) Eauation (1), (2) & (3) in matrix form as, 3 [0 4] 21 ´ �㕅3 ³ �㕅3 �㕅1 3 [0 4] 21 22 ´ �㕅3 ³ �㕅3 + �㕅2 3 [ 4] 0 ´ �㕅3 ³ �㕅3 × 3 [ 4] 0 0 3�㔼2 + �㔼3 = 3�㔼2 = �㔼3 4�㔼3 �㔼2 =2 3 Solution: Substitute �㔼2 in (1) 4�㔼1 = 3�㔼2 4�㔼01 + 3�㔼2 = ]�㔼3 4�㔼 = 3 [ 4�㔼1 = 43+ �㔼3 4�㔼1 = 21 + �㔼3 �㔼1 = Dependent solution if = ỵ + = ỵ = ỵ If = amp ỵ = 2 =ỵ Matlab a) The code: function ex3 clc, clear, close all; disp('Solve the systems AX = B using gaussian elimination'); n = input('Input number of equations n = '); k = input('Input number of variables k = '); result = zeros(0,0); disp('Example for input equation: [1 4] means x1 + 2*x2 + 3*x3 = 4'); for i = 1:n T = input([ 'Input equation ' num2str(i) ' : ']); result = [result; T]; end disp('The system of equations :'); disp(result); for i = 1:(n-1) disp(' -'); disp(['Step ' num2str(i)]); for j = (i+1):n if result(i,i) == 0 temp = result(j,:); result(j,:) = result(i,:); result(i,:) = temp; else result(j,:) = result(j,:) -(result(j,i)/result(i,i))*result(i,:); end end disp(result); disp('Press Enter to continue'); pause; end disp(' -'); A = result(:,1:k); rresult = 0; rA = 0; for i = 1:n for j = 1:(k+1) if abs(result(i,j)) > 0.0001 rresult = rresult + 1; break; end end end for i = 1:n for j = 1:k if abs(A(i,j)) > 0.0001 rA = rA + 1; break; end 0 end end if rresult ~= rA disp('No solution !'); elseif rresult == rA if rresult == n disp('Unique Solution'); x = zeros(k,1); for s = 1:n i = n+1-s; sum = 0; for j = (i+1):k sum = sum + result(i,j)*x(j); end x(i) = (result(i,k+1) - sum)/result(i,i); end disp('Solution: ');disp(x); else disp('Infinity Solution'); disp([num2str(k - rresult) ' free variable']); end end end b) On the screen: 0 Question 5: Generate a random matrix A which has the size of ×4 and is diagonalizable Then, return its eigenvalues, the corresponding eigenvectors and compute A100 I Theories summary What is a diagonalizable matrix? A square matrix is said to be diagonalizable if it is similar to a diagonal matrix That is, A is diagonalizable if there is an invertible matrix P and a diagonal matrix D such that A=PDP-1 What are eigenvalues and the corresponding eigenvectors of a matrix? Many problems present themselves in terms of an eigenvalue problem: �㔴 �㕣 = �㔆 �㕣 In this equation A is an n-by-n matrix, v is a non-zero n-by-1 vector and λ is a scalar (which may be either real or complex) Any value of λ for which this equation has a solution is known as an eigenvalue of the matrix A It is sometimes also called the characteristic value 0 The vector, v, which corresponds to this value is called an eigenvector The eigenvalue problem can be rewritten as: �㔴 �㕣 �㔆 �㕣 = �㔴 �㕣 �㔆 �㔼 �㕣 = (�㔴 �㔆 �㔼) �㕣 = If v is non-zero, this equation will only have a solution if |�㔴 �㔆 �㔼| = This equation is called the characteristic equation of A, and is an nth order polynomial in λ with n roots These roots are called the eigenvalues of A We will only deal with the case of n distinct roots, though they may be repeated For each eigenvalue there will be an eigenvector for which the eigenvalue equation is true This is most easily demonstrated by example: Find Eigenvalues and Eigenvectors of a 2x2 Matrix �㔴 = [ ] 22 23 Then the characteristic equation is |�㔴 �㔆 �㔼| = | []02 [�㔆 ]|=0 22 23 �㔆 2�㔆 ]| = �㔆2 + 3�㔆 + = |[ 22 23 �㔆 �㔆1 = 21 And the two eigenvalues are: { �㔆2 = 22 All that's left is to find the two eigenvectors Let's find the eigenvector, �㕣1 , associated with the eigenvalue, λ1=-1, first �㔴 �㕣1 = �㔆 �㕣1 (�㔴 �㔆1 ) �㕣1 = 2�㔆1 [ ] �㕣1 = 22 23 �㔆1 1 �㕣1,1 1 ] [ �㕣 ] = ] �㕣1 = [ [ 22 22 1,2 22 22 so clearly from the top row of the equations we get �㕣1,1 + �㕣1,2 = ý�㕟 �㕣1,1 = 2�㕣1,2 Note that if we took the second row we would get (22) �㕣1,1 + (22) �㕣1,2 = ý�㕟 �㕣1,1 = 2�㕣1,2 In either case we find that the first eigenvector is any element column vector in which the two elements have equal magnitude and opposite sign +1 �㕣1 = �㕘1] [ 21 where k1 is an arbitrary constant Note that we didn't have to use +1 and -1, we could have used any two quantities of equal magnitude and opposite sign Going through the same procedure for the second eigenvalue: �㔴 �㕣2 = �㔆 �㕣2 2�㔆2 1�㕣2,1 (�㔴 �㔆2 ) �㕣2= [ ] �㕣2 = [ ] [ �㕣 ] = 22 23 �㔆2 2,2 22 21 So �㕣2,1 + �㕣2,2 = �㕣2,1 = 2�㕣2,2 If 10 0 +1 Again, the choice of +1 and -2 for�㕣 the eigenvector was arbitrary; only their ratio is = �㕘2] [ 22 important This is demonstrated in the MatLab code below The application of diagonal matrix Diagonal matrices are relatively easy to compute with, and similar matrices share many properties, so diagonalizable matrices are well-suited for computation In particular, many applications involve computing large powers of a matrix, which is easy if the matrix is diagonal But if A=PDP-1, then �㔴Ā = (�㕃ÿ�㕃21 )Ā = (�㕃ÿ�㕃21 )(�㕃ÿ�㕃21 )(& )(�㕃ÿ�㕃21) = �㕃ÿ because the �㕃21 �㕃 terms in the middle all collapse Solution details 4 ] Choose the matrix �㔴 = [ 4 0 0 0 The unit matrix is �㔼 = [ ] 0 0 0 Then we have |�㔴 �㔆 �㔼| = So that 0 |[ 2] �㔆.0[ 0]| = 4 0 0 11 0 22 4� |[ Solve this equation we have: 4㔆 2� 㔆 122 � 㔆 4 ]| = �㔆31 = 12.2111 �㔆 �㔆2 = 22.2111 �㔆3 = 1.0000 �㔆4 = 0.0000 4 2] ,which are the eigenvalues of the matrix �㔴 = [ 4 20.4234 20.5217 ] With �㔆1 = 12.2111 the eigenvector is [ 20.4531 20.5858 20.2156 20.5249 With �㔆2 = 22.2111 the eigenvector is [ ] 20.8059 20.1688 20.3455 0.7775 With �㔆3 = 1.0000 the eigenvector is [ ] 20.5183 0.0864 0.2641 20.8805 ] With �㔆4 = 0.0000 the eigenvector is [ 0.3522 0.1761 20.4234 20.2156 20.3455 0.2641 20.5217 20.5249 0.7775 20.8805 So we have �㕃 = [ ] and 20.4531 20.8059 20.5183 0.3522 20.5858 20.1688 0.0864 0.1761 12.2111 0 0 22.2111 0 ] ÿ=[ 0 0.0000 0 0 1.0000 Then �㔴100 = �㕃ÿ100 �㕃21 = 20.4234 20.2156 20.3455 0.2641 12.2111 0 22.2111 20.5217 20.5249 0.7775 20.8805 [ ][ 0 20.4531 20.8059 20.5183 0.3522 0 20.5858 20.1688 0.0864 0.1761 0 0.0000 10 0 ] 1.0000 12 0 20.4234 5217 20.2156 5249 0.7775 20.8805 20 20.4531 20 20.8059 20.3455 20.5183 0.2641 0.3522 21 [ ] 0.9375 0.9008 1.1102 1.0535 1.2984 0.7607 0.8142 0.9642 1.1276 108 20.5858 20 1688 0.1761 = 10 [ 0.0864 1.0526 1.2466 1.4578 Coding details a Full MATLAB code: 1.5481 2562 1.3446 ] 1.7383 %Clear all text from the Command Window clear all; clc; %Input the matrix 4x4 that we need to use in this problem A=input('Enter the matrix A: ') %Check the matrix if it is already diagonal? check=isdiag(A); if check==true disp('The matrix is already diagonal'); %Calculate A power 100 fprintf('A power of 100 = A^100:') A100 = A^100; ANSWER = real(A100) else F=size(A,1); %Check the matrix whether it is diagonalizable or not? syms lambda I = eye(F); lambda1 = solve(det(A - I*lambda)==0); numrows=size(lambda1,1); V=[]; for i = 1:numrows v = null(A-lambda1(i,1)*I); V=[V,v]; end 13 0 B=transpose(V); C=rank(B); E=size(B,1); if C==F disp("The matrix is diagonalizable") p =poly(A); eigs = roots(p); M=[]; for i=1:4 m= eigs(i); M=[M,m]; end disp("The eigenvalues are:") disp(M) %Show the output of the problem: V is the matrix concluding all %eigenvectors and D is a diagonal matrix with eigenvalues located on the %main diagonal fprintf('Eigenvectors are:\n') [V,D] = eig(A) %Calculate A power 100 fprintf('A power of 100 = V*D^100*inv(V):') A100 = V*D^100*inv(V); ANSWER = real(A100) else %Ask the user to input another matrix disp("The matrix is not diagonalizable Let's try another matrix") end end b Results and explanation: If we input a diagonal matrix, this code will help us to find �㔴100 directly: 14 0 c Note: The result is strange because it is too big to display in decimal number 4 ], we will get eigenvalues: When we input a vector �㔴 = [ 4 �㔆1 = 12.2111 �㔆2 = 22.2111 �㔆3 = 1.0000 �㔆4 = 0.0000 Also, the eigenvectors are concluded in vector 20.4234 20.2156 20.3455 0.2641 20.5217 20.5249 0.7775 20.8805 �㕉 = [ ] 20.4531 20.8059 20.5183 0.3522 20.5858 20.1688 0.0864 0.1761 The result of �㔴100 is shown in Figure 15 0 2 However, if we input a matrix that is not diagonalizable �㔴 = [ The result will be: FIGURE 4 ] 16 0 ... e3'']; %Find the rank of A r = rank (A) ; %Find basics of Im (f) if (r == 1) Basic = [e1]; disp( ''Basic of Imf = ''); disp([e1 ]) dimImf = elseif (r == 2) Basic = [e1;e2]; disp( ''Basic of Imf = ''); disp([e1'',e2'' ]). .. transformation f as below, find the dimension and one basic of Im (f) : f( x1,x2,x 3) = (x1 + x2;x2 + x3;x1 - ax 3), (a = 9) I Theory: The set of all vectors in F that are images under f of at least one vector... is called the range of f: () = {ỵ : ý , ỵ = (? ?)} = () If f: E F is a linear transformation, then: Im (f) of f is a subspace of f II Solution details: Manual solving: MATLAB code and explanation:

Ngày đăng: 21/12/2022, 08:34

Tài liệu cùng người dùng

Tài liệu liên quan