Currently, science is growing, with this development strength, the application of science and scientific patents in schools is very feasible and significant. Since the first year, Ho Chi Minh City University of Technology lecturers have helped technical students get acquainted with programming applications such as MATLAB. MATLAB is a rising and programming environment that allows calculating numbers with matrices, graphing functions or charting information, implementing algorithms, creating user interfaces, and linking to computer programs written in many other programming languages. MATLAB enables simulation of calculations with the Toolbox library, experimenting with many models in practice and techniques. With more than 40 years of establishment and development, MATLAB is an effective calculation tool to solve technical problems today with a relatively simple and universal design. Therefore, for the problems in Algebra, especially matrix problems, we can use MATLABs computing applications to solve most simply and understandably, helping us get acquainted and add more skills to use programs application for students.
Trang 1HCMC University of Technology MATLAB Exercises
Department of Applied Mathematics Subject: Linear Algebra
1 Introduction
Currently, science is growing, with this development strength, the
application of science and scientific patents in schools is very feasible and significant Since the first year, Ho Chi Minh City University of Technology lecturers have helped technical students get acquainted with programming applications such as MATLAB MATLAB is a rising and programming
environment that allows calculating numbers with matrices, graphing
functions or charting information, implementing algorithms, creating user interfaces, and linking to computer programs written in many other
programming languages MATLAB enables simulation of calculations with theToolbox library, experimenting with many models in practice and techniques.With more than 40 years of establishment and development, MATLAB is an effective calculation tool to solve technical problems today with a relatively simple and universal design Therefore, for the problems in Algebra,
especially matrix problems, we can use MATLAB's computing applications to solve most simply and understandably, helping us get acquainted and add more skills to use programs application for students
3 Solutions
Question 1: Find the argument, module of z=1+i√3
1+i z= 1+i√3
Question 2: Find the argument, module of z = (1+i√ 3) (1-i)
Trang 2z2=z−´z ↔ (x + yi)2=x+ yi−(x− yi) ↔ x2
+2 xyi− y2=2 yi
↔ {x2−y2=0
2 xy=2 y ↔ {x=±1 x=1 , {x=0 y=0
The solution to the complex equation is z=0, z=1-i and z=1+i
Question 6:A=(2 −1 42 1 3 −1)5 ; B=(−1 3 0 −1)1 2 0 −1 Find C = A T B, trace of C, rank of C, det of C.
A=(2−1 4 521 3−1); B=(−1 3 0−11 26−1 )
Trang 3−10)A=(−10 2 −4
Trang 512
Trang 6Det (AB)= [-9(2+m)-208m+27(-13+6m)]-[-4(-13+6m)]-117(2+m)+108m]≠0m≠−172
Trang 88
−78
−18
−118
98
1413
8
−78
−18
−11
8
98
−1
8 ) → P A=det ( A ) A−1=8( −54
34
1413
8
−78
−18
−118
98
−1
8 )=(−1013 −7 −16 2
−11 9 −1)
Question 16: Reduce the matrix (1 1 2 12 3 4 5
3 4 6 9) to the row echelon form
6)−r2+r3→r3
→ (1 1 20 1 0
0 0 0
13
3)
Question 17: Solve the equation (3 −15 −2)X=(5 67 8)
(3 −15 −2) X=(5 67 8)
Trang 91641
Trang 10Question 19: Find the NUMBER of solutions of this system ¿
0 0 4 5
0 0 0 0 |−74
5
0 ) The system corresponding to this matrix is:
Trang 11⇒ The system has no solution
Question 22: Find m such that the following system has a unique solution
Trang 13Question 25: Find the dimension and one basis of the span
Question 26: Given V =¿(1 ; 2 ; 1; 1) , (2;−1 ; 1; 3 ),(5 ; 5 ; 4 ; m)>¿ Find m such that
dim(V) is max find a basis of V.
V=(12 −1 12 1
5 5 4
13
m−5)−r2+r3→ r3
→ (10 −5 −12 1
11
Trang 15→ The given requirement is equivalent to such that det(A) ≠ 0 ↔
Question 33: In R3, given 2 bases E={(1;0;1),(1;1;1),(1;1;0)} and
E’={(1;1;2),(1;2;1),(1;1;1)} Find the change of basis matrix from E to E’
Trang 16Question 34: Find m such that x = (1; 0; m) is a linear combination of M =
→ m does not exist such that G ⊂F
Question 36: In R4, given a subspace
V ={(x1; x2; x3; x4)∈ R4∨x1−x2+x3=0∧ x2+x3+x4=0
Trang 17Find the dimension, one basis of V
Trang 18Question 40: In R3 with the dot product, given u=(1 ;1;2), v=(2 ;1 ;−1) Find
ⅆ(u , v ) and find a vector ω orthogonal to u, v
In R3, given a dot product: (u , v )=u1v1+u2v2+u3v3
u−v=(−1 ;0 ;3) The distance between u and v is d (u , v)=‖u−v‖=√ ⟨u−v ,u−v⟩ =
√(−1) (−1)+0+3.3 = √10
Cross product: |i ⃗j⃗ ⃗k
1 1 2
2 1 −1|=−3 ⃗i+5 ⃗j−⃗k A vector ω orthogonal to u , v is (-3;5;-1).
Question 41: In R3, given an inner product
( x , y )=2 x1y1−3 x1y2+x2y2−x2y3−x3y2+4 x3 y3
Find the distance between 2 vectors u=(1 ;2;1) and v=(−1;1 ;2)
u = (1,2,1) v = (-1,1,2) A=(−32 −35 −10
0 −1 4 )
d(u,v) = √(u−v ) A (u−v )T=√7
Question 42: In R3, given an inner product
Trang 19Question 43: In R3, given an inner product
Trang 20The basis of Imf is {(1;0;1),(0;1;-1)} and dim ( Imf )=2.
Question 46: Given f: R3→ R2 satisfying f (1 ;1; 0)=(2;−1), f (1 ;1;1 )=(1 ;2),
Trang 21Therefore, the eigenvectors corresponding to λ1 = -4 are β (−65 , 1), β ≠0.
⇒u=(−56 ) is the eigenvector of A
Question 50: Given A=(3 64 5), λ1−1, λ2=3 Which number is an eigenvalue of
Trang 22Question 51: Given A=(3 1 12 4 2
1 1 3) Find all eigenvalues and the associated eigenvectors of A
Given A=(3 1 12 4 2
1 1 3) Find all eigenvalues∧theassociated eigenvectorsof A
* Find the eigenvalues
( A−I ) x=0 ↔ det ( A−I )=0 ↔| (3 1 12 4 2
So the eigenvalues is 2 and 6 and the eigenvectors of A is (−1 −1 11 0 2
0 1 1)
Question 52: Given A=(−10 −8−8 67
1 −14 m) Find m such that A has an eigenvalue
λ=2 Find all eigenvalues and the associated A with m found
Trang 23Question 54: In R3, given M = {(1; 2; −1), (3; 2; −1), (0; 2; −1)} Find m
such that (3; 8; m) is a linear combination of M
Trang 24Question 56: In R4, given U =¿(1,2,1,1); (2,1,0 ,−2)>¿ and
V =¿(1,5,3,5 ); (3,0,−1 , m)>¿ Find m such that U ≡V
Because U≡W the m=-5
Question 57: In R4, V is the nullspace { x1+x2−x3=0
2 x1+2 X2+x3+x4=0
x1+x2+2 x3+m x4=0Find m such that dim (V ) is max Find the dimension and a basis of V with m inthe question a
dim V=2 and basis= [1, 1, -1,0], [0,0,3,1]
Question 58: In R4, given U =⟨(1,2,1,0 ); (2,−1,1,1)⟩V =⟨(1,1 ,−2,1) ;(2,0,4 , m)⟩ Find msuch that dim(U+V) is min Find the dimension, a basis of U ∩V
Trang 25→ x=α1 (1,2,1,0)+α2 (2 ,−1,1,1)=α2.(35,−
19
5 ,−
25,1)
→ dimensionof U ∩V is1∧a basic is{ (35,−
19
5 ,−
25,1) }
Question 59: In R4 , given 2 nullspaces
U :[ 1 1 2 0
−1 1 −1 2|00], V : [ 1 2 2 2
−1 0 −1 m|00].Find m such that dim(U ∩ V ) is max Find the dimension, a basis of U ∩ V
Trang 26Then the basic of V⊥ is V⊥ = {(1 ,−1,1,0),(0 ,−2,0,1)}
Question 62: In R4, given a span V =¿(2;−1; 1 ; 0) , (−2 ; 1; 0 ; 1)>¿ and a vector
x=(1;1 ;0 ;1) Find Pr v( x)
Prv(x)= V*(VT *V)-1*VT *x
Trang 27Question 64: In R3 with the standard basis, given F = ¿(1 ; 1; 2) , (2; 1 ;−1)>¿ and
a vector x = (1; 2; 3) Find the projection of x onto F
35 )
Trang 28Question 65: In R3, given an inner product ( x , y )=x1y1+2 x2y2+3 x3y3−x1y3−x3y1
Find the angle and the distance between u=(1 ;1;2) and v=(2 ;1 ;−1)
The given two vectors are u=(1 ;1;2) and v=(2 ;1 ;−1) in R3
Question 66: In R3, given an inner product
( x , y )=x1y1+2 x2 y2+5 x3y3−2 x1 y3−2 x3y1 Find the orthogonal complement of
Trang 30Question 70: Given a linear transformation f: R3→ R2, and the matrix of f in
E={(1 ;1;1) , (1;0 ;1) , (1;1 ;0) }, F={(1 ;1) ,(2 ;1) } is A E , F=(2 1 −30 3 4 ) Find the matrix of
f in the standard bases
Question 71: Given a linear transformation f: R3
→ R3 with the matrix in the basis E={(1 ;2;1) , (1;1 ;2) ,(1 ;1;1) } is
A E=(1 0 12 1 4
1 1 3) Find the matrix of f in the standard bases
We call the matrix basis of f is e
Trang 31Question 73: Given a linear transformation f : R3
→ R3 with the matrix in the basis E={(1 ;1;2) , (1;1 ;1) ,(1 ;2;1) } is
Trang 32[f (1;2 ;1)] E=(1 1 −12 3 3
1 2 4 ) (00
1)=(−13
4 ) → f (1 ;1;2 )=−(1 ;1;2)+3 (1 ;1;1)+4 (1;2 ;1)=(6 ;10 ;5) Imf =¿f (1 ;1 ;2), f (1 ;1 ;1 ), f (1 ;2;1)≥¿(4 ; 5 ; 5) , (6 ; 8 ; 7) ,(6 ; 10 ; 5)>¿
A basis of Imf is {(4;5;5), (0;-2;2)} and the dimension of Imf is 2.
Question 74: Given a linear transformation f : R3 → R3 with the matrix in thebasis E = {(1; 0; 1),(1; 1; 1),(1; 1; 0)} is
Trang 33Question 2: Find the argument, module of z = (1+i√ 3) (1-i)
[x,y] = solve( 'x^2 - y^2 - x= 0' , '2*x*y + y = 0' );
disp( 'The solution to the complex equation is ' );
[x,y] = solve( 'x^2 - y^2 = 0' , '2*x*y - 2*y = 0' );
disp( 'The solution to the complex equation is ' );
Trang 3412
Trang 35%compute f(A) using the formula
f_A = A^2 -(2*A) -3
Question 16: Reduce the matrix (1 1 2 12 3 4 5
3 4 6 9) to the row echelon form
Trang 37Question 20: Find the NUMBER of solutions of this system
Trang 38Question 26: Given V =¿(1 ; 2 ; 1; 1) , (2;−1 ; 1; 3 ),(5 ; 5 ; 4 ; m)>¿ Find m such that
dim(V) is max find a basis of V.
Trang 40ans =
[ 1, 0, 0]
[ 0, 1, 1]
[ 0, 0, 0]
% Since the rref (row reduced echelon matrix) of the coefficient matrix of
% given vectors has a row with all elements zero So, the rref is not a
% full rank matrix (it doesn't matter what have we chosen 'm') Hence,
% given vectors are linearly dependent for all 'm' Therefore, the given
% set cannaot be a basis of P_2[x].
% There does not exist such 'm' for which the given set is a basis for
% P_2[x].
Question 33: In R3, given 2 bases E={(1;0;1),(1;1;1),(1;1;0)} and
E’={(1;1;2),(1;2;1),(1;1;1)} Find the change of basis matrix from E to E’
>> F=[1 1 -1 -1;1 -1 3 -1]
F =
Trang 41>> %m does not exist
Question 36: In R4, given a subspace
Trang 42Question 40: In R3 with the dot product, given u=(1 ;1;2), v=(2 ;1 ;−1) Find
ⅆ(u , v ) and find a vector ω orthogonal to u, v
u=[1 1 2];
v=[2 1 -1];
d=norm(u-v)
w=cross(u,v)
Trang 43Question 41 & 42: In R3, given an inner product
Trang 44Question 45: Find the dimension, one basis of Imf:
Trang 45Question 50: Given A=(3 64 5), λ1−1, λ2=3 Which number is an eigenvalue of
1 −14 m) Find m such that A has an eigenvalue
λ=2 Find all eigenvalues and the associated A with m found
Trang 46Question 56: In R4, given U =¿(1,2,1,1); (2,1,0 ,−2)>¿ and
V =¿(1,5,3,5 ); (3,0,−1 , m)>¿ Find m such that U ≡V
Trang 48Question 59: In R4 , given 2 nullspaces
U :[ 1 1 2 0
−1 1 −1 2|00], V : [ 1 2 2 2
−1 0 −1 m|00].Find m such that dim(U ∩ V ) is max Find the dimension, a basis of U ∩ V
Trang 50Question 64: In R3 with the standard basis, given F = ¿(1 ; 1; 2) , (2; 1 ;−1)>¿ and
a vector x = (1; 2; 3) Find the projection of x onto F
F=[1 1 2;2 1 -1]';
x=[1 2 3]';
PrFx=F*inv(F'*F)*F'*x
Question 65: In R3, given an inner product ( x , y )=x1y1+2 x2y2+3 x3y3−x1y3−x3y1
Find the angle and the distance between u=(1 ;1;2) and v=(2 ;1 ;−1)
Question 66: In R3, given an inner product
( x , y )=x1y1+2 x2 y2+5 x3y3−2 x1 y3−2 x3y1 Find the orthogonal complement of
F=¿(1 ;2 ;3)>¿
Trang 51Question 70: Given a linear transformation f: R3→ R2, and the matrix of f in
E={(1 ;1;1) , (1;0 ;1) , (1;1 ;0) }, F={(1 ;1) ,(2 ;1) } is A E , F=(2 1 −30 3 4 ) Find the matrix of
f in the standard bases
Trang 52Question 72: Given a linear transformation f: R3→ R3 with the matrix in the basis E={(1 ;2;1) , (1;1 ;2) ,(1 ;1;1) } is A E=(1 0 12 1 4
1 1 3) Find the matrix of f in
Trang 53Question 75: Write a program to find: Input: matrix A Count the number
of even entries of A
% ask user to enter rows and columns
m=input( 'Enter the rows: ' );
n=input( 'Enter the columns: ' );
% ask user to enter the elements of the martix
fprintf( 'Total even entries are: %d' ,evenEntries)
Question 76: Write a program to find: Input: matrix A Find the
maximum elements in each row of A
% ask user to enter rows and columns
m=input( 'Enter the rows: ' );
n=input( 'Enter the columns: ' );
% ask user to enter the elements of the martix
% Find the maximum element in each row of A
disp( 'The maximum elements in each row are :' )
max(a,[],2)
Question 77: Write a program to find: Input: matrix A Find the
maximum positive entry in A.
% ask user to enter rows and columns
m=input( 'Enter the rows: ' );
n=input( 'Enter the columns: ' );
Trang 54% ask user to enter the elements of the martix
% check for all positive elements and find maximum
% consider 0 to be positive as well
% ask user to enter rows and columns
m=input( 'Enter the rows: ' );
n=input( 'Enter the columns: ' );
% ask user to enter the elements of the martix
% check for all odd elements
% and add them to a sum
Trang 55% print the required answer
fprintf( 'Sum of Odd Elements is %d' ,sumOfOddEntries)
Question 79: Write a program to find: Input: matrix A Find the product
of all odd entries in A.
% ask user to enter rows and columns
m=input( 'Enter the rows: ' );
n=input( 'Enter the columns: ' );
% ask user to enter the elements of the martix
% print the required answer
disp( ' The Product of all elements in a matrix is' );
disp(product);
Question 80: Write a program to find: Input: matrix A Check if A is
square and symmetric
% ask user to enter rows and columns
m=input( 'Enter the rows: ' );
n=input( 'Enter the columns: ' );
% ask user to enter the elements of the martix
Trang 56disp( 'Matrix A is neither square nor symmetric' );
% ask user to enter rows and columns
m=input( 'Enter the rows: ' )
n=input( 'Enter the columns: ' )
% ask user to enter the elements of the martix
fprintf( 'Orthogonal Matrix exists for only Square Matrix' )
% if matrix product of A and B forms identity matrix it is Orthogonal
elseif A*B==I
fprintf( 'The given matrix is Orthogonal' )
% in all other cases it is not Orthogonal
else
fprintf( 'The given matrix is Not Orthogonal' )
end
-The