现在时间是:
当前位置:首 页 >> 数值分析(英)>> 教学区>> 文章列表

17074231-作业8

作者:金慧   发布时间:2019-06-09 16:36:42   浏览次数:81

4.3

1. Apply classical Gram–Schmidt orthogonalization to find the full QR factorization of the following matrices:

b:[-4,-4;-2,7;4,-5]

Solution:

 

Y1=A1=[-4;-2;4];

R11=||y1||2=6;

q1=y1/||y1||2=[-2/3;-1/3;2/3];

Y2=A2-q1*q1*A2=[-6;6;3];

R22=||y2||2=9;

q2=y2/||y2||2=[2/3;2/3;-1/3];

R12=q1*A2=-3;

So

Q=[-2/3,-2/3;-1/3,2/3;2/3,-1/3];

R=[6,-3;0,9];

 

4.Apply modified Gram–Schmidt orthogonalization to find the full QR factorization of the matrices in Exercise 2.

Solution:

Y1=A1=[-4;-2;4];

 r11=||y1||2=6 ;

q1=y1/||y1||2=[-2/3;-1/3;2/3];

y=A2,

r12=q1'*y=[-2/3 -1/3 2/3]*[-4;7;-5]=-3

y=y-r12*q1=[-4;7;-5]-(-3)*[-2/3;-1/3;2/3]=[-4 2;7 -1;-5 -2]=[-6;6;-3]

r22=||y2||2=9

q2=y/r22=[-6;6;-3]/9=[-2/3;2/3;-1/3]

Adding a third vector A3=[1;0;0]

(y3)1=A3-q1*(q1)’*A3=[5/9;-2/9;4/9]

y 3=(y3)1-q2*(q2)’*(A3)1=[1/9;2/9;/2/9]

q3=y3/||y3||2=[1/3;2/3;2/3]

so,Q=[-2/3 -2/3 1/3;-1/3 2/3 2/3;2/3 ;-1/3 2/3]

R=[6 -3;0 9;0 0]

 

 

6. Apply Householder reflectors to find the full QR factorization of the matrices in Exercise 2.

b:[-4,-4;-2,7;4,-5]

Solution:

x1=[-4;-2;4];

w1=[6;0;0];

v1=x-w=[-10;-2;4];

h1=E-2v*v/v*v=[-2/3,-1/3,2/3;-1/3,14/15,2/15;2/3,2/15,11/15];

h1*A=[6,-25/3;0,68/15;0,-1/15];

x2=[68/15;-1/15];

w2=[(4625/225)^0.5;0];

v2=x2-w2=[0.005;-0.067];

E-2v2*v2/v2*v2=[1,0;0,-1];

So:h2=[1,0,0;0,1,0;0,0,-1];

Code>>

> h1=[-2/3,-1/3,2/3;-1/3,14/15,2/15;2/3,2/15,11/15];

>> h2=[1,0,0;0,1,0;0,0,-1];

>> a=[-4,-4;-2,7;4,-5];

>> h1*h2*a

 

 

>> r=h2*h1*a

 

ans =

 

    6.0000   -3.0000

   -0.0000    7.2000

         0    5.4000

 

>>q= h1*h2

 

ans =

 

   -0.6667   -0.3333   -0.6667

   -0.3333    0.9333   -0.1333

0.6667    0.1333   -0.7333

Computers

1. Write a Matlab program that implements classical Gram–Schmidt to find the reduced QR factorization. Check your work by comparing factorizations of the matrices in Exercise 1 with the Matlab qr(A,0) command or equivalent. The factorization is unique up to signs of the entries of Q and R.

Code>>

function[q,r]=QR(A)

[n,m]=size(A);

for j=1:m

    y=A(1:n,j);

    for i=1:(j-1)

        r(i,j)=(q(1:n,i))'*A(1:n,j);

        y=y-r(i,j)*q(1:n,i);

    end

    r(j,j)=norm(y);

    q(1:n,j)=y/r(j,j);

    A(1:n,j)

end

 

A=[4,0;3,1];

>> [q,r]=QR(A)

 

ans =

 

     4

     3

 

 

ans =

 

     0

     1

 

 

q =

 

    0.8000   -0.6000

    0.6000    0.8000

 

 

r =

 

    5.0000    0.6000

         0    0.8000

 







上一篇:没有了    下一篇:没有了

Copyright ©2020    计算数学达人 All Right Reserved.

技术支持:自助建站 | 领地网站建设 |短信接口 |燕窝 版权所有 © 2005-2020 lingw.net.粤ICP备16125321号 -5