summaryrefslogtreecommitdiff
path: root/1670/CH3/EX3.10/3_10.sce
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1670/CH3/EX3.10/3_10.sce
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '1670/CH3/EX3.10/3_10.sce')
-rwxr-xr-x1670/CH3/EX3.10/3_10.sce56
1 files changed, 56 insertions, 0 deletions
diff --git a/1670/CH3/EX3.10/3_10.sce b/1670/CH3/EX3.10/3_10.sce
new file mode 100755
index 000000000..5c707aadf
--- /dev/null
+++ b/1670/CH3/EX3.10/3_10.sce
@@ -0,0 +1,56 @@
+//Example 3.10
+//Triangularization Method
+//Page no. 62
+clc;clear;close;
+
+A=[2,4,-6;1,5,3;1,3,2];
+B=[-4;10;5];
+printf('A can be factorizaed as follows:\n')
+printf('\tL\t\t *\t\tU\t\t =\t\tA')
+U(2,1)=0;U(3,1)=0;U(3,2)=0;
+L(1,2)=0;L(1,3)=0;L(2,3)=0;
+for i=1:3
+ L(i,i)=1
+end
+for i=1:3
+ U(1,i)=A(1,i)
+end
+L(2,1)=1/U(1,1);
+for i=2:3
+ U(2,i)=A(2,i)-U(1,i)*L(2,1);
+end
+L(3,1)=1/U(1,1);
+L(3,2)=(A(3,2)-U(1,2)*L(3,1))/U(2,2);
+U(3,3)=A(3,3)-U(1,3)*L(3,1)-U(2,3)*L(3,2);
+printf('\n')
+for i=1:3
+ for j=1:3
+ printf('%.2f\t',L(i,j))
+ end
+
+ if(i==2)
+ printf(' * ')
+ else
+ printf('\t')
+ end
+
+ for j=1:3
+ printf('%.2f\t',U(i,j))
+ end
+ if(i==2)
+ printf(' = ')
+ else
+ printf('\t')
+ end
+ for j=1:3
+ printf('%.2f\t',A(i,j))
+ end
+ printf('\n')
+end
+printf('\nY=U*X')
+ Y=inv(L)*B
+ X=inv(U)*Y
+printf('\n\nX=')
+for i=1:3
+ printf('\n %i',X(i,1))
+end \ No newline at end of file