summaryrefslogtreecommitdiff
path: root/191/CH4/EX4.13
diff options
context:
space:
mode:
Diffstat (limited to '191/CH4/EX4.13')
-rwxr-xr-x191/CH4/EX4.13/Example4_13.sce31
-rwxr-xr-x191/CH4/EX4.13/Result4_13.txt47
2 files changed, 78 insertions, 0 deletions
diff --git a/191/CH4/EX4.13/Example4_13.sce b/191/CH4/EX4.13/Example4_13.sce
new file mode 100755
index 000000000..13af20e4e
--- /dev/null
+++ b/191/CH4/EX4.13/Example4_13.sce
@@ -0,0 +1,31 @@
+//Orthogonal decomposition - QR method
+//reduce A to tridiagonal form
+clc;
+clear;
+close();
+format('v',7);
+A1 = [1 4 2;-1 2 0;1 3 -1];
+disp(A1, 'A = ');
+// zero is created in lower triangle
+//by taking the rotation matrix X1=[c s 0;-s c 0;0 0 1]; where c=cos and s=sin
+//O is theta
+
+Q = eye(3,3);
+for i=2:3
+ for j=1:i-1
+ p=i;q=j;
+ O = -atan(A1(p,q)/(A1(q,q)));
+ c = cos(O);
+ s = sin(O);
+ X = eye(3,3);
+ X(p,p)=c;
+ X(q,q)=c;
+ X(p,q)=-s;
+ X(q,p)=s;
+ A1 = X'*A1;
+ Q = Q*X;
+ disp(A1,X,'The X and A matrix : ');
+ end
+end
+R = A1;
+disp(R,Q,'Hence the original matrix can be decomposed as : ') \ No newline at end of file
diff --git a/191/CH4/EX4.13/Result4_13.txt b/191/CH4/EX4.13/Result4_13.txt
new file mode 100755
index 000000000..961550a90
--- /dev/null
+++ b/191/CH4/EX4.13/Result4_13.txt
@@ -0,0 +1,47 @@
+
+ A =
+
+ 1. 4. 2.
+ - 1. 2. 0.
+ 1. 3. - 1.
+
+ The X and A matrix :
+
+ 0.7071 0.7071 0.
+ - 0.7071 0.7071 0.
+ 0. 0. 1.
+
+ 1.4142 1.4142 1.4142
+ - 1.D-16 4.2426 1.4142
+ 1. 3. - 1.
+
+ The X and A matrix :
+
+ 0.8165 0. - 0.5774
+ 0. 1. 0.
+ 0.5774 0. 0.8165
+
+ 1.7321 2.8868 0.5774
+ - 1.D-16 4.2426 1.4142
+ 0. 1.633 - 1.633
+
+ The X and A matrix :
+
+ 1. 0. 0.
+ 0. 0.9333 - 0.3592
+ 0. 0.3592 0.9333
+
+ 1.7321 2.8868 0.5774
+ - 1.D-16 4.5461 0.7332
+ 4.D-17 0. - 2.032
+
+ Hence the original matrix can be decomposed as :
+
+ 0.5774 0.5133 - 0.635
+ - 0.5774 0.8066 0.127
+ 0.5774 0.2933 0.762
+
+ 1.7321 2.8868 0.5774
+ - 1.D-16 4.5461 0.7332
+ 4.D-17 0. - 2.032
+ \ No newline at end of file