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

CHAPTER 5 MATLAB EXERCISES 311

8. Verify the result of Exercise 7 using the bases B 5 hs1, 0d, s0, 1dj and
22
51Ï5, Ï52,1Ï5, Ï526.
1 1 2
B9 5

CHAPTER 5 ❑ MATLAB EXERCISES

1. Use the MATLAB command norm(v) to find


(a) the length of the vector v 5 s0, 22, 1, 4, 22d .
(b) a unit vector in the direction of v 5 s23, 2, 4, 25, 0, 1d .
(c) the distance between the vectors u 5 s0, 2, 2, 23d and v 5 s24, 7, 10, 1d .
2. The dot product of the vectors (written as columns)

34 34
u1 v1
u2 v2
u5 . and v 5 .
. . . .
un vn

is given by the matrix product

34
v1
v2
u ? v 5 uTv 5 fu1 u2 ... u ng . .
..
vn

Hence you can compute the dot product of u and v simply by multiplying the transpose of u times
the vector v. Let u 5 s2, 25, 0, 4, 8d, v 5 s0, 23, 2, 21, 1d and w 5 s1, 21, 0, 0, 7d , and
use MATLAB to find the following.
(a) u?v
(b) su ? vdw
(c) u ? s2v 2 3wd
(d) v ? v and ivi2
3. The angle u between two nonzero vectors is given by

u?v
cos u 5 .
iu i ivi

Use MATLAB to find the angle between u 5 s23, 4, 0d and v 5 s1, 1, 4d. (Hint: use the
built-in inverse cosine function, acos).
4. You can find the orthogonal projection of the column vector x onto the vector y by computing
xTy
y.
yTy
Use MATLAB to find the following projections of x onto y.
312 CHAPTER 5 INNER PRODUCT SPACES

(a) x 5 s3, 1, 2d, y 5 s7, 1, 22d


(b) x 5 s1, 1, 1d, y 5 s21, 1, 1d
(c) x 5 s0, 1, 3, 23d, y 5 s4, 0, 0, 1d
5. Use the MATLAB command cross(u, v) to find the cross products of the following vectors.
(a) u 5 s1, 22, 1d, v 5 s3, 1, 22d
(b) u 5 s0, 1, 22d, v 5 s25, 14, 6d
6. Let u 5 s23, 2, 4d, v 5 s5, 0, 27d , and w 5 s21, 25, 6d. Use MATLAB to illustrate the fol-
lowing properties of the cross product.
(a) u 3 v 5 2sv 3 ud
(b) u3u50
(c) u 3 sv 1 wd 5 su 3 vd 1 su 3 wd
(d) u ? sv 3 wd 5 su 3 vd ? w
7. The MATLAB command A\ b finds the least squares solution to the linear system of equations
Ax 5 b. For example, if

3 4 34
0 2 1
A5 3 0 and b 5 1 ,
1 0 3
then the command A\ b gives the answer

30.50004.
0.6000

Use MATLAB to solve the least squares problem Ax 5 b for the given matrices.

3 4 34 3 4 34
1 2 1 1 2 0
0 1 1 0 1 2
(a) A 5 b5 (b) A 5 b5
1 3 1 1 3 1
1 4 1 1 4 1

1 2 1 21
3 4 3 2
(c) A 5 0 0 1 b 5 21
1 1 0 0
1 2 21 1

8. Use MATLAB to find the four fundamental subspaces of the following matrices.

3 4 3 4
0 1 0 1 2
1 0 1 3 21
(a) (b)
0 0 0 1 4
1 2 1 0 1
CHAPTER 5 CUMULATIVE TEST FOR CHAPTERS 4 AND 5 313

0 1 1 0

3 4
2 1 1 0
0 1 1 1
0 1 1 21
(c) (d) 3 22 21 0
0 2 0 0
4 1 21 0
1 1 1 1
5 4 3 2

CUMULATIVE TEST FOR CHAPTERS 4 AND 5


Take this test as you would take a test in class. After you are done, check your work against
the answers in the back of the book.
1. Given the vectors v 5 s21, 2d and w 5 s3, 21d, sketch the following vectors.
(a) v 1 w (b) 3v (c) 2v 2 4w
2. If possible, write w 5 s3, 2, 1d as a linear combination of the vectors
v1 5 s1, 2, 0d, v2 5 s21, 0, 1d, v3 5 s0, 3, 0d
3. Prove that the set of all singular 2 3 2 matrices is not a vector space.

4. Determine whether the set hsx, x 1 y, y,2yd : x, y [ Rj is a subspace of R4.

5. Determine whether the set hsx, xy, yd : x, y [ Rj is a subspace of R3.

6. Determine whether the columns of the following matrix span R4.


2 21

3 4
1 0
1 3 0 2
A5
0 0 1 21
1 0 0 1
7. (a) Define what it means to say a set of vectors is linearly independent.
(b) Determine whether the following set is linearly dependent or independent.
S 5 hs1, 0, 1, 0d, s0, 3, 0, 1d, s1, 1, 2, 2d, s3, 24, 2, 23dj
8. Find the dimension and a basis for the subspace of M3,3 consisting of all the
3 3 3 symmetric matrices.
9. (a) Define basis of a vector space.
(b) Determine if the following set is a basis for R3.
hs1, 2, 1d, s0, 1, 2d,s2, 1, 23dj
21
3 4
0 2
10. Let A 5 .
1 1 0
(a) Find the rank of A.
(b) Find a basis for the row space of A.
(c) Find a basis for the column space of A.

You might also like