Page 255 - MATLAB an introduction with applications
P. 255
240 ——— MATLAB: An Introduction with Applications
Check with MATLAB built-in function:
>> A = [11 2 8;2 2 –10;9 –10 5];
>> [Q,D] = eig(A)
Q =
0.3319 –0.6460 –0.6277
–0.6599 0.3380 –0.6966
–0.6741 –0.6845 0.3475
D =
–9.2213 0 0
0 18.4308 0
0 0 8.7905
43 2 1
34 1 2
Example E4.18: Transform the matrix A = into tridiagonal form using Householder reduction.
21 4 3
1 234
Also determine the transformation matrix.
Solution:
Suppose that A is a symmetric n × n matrix.
Start with A = A
0
Construct the sequence P , P , ..., P n–1 of Householder matrices, so that A = P A P for k = 1, 2, ..., n – 2,
1
2
k k–1 k
k
where A has zeros below the subdiagonal in columns 1, 2, …, k. Then A n–2 is a symmetric tridiagonal
k
matrix that is similar to A. This process is called Householder’s method.
%Input - A is an nxn symmetric matrix
A=[4 3 2 1;3 4 1 2;2 1 4 3;1 2 3 4];
%Output - T is a tridiagonal matrix
[n,n] = size(A);
for k = 1:n–2
s = norm(A(k+1:n,k));
if (A(k+1,k)<0)
s = –s;
end
r = sqrt(2*s*(A(k+1,k)+s));
W(1:k) = zeros(1,k);
W(k+1) = (A(k+1,k)+s)/r;
W(k+2:n) = A(k+2:n,k)’/r;
V(1:k) = zeros(1,k);
V(k+1:n) = A(k+1:n,k+1:n)*W(k+1:n)’;
c = W(k+1:n)*V(k+1:n)’;