0% found this document useful (0 votes)
42 views7 pages

MATH 18 MATLAB HW5

The document discusses the calculation of orthogonal vectors in R3 and Rn, demonstrating the maximum number of orthogonal vectors possible. It includes various computations involving vector norms, dot products, and orthogonal projections, with outputs showing the results of these calculations. Additionally, it covers the use of QR decomposition and eigenvalues in relation to orthogonal bases and linear dependencies.

Uploaded by

bjonathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views7 pages

MATH 18 MATLAB HW5

The document discusses the calculation of orthogonal vectors in R3 and Rn, demonstrating the maximum number of orthogonal vectors possible. It includes various computations involving vector norms, dot products, and orthogonal projections, with outputs showing the results of these calculations. Additionally, it covers the use of QR decomposition and eigenvalues in relation to orthogonal bases and linear dependencies.

Uploaded by

bjonathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

5.

1
a) Two-vector subsets (Calculated manually with dot() function) → {w,x}, {x,y},{x,z},{y,z}
Three vector subsets: {x,y,z} because {x,y},{x,z} and {y,z} are all orthogonal to each other
The greatest number of number of orthogonal vectors you could fnid in R3 would be 3. If
you had anymore vectors, it would make a linearly dependent set and thus not mutually
orthogonal. Similarly, a set in Rn would have a maximum of n vectors.
b) v = [2;0;1]
w = [1;3;3]
x = [6;1;-3]
y = [1;0;2]
z = [2;-15;-1]
normx = x/norm(x)
normy = y/norm(y)
normz = z/norm(z)
W = [normx normy normz]

Output:
W=
0.8847 0.4472 0.1319
0.1474 0 -0.9891
-0.4423 0.8944 -0.0659

5.2
a) Input:
changedW = W'*W
Output:
changedW =
1.0000 0 0
0 1.0000 0
0 0 1.0000
b) W = [normx normy normz]
a = [1;1;0]
b = [2;0;3]
normb = norm(b)
normWb = norm(W*b)
dotab = dot(a,b)
dotWaWb = dot(W*a,W*b)
Output:
normb =
3.6056
normWb =
3.6056
dotab =
2
dotWaWb =
2

Normb and normWb are the exact same, this makes sense because W is orthogonal.

c) Input:
W = [normx normy normz]
Wt = W'
invW = inv(W)
Output
Wt =
0.8847 0.1474 -0.4423
0.4472 0 0.8944
0.1319 -0.9891 -0.0659
invW =
0.8847 0.1474 -0.4423
0.4472 0 0.8944
0.1319 -0.9891 -0.0659

inv(W) and WT are the exact same


5.3
a) Input
vbar = (dot(v,w)/dot(w,w))*w
z = v - vbar
v = vbar + z
Output
vbar =
0.2632
0.7895
0.7895
z=
1.7368
-0.7895
0.2105
v=
2
0
1
b) Input:
dotvbarz = dot(vbar,z)
Output
dotvbarz =
-1.1102e-16 (which is just a rounding error and should be 0)
Since output is 0, vbar is orthogonal to Z

5.4
Input:
basis2 = y - (dot(x,y)/dot(x,x))*x
Output
basis2 =
1
0
2
Orthogonal basis for x & y, {[6;1;-3], [1;0;2]}

Input:
vec3 = [3;3;3]
vec3bar = (dot(vec3,x)/dot(x,x))*x +
(dot(vec3,basis2)/dot(basis2,basis2)*basis2)
Output
vec3bar =
3.3652
0.2609
2.8174
5.5
a) Input
orthobasis = [1 2 1;2 1 2;1 1 2]
[Q,R] = qr(orthobasis)

Output
Q=
-0.4082 0.8616 -0.3015
-0.8165 -0.4924 -0.3015
-0.4082 0.1231 0.9045
R=
-2.4495 -2.0412 -2.8577
0 1.3540 0.1231
0 0 0.9045
b) Input
v = eig(Q)
normv2 = norm(v(2))
normv3 = norm(v(3))
Output
v=
-0.4980 + 0.8672i
-0.4980 - 0.8672i
1.0000 + 0.0000i
normv2 =
1.0000
normv3 =
1
Norm for v(2) and v(3) is the same

5.6
a) Input
B = [1 75;1 100;1 128;1 129;1 195]
d = [15;23;26;34;38]
[Q, R] = qr(B,0)
x = Q(:, 1)
y = Q(:, 2)
v = dot(x,d)*x + dot(y,d)*y
Output
B=

1 75
1 100
1 128
1 129
1 195
d=
15
23
26
34
38
Q=
-0.4472 -0.5618
-0.4472 -0.2831
-0.4472 0.0290
-0.4472 0.0401
-0.4472 0.7758
R=
-2.2361 -280.4029
0 89.7173
x=
-0.4472
-0.4472
-0.4472
-0.4472
-0.4472
y=
-0.5618
-0.2831
0.0290
0.0401
0.7758
v=
17.8416
22.4837
27.6828
27.8685
40.1235
b) Input
c = B\v
verify = B*c - v
Output
c=
3.9153
0.1857
verify =
1.0e-13 *

-0.1066
-0.1421
-0.1066
-0.0711
0

c) Output
cl =
3.9153
0.1857

It’s exactly the same as the answer from the previous part

5.7
a) y = c(1)x + c(2)
b) Input
Y1 = c(2)*35 + c(1)
Y2 = c(2)*170 + c(1)
Y3 = c(2)*290 + c(1)
Output
Y1 =
10.4143
Y2 =
35.4815
Y3 =
57.7634

c)
After manually hovering over the graph at x = 35, 170 and 290, it can be observed that
the answers in part (b) are almost identical to (c), only differing by a negligible amount.

You might also like