Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Vignesh Kumar
- % RUID last 4 digits: 3719
- % Math 250 Lab Assignment #2
- % Section C2
- rand('seed', 3719)
- % Question 1 (a)
- A = rmat(3,5), rank(A(:,1:3))
- A =
- 5 4 2 0 9
- 5 8 3 6 6
- 1 6 2 9 9
- ans =
- 3
- b = rvect(3), R = rref([A b])
- b =
- 1
- 8
- 4
- R =
- Columns 1 through 4
- 1.0000 0 0 -2.0000
- 0 1.0000 0 0.5000
- 0 0 1.0000 4.0000
- Columns 5 through 6
- -5.0000 2.3333
- -10.0000 6.1667
- 37.0000 -17.6667
- S = R(:,1:5)
- S =
- Columns 1 through 4
- 1.0000 0 0 -2.0000
- 0 1.0000 0 0.5000
- 0 0 1.0000 4.0000
- Column 5
- -5.0000
- -10.0000
- 37.0000
- % Question 1 (a) (i) Columns 1, 2, and 3 are the pivot columns
- % Question 1 (a) (ii) The rank of both matrices are 3 since there are 3 pivots
- % Question 1 (a) (iii) Nullity is equal to 2 since it is # of columns - rank
- % Question 1 (a) (iv) Since there are no zero rows, Ax = b is consistent for all values
- % Question 1 (b)
- c = R(:,6)
- c =
- 2.3333
- 6.1667
- -17.6667
- x = [c; 0; 0]
- x =
- 2.3333
- 6.1667
- -17.6667
- 0
- 0
- A*x - b
- ans =
- 1.0e-14 *
- 0
- -0.3553
- 0
- S*x - c
- ans =
- 0
- 0
- 0
- % Question 1 (b) (ii) Since Ax = b, Ax - b would mean it equals a zero vector and there are no zero rows, we know it is consistent for all b
- % Question 1 (c)
- u = [-S(:,4); 1; 0], v = [-S(:,5);0;1]
- u =
- 2.0000
- -0.5000
- -4.0000
- 1.0000
- 0
- v =
- 5
- 10
- -37
- 0
- 1
- % Question 1 (i)
- % (i) Since u and v are scaled by -1 and therefore opposites. Therefore, the sum equals 0
- S*u
- ans =
- 0
- 0
- 0
- A*u
- ans =
- 0
- 0
- 0
- S*v
- ans =
- 0
- 0
- 0
- A*v
- ans =
- 0
- 0
- 0
- s = rand(1), t = rand(1), y = s*u + t*v
- s =
- 0.9588
- t =
- 0.5333
- y =
- 4.5843
- 4.8540
- -23.5689
- 0.9588
- 0.5333
- % Question 1 (c) (ii)
- % Ay = 0 since Az = A(x+y)=Ax+Ay, and Ax=Ax+Ay, therefore you can assume Ax+Ay=b
- % Question 1 (d)
- z = x + y
- z =
- 6.9176
- 11.0207
- -41.2356
- 0.9588
- 0.5333
- A*z-b
- ans =
- 1.0e-13 *
- 0.0400
- 0.1421
- 0.0799
- u1 = rvect(3), u2= rvect(3), u3 = rvect(3), u4 = rvect(3)
- u1 =
- 8
- 3
- 3
- u2 =
- 2
- 8
- 4
- u3 =
- 2
- 9
- 9
- u4 =
- 4
- 9
- 5
- % Question 2 (a)
- A = [u1 u2 u3], rref(A)
- A =
- 8 2 2
- 3 8 9
- 3 4 9
- ans =
- 1 0 0
- 0 1 0
- 0 0 1
- % Question 2(i)
- % Since there are no free variables and it is linearly independent (nullity=0)
- % Question 2 (b)
- B = [u1 u2 u3 u4], rref(B)
- B =
- 8 2 2 4
- 3 8 9 9
- 3 4 9 5
- ans =
- 1.0000 0 0 0.2424
- 0 1.0000 0 1.0000
- 0 0 1.0000 0.0303
- % Question 2 (bi)
- % There is one free variable, and it is therefore linearly dependent since nullity>0
- % Question 2 (c)
- % Since both u1,u2 have random scalar values and v is a linear combination of u1&u2, we can say the set is linearly independent
- v = rand(1)*u1 + rand(1)*u2
- v =
- 0.6205
- 1.8517
- 0.9584
- V = [u1, u2, v], rref(V)
- V =
- 8.0000 2.0000 0.6205
- 3.0000 8.0000 1.8517
- 3.0000 4.0000 0.9584
- ans =
- 1.0000 0 0.0217
- 0 1.0000 0.2233
- 0 0 0
- % Question 3 (a)
- A = rmat(2,3), B = rmat(3, 4), C = rmat(4,3), v = rvect(4)
- A =
- 2 8 4
- 5 3 8
- B =
- 3 2 1 6
- 4 3 7 5
- 6 7 5 0
- C =
- 4 5 2
- 9 1 8
- 8 3 9
- 8 6 1
- v =
- 5
- 1
- 6
- 8
- u = B*v, A*u, D = A*B, D*v
- u =
- 71
- 105
- 67
- ans =
- 1250
- 1206
- D =
- 62 56 78 52
- 75 75 66 45
- ans =
- 1250
- 1206
- % Question 3 (b)
- A = [0 1; 0 0], B = [0 0; 1 0], C = [0 1;1 0]
- A =
- 0 1
- 0 0
- B =
- 0 0
- 1 0
- C =
- 0 1
- 1 0
- A*B
- ans =
- 1 0
- 0 0
- B*A
- ans =
- 0 0
- 0 1
- % When you take the product matrix of AB and Ba, they aren't equal to each other
- (A + B)^2
- ans =
- 1 0
- 0 1
- (A^2)+(2*(A*B))+(B^2)
- ans =
- 2 0
- 0 0
- % A^2=0, since it is matrix multiplication, which follows the row*column form, if it were a number it would have been the square of a number
- % Question 3 (iii)
- A*C
- ans =
- 1 0
- 0 0
- A*B
- ans =
- 1 0
- 0 0
- % Since this is matrix multiplication, you can not infer that they are the same unless they are identity matrixes. If this was numbers, you would be able to assume that A, B, and C are the same
- % Although, they are clearly not the same in this case with matrixes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement