Question

Please Urgent help me!!!(QR decomposition queastion)

You have not to solve all parts of question!!!

The QR decomposition can be used to solve a linear system. Let A be an n x n matrix, with A system Axb can be written as QR.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

save below code as qrsolve.m

function qrsolve(A,B)
[a,b]=size(A);
R=A; %Start with R=A
Q=eye(a); %Set Q as the identity matrix
for k=1:a-1
X=zeros(a,1);
X(k:a,1)=R(k:a,k);
F=norm(X);
v=X; v(k)=X(k)+F;

s=norm(v);
if s~=0, w=v/s; u=2*R'*w;
R=R-w*u';
Q=Q-2*Q*w*w';
end
end


Xsolved = inv(R)*(Q'*B)
residual=abs(A*Xsolved-B)
end

OUTPUT---------------------TEST-------------CODE-------------------------------------------------------

>>qrsolve([1 -1 0;2 4 5;-7 1 3], [1; -1;8])
Xsolved =

  -0.75000
  -1.75000
   1.50000

residual =

   8.8818e-16
   1.7764e-15
   0.0000e+00


 
>> qrsolve([21 3 -4 8;1 3 59 0;1 2 -22 35;3 78 100 3],  [1; -1; 1; 2])
Xsolved =

   0.032058
   0.049597
  -0.020014
   0.012241

residual =

   4.4409e-16
   4.4409e-16
   2.2204e-16
   4.4409e-16
Add a comment
Know the answer?
Add Answer to:
Please Urgent help me!!!(QR decomposition queastion) You have not to solve all parts of question!!! The QR decompositio...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT