Download Solution Assignment 7

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
www.vutube.edu.pk
SSoolluuttiioonn A
Assssiiggnnm
meenntt 77
Question # 1
a) show that the set S= { u1 , u 2 , u 3 } is an orthogonal basis for R 3
5 
 
and express the vector x= 3 as a linear combination of the vectors in S
 
1 
3 
2 
1 




 
Where u1 = 3 , u 2 = 2
 
  , u 3 = 1 
 0 
 1
 4 
Solution:
First Consider the three possible pairs of distinct vectors, namely {u 1, u2}, {u1, u3} and {u2, u3}.
u1 u2   3 2    3 2    0  1  6  6  0  0
u1 u3   31   31   0  4   3  3  0  0
u2 u3   2 1   2 1   1 4   2  2  4  0
Each pair of distinct vectors are orthogonal, and so S= {u 1, u2, u3} is an orthogonal set.
Now by using this theorem which states that “If S = {u 1, u2, u3,…up} is an orthogonal set of non zero vectors
in Rn, then S is linearly independent and hence is a basis for the subspace spanned by S”.
So S = {u1, u2, u3} is an orthogonal basis for R3.
Now the next step is to express x as a linear combination of u’s.
Compute
 5  3 
x u1   3  3   5  3   3 3  1 0   15  9  0  24
 1   0 
 5  2 
x u2   3  2    5  2    3 2   1 1  10  6  1  3
 1   1
 5  1 
x u3   3 1    5 1   31  1 4   5  3  4  6
 1   4 
 3  3 
u1 u1   3  3   3 3   3 3   0  0   9  9  0  18
 0   0 
 2  2 
u2 u2   2   2    2  2    2  2    1 1  4  4  1  9
 1  1
1  1 
u3 u3  1  1   11  11   4  4   1  1  16  18
 4   4
Now by using theorem which states that, “Let {u1, u2, u3,…up} be an orthogonal basis for a subspace W of
Rn. for each x in W, the weight of the linear combination.
x  c1u1  c2u2  c3u3 ..........  c pu p
Are given by
cj 
x.u j
u j .u j
( j  1, 2,3......., p)
Now according to the given condition
x  c1u1  c2u2  c3u3
Where,
c1 
x.u3
x.u1
x.u2
, c2 
, c3 
u1.u1
u2 .u2
u3 .u3
x
x.u3
x.u1
x.u2
u1 
u2 
u3
u1.u1
u2 .u2
u3 .u3
Now,
24
3
6
u1  u2  u3
18
9
18
4
1
1
x  u1  u2  u3
3
3
3
x
b).
2
4 
and u=   Find the orthogonal projection of y onto u. Then write y as the sum of

3 
 7 
Let y= 
two orthogonal vectors, one in Span{u} and one Orthogonal to u.
Solution:
Compute
2  4 
y  u        13
 3   7 
4 4
u  u        65
 7    7 
The orthogonal projection of y onto u is
yˆ 
yu
13
1  4   4 / 5
u
u  
uu
65
5  7   7 / 5 
And the component of y orthogonal to u is
 2  4 / 5 14 / 5
y  yˆ     


 3  7 / 5   8 / 5 
The sum of these two vectors is y. That is,
 2  4 / 5 14 / 5
 3   7 / 5    8 / 5 
  
 

y
yˆ
( y  yˆ )
Note: If the calculations above are correct, then
 yˆ ( y  yˆ ) will be an orthogonal set. As a check, we
will compute.
 4 / 5 14 / 5 56 56
yˆ ( y  yˆ )  

0


 7 / 5   8 / 5  25 25
Question # 2
a) Find the distance from y to w=Span { v1 , v 2
3 
1 
} where y=  
5 
 
1 
3 
1 
=
v1  1 ,
 
1 
1 
 1
=
v 2 1 
 
 1
Solution:
y
y.v1
y.v2
v1 
v2
v1.v1
v2 .v2
3  3 
1  1 
y v1        3 3  11   5  1  11  9  1  5  1  6
5  1
  
1  1 
3  3 
1  1 
v1 v1        3 3  11   1 1  11  9  1  1  1  12,
 1  1
  
