Numerical Analysis/Householder transformation exercises

From testwiki
Revision as of 11:12, 17 December 2022 by imported>MathXplore (Removing from Category:Numerical analysis using Cat-a-lot)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Householder's method Exercises

Exercise 1

This exercise will help you in introducing how to perform the Householder's method to transform a symmetric matrix A into the tridiagonal form. All of the notations and computations in this Exercise follow from those in Section 9.3, Numerical Analysis, Burden and Faires, 8th Edition. It's recommended that you read that section before solving the problem. It's also recommended that you read the following useful links
1. Householder's method for symmetric matrices, J. H. Wilkinson, Handbook Series Linear Algebra, Volume 4, Number 1 / December, 1962, Springer Berlin / Heidelberg.
2. Module for Householder Transformations, Mathematics Department, California State University, Fullerton.


Problem
Let

A=[5142132342432332].

Perform Householder's method to bring A into a tridiagonal form.

Solution

Step 1: k = 1 (Meaning: Making 0's for the third and fourth rows of the first column) <quiz display=simple> { |type="{}"} α=sgn(ak+1,k)j=k+1najk2 is { 4.5825 _10 }.

{ |type="{}"} r=12(α2ak+1,kα) is { 3.5765 5% _10 }.

{ |type="{}"} Now, we are going to find the vector w(1)=[w1(1)w2(1)w3(1)w4(1)] Set w1(1)=0, we need to find w2(1),w3(1),w4(1) w2(1)=a2,1α2r= { -0.7805 5% _10}. wj(1)=aj,12r for j = 3 and 4 gives w3(1)=a3,12r= { -0.5592 5% _10} w4(1)=a4,12r= { 0.2796 5% _10}

{ |type="{}"} The orthogonal matrix P1, defined as P1=I2w(1)(w(1))t is (click Submit to see the answer) || P1=[100000.21820.87290.436400.87290.37460.312700.43640.31270.8436].

{ |type="{}"} The new matrix A(1), defined as A(1)=P1AP1, should be in the form A(1)=[**00*****0***0***] ||A(1)=[54.5826004.58266.04760.12220.279300.12220.60593.406800.27933.40683.5582] This is the end of Step 1. </quiz>



Step 2: k = 2 (Meaning: Making 0's for the fourth row of the second column)
In Step 2, we redo the computations in Step 1 with the matrix A=A(1) <quiz display=simple> { |type="{}"} α=sgn(ak+1,k)j=k+1najk2 is { 0.3050 _10 }.

{ |type="{}"} r=12(α2ak+1,kα) is { 0.2552 5% _10 }.

{ |type="{}"} Now, find the vector w(2)=[w1(2)w2(2)w3(2)w4(2)] Set w1(2)=w2(2)=0, we need to find w3(2),w4(2) w3(2)=a2,1α2r= { -0.8369 5% _10}. w4(2)=a4,12r= { 0.5473 5% _10}

{ |type="{}"} The orthogonal matrix P2, defined as P2=I2w(2)(w(2))t is (click Submit to see the answer) || P2=[10000100000.40090.9161000.91610.4009].

{ |type="{}"} The new matrix A(2), defined as A(2)=P2A(1)P2, should be in the form A(2)=[**00****00***00**] ||A(2)=[54.5826004.58266.04760.3049000.30495.39140.7824000.78242.4390] This is the end of Step 2. </quiz> Now the matrix A(2) is in a tridiagonal form. The Householder's method is complete.

Exercise 2

<quiz display=simple> {Householder's method is for |type="()"} - Any matrix. - A non-symmetric positive define matrix. + A symmetric matrix. - A non-symmetric diagonally dominant matrix.

{The goal of Householder's method is for |type="()"} - Finding the determinant of a matrix. + Transforming a matrix to tridiagonal form. - Finding eigenvalues of a matrix. - Finding the LU decomposition of a matrix.

{How many steps do we need to perform in Householder's method |type="()"} - n steps (where n is the size of the matrix). - 2n steps. - n2 steps. + n-2 steps.

{What should be performed after Householder's method |type="()"} - LU decomposition. - Support Vector Decomposition (SVD). - Power method. + QR decomposition.


{Will the Householder's method ever fail |type="()"} - Yes + No. </quiz>

Exercise 3

Problem
Based on the computations performed in Exercise 1, write code in Matlab to perform the Householder's method for an input symmetric matrix A.


Solution <quiz display=simple>

||

% Get the size of the matrix A
[n m] = size(A);
% Define the Identity matrix of size of A
I = diag(ones(1,n));
% Householder's method with details
for k = 1 : (n-2)
    % Define the vector w. Initially, w is a zero vector
    w = zeros(n,1);
    % Compute \alpha^2
    alpha_square = sum(A(k+1:n,k)'*A(k+1:n,k))
    % Get \alpha with the appropriate sign
    ap = -sign(A(k+1,k))*sqrt(alpha_square)
    % Find r
    r = sqrt((alpha_square-A(k+1,k)*ap)/2)
    r2 = 2*r;
    % Find w(k+1)
    w(k+1) = (A(k+1,k)-ap)/r2;
    % Find w(j) for j from k+2 to n
    for j = (k+2) : n
        w(j) = A(j,k)/r2;
    end;
    w
    % From the orthogonal matrix P
    P = I - 2*w*w'
    % Update the matrix A
    A = P*A*P
end;

}

</quiz>
132.235.39.18 19:02, 28 May 2009 (UTC) Nam Nguyen