



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solutions to various vector and matrix operations as part of a university-level computer science course. Topics include vector length, angle between vectors, unit vectors perpendicular to given vectors, determinants, matrix inverses, and matrix-vector multiplication.
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!




(a) Let v = [ 5 3 7 ]. Compute ‖v‖, the vector length of v.
Solution:
‖v‖ =
(b) Let u = [ 2 3 1 ] and v = [ 5 3 7 ]. Compute the angle u makes with v. Express your answer in radians.
Solution:
cos θ =
u·v ‖u‖ ∗ ‖v‖
θ = cos−^1
= cos−^1 (0.7627) = 0. 703 radian
(c) Let u = [ 2 3 1 ] and v = [ 5 3 7 ]. Find a unit vector perpendicular to both u and v.
Solution:
u×v =
i j k 2 3 1 5 3 7
∣ i^ −
∣ j^ +
∣ k^ = [ 18^ −^9 −^ 9 ]
Unitize u×v, the result is
√^2 6 −^ √^1 6 −^ √^1 6
(d) Given a vector v = [x y], show that the vector u = [−y x] is orthogonal (i.e., perpendicular) to v.
Solution:
Two vectors u, v are perpendicular iff u·v = 0, and [x y]·[−y x] = x(−y) + yx = 0
M =
and vectors u =
, v =
x y z
(a) Compute the determinant det M.
Solution:
det M = 1 ·
(b) Compute the inverse M−^1.
Solution: We use elementary row operations to find the inverse of M.
So M−^1 =
(c) Compute matrix-matrix multiplication MN.
Solution:
(d) Compute matrix-vector multiplication Mv.
Solution:
Mv =
x y z
x + 2y + z 3 y + 4z − 4 y + 3z
(e) Compute the multiplication uvT^.
Solution:
and vectors v =
x x^2 x^3
g 1 g 2 g 3 g 4
, where^ g 1 =
,^ g 2 =
,^ g 3 =
,^ g 4 =
. Compute
vT^ MG.
Solution:
vT^ M = [ 1 x x^2 x^3 ]
= [ 1^ −^3 x^2 + 2x^3 3 x^2 −^2 x^3 x^ −^2 x^2 +^ x^3 −x^2 +^ x^3 ]
So vT^ MG = [ 1 − 3 x^2 + 2x^3 6 x^2 − 4 x^3 3 x − 6 x^2 + 3x^3 − 4 x^2 + 4x^3 ]
Solution:
Suppose the line equation is ax + by + c = 0, and we know that
a b
is perpendicular to the line. Since vector
p 1 − p 2 =
x 0 − x 1 y 0 − y 1
is along the line, we know from question 1(d) that
y 1 − y 0 x 0 − x 1
is a vector perpendicular
to the line. We can use it as
a b
, which means a = y 1 − y 0 and b = x 0 − x 1.
Next we plug in p 0 to the line equation to get c. From ax 0 +by 0 +c = 0 we have (y 1 −y 0 )x 0 +(x 0 −x 1 )y 0 +c = 0, so c = x 1 y 0 − x 0 y 1. This gives us the equation in the problem statement.
Solution:
We follow a similar approach to the previous question. First, we compute a normal vector for the plane. Recall that given two vectors in the plane, their cross product will be perpendicular to the plane. Thus a normal vector is:
n =
a b c
(^) = (p 2 − p 1 )×(p 3 − p 1 )
Given this normal and a point in the plane, we can solve for d:
n·p 1 + d = 0 d = −n·p 1
M(θ) =
cos θ − sin θ sin θ cos θ
(a) A square matrix M is said to be orthogonal if and only if its inverse exists and M−^1 = MT. Show that M(θ) is orthogonal.
Solution: To show that M−^1 = MT, we simply need to show that MMT^ = I: [ cos θ − sin θ sin θ cos θ
cos θ sin θ − sin θ cos θ
cos^2 θ + sin^2 θ cos θ sin θ − sin θ cos θ sin θ cos θ − cos θ sin θ sin^2 θ + cos^2 θ
(b) Show that M(θ 1 )M(θ 2 ) = M(θ 1 + θ 2 ).
Solution:
M(θ 1 )M(θ 2 ) =
cos θ 1 − sin θ 1 sin θ 1 cos θ 1
cos θ 2 − sin θ 2 sin θ 2 cos θ 2
cos θ 1 cos θ 2 − sin θ 1 sin θ 2 −(sin θ 1 cos θ 2 + cos θ 1 sin θ 2 ) sin θ 1 cos θ 2 + cos θ 1 sin θ 2 cos θ 1 cos θ 2 − sin θ 1 sin θ 2
cos(θ 1 + θ 2 ) − sin(θ 1 + θ 2 ) sin(θ 1 + θ 2 ) cos(θ 1 + θ 2 )
= M(θ 1 + θ 2 )
(c) Show that, for all possible values of θ, the inverse of M(θ) is M(−θ).
Solution: Using the result from part (b), we know that
M(θ)M(−θ) = M(θ + (−θ)) = M(0) =
cos 0 − sin 0 sin 0 cos 0
So we proved that M(θ) and M(−θ) are inverses of each other.