summaryrefslogtreecommitdiff
path: root/191/CH4/EX4.9/Example4_9.sce
blob: 0587884490571378ffc0fd8591c82efe08e49190 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Given's Method
//reduce A1 to tridiagonal form
clc;
clear;
close();
format('v',7);
A1 = [2 -1 1 4;-1 3 1 2;1 1 5 -3;4 2 -3 6];
disp(A1,'A = ')
// zero is created at (1,3)
//by taking the rotation matrix X1=[c 0 s; 0 1 0;-s 0 c]; where c=cos and s=sin
//O is theta

count =0;
for i=1:(4-2)
    for j=i+2:4
        if abs(A1(i,j))>0 then
            p=i+1;q=j;
            O = -atan(A1(p-1,q)/(A1(p-1,p)));
            c = cos(O);
            s = sin(O);
            X = eye(4,4);
            X(p,p)=c;
            X(q,q)=c;
            X(p,q)=s;
            X(q,p)=-s;
            
            A1 = X'*A1*X;  
            disp(A1, 'Ai = ');
            disp(X ,'X = ');
            disp(O, 'Theta = ');
            count = count+1;
        end
    end
end
disp(A1,'Reduced A1 to trigonal matrix is : ')