1  1 
3 1 
1   1
y v2        31  1 1   5 1  1 1  3  1  5  1  6,
5 1 
  
1   1
1  1 
 1  1
v2 v2       11   1 1  11   1 1  4
1  1 
  
 1  1
 3
 1
 3
 1
 1
 1
 1
 
6   6   1   3  1
y



12  1 4  1  2  1 2  1 
 
 
 
 
 1
 1
 1
 1
 3   3 
 2   2 
 1   3   3
 2    2   1 


 
1
3

 
  1
2
2

 
  1 
 1   3 
 2  
2 
 3
 1 
y 
 1
 
 1 
3  3   0 
1  1   2 
y-y       
5  1  4 
     
1  1   0 
^
Now
^ 2

y - y  0  4  16  0  20

y-
^
The distance from y to W is
y
2 5
2 5
b) Find the least square error in the least square solution of Ax=b
1

Where A= 1

1
3
 1 , b=
1 
5 
1 
 
 0 
Solution:
To use (3), compute:
1 3
1 1 1  
  1  1  1 3  1  1  3 3 
A A
1

1

 3  1  1 9  1  1 3 11
3 1 1 
 

 
1
1

5 
1 1 1     5  1  0   6 
T
A b
 1   
 
3 1 1   15  1  0  14
0 
T
Then the equation A A  A b becomes
T
T
3 3   x1   6 
3 11  x   14

 2  
Row operation can be used to solve this system, but since
faster to compute.
 A A
T
1
AT A is invertible and 2  2 , it is probably
1  11 3
24  3 3 

And then to solve A Ax  A b as
T
T
xˆ   AT A  AT b
1
1  11 3  6  1  66  42 

24  3 3  14  24  18  42 
1  24  1


24  24  1
1
xˆ   
1

Now we have,
3
1  3  4
1


 1    1  1  0 
1 
1 
1  1  2
1
Axˆ  1
1
Hence,
5  4 5  4   1 
b  Axˆ  1   0   1  0    1 
0  2 0  2  2
And
b  Axˆ 
1  1   2 
2
2
2
 11 4
 6
The least square error is
Question # 3
6 . For any x in R2 , the distance between b and the vector Ax is at least
6.
Find an orthogonal basis for the subspace W of
 1
3
A= 
1

1
6 
3 
6 

 3
6
8
2
4
R
4
for the matrix
Also make a QR-factorization of the above matrix A and check that
A=QR
Solution:
A   x1
Let ,
 1
3
x1    ,
1
 
1
x2
x3 
6
 8
x2    ,
 2 
 
 4 
6
3
x3   
6
 
 3
Then [ x1, x2, x3 ] is clearly linearly independent and thus is a basis for a subspace W of R 4. Now we can
construct an orthogonal basis for W.
Step 1:
Let v1 = x1 and W1 = Span {x1} = Span {v1}.
Step 2:
Let v2 be the vector produced by subtracting from x 2 its projection onto the subspace W1. That is,
let
v2  x2  projw1 x2
 x2 
x2 v1
v1
v1 v1
Since v1  x1
 6   1
 8  3 
x2 v1        6  1   8  3   2 1   4 1  6  24  2  4  36
 2   1 
  
 4   1 
 1  1
 3  3 
v1 v1        1 1   3 3  11  11  1  9  1  1  12
 1  1 
  
 1  1 
6
 1  6 
 1
 8 
 3   8
3
 36     
 
v2     


3
 2   12   1   2 
1
 
   
 
 4 
 1   4 
1
 6   3   3 
 8   9   1 
    
 2   3   1 
     
 4   3   1
3
1
v2   
1
 
 1
v2 is the component of x2 orthogonal to x1, and {v1, v2} is an orthogonal basis for the subspace W2 spanned
by x1 and x2.
Step 3:
Let v3 be the vector produced by subtracting from x 3 its projection onto the subspace W2. Use the
orthogonal basis {v1, v2} to compute the projection onto W2:
projW2 x3 
x3  v1
x v
v1  3 2 v2
v1  v1
v2  v2
 6   1
 3  3 
