%% Title for the document: Homework Section 6.5 % Comments for the section %% Exercise 24, p. 409 % We can use Latex in the comments (if you have had the calc lab) % % $$\mathbf{v}_2=\mathbf{a}_2-\frac{\mathbf{a}_2\cdot\mathbf{v}}{\|{\mathbf v}\|^2}{\mathbf{v}}$$ % clear; %It's a good idea to make each piece self-contained A=[-10 13 7 -11; 2 1 -5 3; -6 3 13 -3; 16 -16 -2 5; 2 1 -5 -7]; % For the solution, fill in the columns of a matrix V. I'll get you % started: V(:,1)=A(:,1); V(:,1)=V(:,1)/sqrt(V(:,1)'*V(:,1)); V(:,2)=A(:,2)-(A(:,2)'*V(:,1))*V(:,1); %This last line will tell Matlab to print V to the screen V %% Exercise 25, p. 409: Use your previous code to create QR clear A=[-10 13 7 -11; 2 1 -5 3; -6 3 13 -3; 16 -16 -2 5; 2 1 -5 -7]; %% Exercise 26 The problem uses a "for loop" below. clear A=[-10 13 7 -11; 2 1 -5 3; -6 3 13 -3; 16 -16 -2 5; 2 1 -5 -7]; % See if you can figure out what each line does. [nr,nc]=size(A); q=A(:,1)/norm(A(:,1)); Q=q; for j=2:nc x=A(:,j); v=x-Q*Q'*x; v=v/norm(v); Q=[Q v]; end R=Q'*A; clear ans j nc nr q v x Q R