x3 v1        6  1   3 3   6 1   31  6  9  6  3  6
 6  1 
  
 3  1 
 1  1
 3  3 
v1 v1        1 1   3 3  11  11  1  9  1  1  12
 1  1 
  
 1  1 
 6  3 
 3  1 
x3 v2        6  3   31   6 1   3 1  18  3  6  3  30
 6  1 
  
 3  1
 3  3 
 1  1 
v2 v2        3 3  11  11   1 1  9  1  1  1  12
 1  1 
  
 1  1
 1
3
3
 
6
30 1
    
12  1  12  1 
 
 
1
 1
  1 15  
   
1  3   5 


2 1   5 
     
  1   5 

 1
3
3
 
1  51

21  21 
 
 
1
 1

14   7 
   
18   4 

2 6   3 
   
 4   2 
v3  x3  projW2 x3
 6   7   1
 3   4   1
v3         
6 3 3
     
 3  2   1
Scale v3 to simplify the later computations
1
1
v3   1 v3   
 3 
 
1
The columns A are the vectors x1, x2, x3 . an orthogonal basis for colA = Span [x1, x2, x3 ] has been found.
 1
3
v1    ,
1
 
1
3
1
v2    ,
1
 
 1
1
1
v3   
 3
 
1
Normalize the three vectors to obtain u1, u2, u3.
 1

 1 
3
 
1
1 3  
u1 
v1 

v1
12 1   1
  
1  
1


12 

12 


12 

12 
3

3  
1
 
1
1 1  
u2 
v2 

v2
12 1   1
  
 1 
1

1

1  
1
 
1
1 1  
u3 
v3 

v3
12  3  3
  
1  
1


12 

12 


12 

12 

12 

12 


12 

12 
QR Factorization:
 1

 3

Q
 1

1


12 

1
1
12
12 

3
1

12
12 

1
1
12
12 
3
12
12
12
12
1
12
By construction, the first k columns of Q are orthonormal basis of span [x1, x2, x3 ] . From theorem of QR
factorization which states;
“ If A is an m n matrix with linearly independent columns, then A can be factored as
A = QR, where Q is an m n matrix whose columns form an orthonormal basis for
colA and R is an n  n upper triangular invertible matrix with positive entries on its
diagonal.”
To find R, observe that QTQ = I,
QT A  QT  QR   IR  R
 1

12

QT   3
12

 1
12

3
1
12
1
12
1
12
12
3
1
12

12 

1

12 

1
12 
1
12
 1

12

R 3
12

 1

12

 1 6 6 
12
12
12  
 3 8 3 
1
1
1


12
12
12   1 2 6 
  1 4 3
3
1
1


12
12
12 
 1 6 6 
 1 3 1 1  
3 8 3 
1 


R
3 1 1 1
 1 2 6 
12 
 1 1 3 1  

 1 4 3
 1  9  1  1 6  24  2  4 6  9  6  3
1 

3  3  1  1
18  8  2  4 18  3  6  3 

12
 1  3  3  1
6  8  6  4 6  3  18  3 
 12 3 12
3 
12 36 6 


1 
 

0
12
30
0
12
5
3



12 


 0
0 12 
0
 12 
 0
3
1
1
 2 3 6 3
3 


R  0
2 3
5 3


0
2 3 
 0
 2 6 1 
R  3  0 2 5 
 0 0 2 
A  QR
 1 3 1 

  2 6 1 
3  3 1 1 

0 2 5 

12  1 1 3

  0 0 2 
 1 1 1 
 1 3 1 

  2 6 1 
1  3 1 1 

0 2 5 



2 1 1 3

  0 0 2 
 1 1 1 
 2  0  0 6  6  0 1  15  2 


1  6  0  0 18  2  0 3  5  2 

1 5  6 
2  2  0  0 6  2  0


1 5  2 
 2  0  0 6  2  0
 2 12 12 


1 6 16 6 
 
2  2 4 12 


 2 8 6 
 1 6 6 
 3 8 3 

 
 1 2 6 


 1 4 3
Hence it is verified that A = QR.
Related documents