summaryrefslogtreecommitdiff
path: root/260/CH3/EX3.14
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /260/CH3/EX3.14
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '260/CH3/EX3.14')
-rw-r--r--260/CH3/EX3.14/3_14.sce54
1 files changed, 54 insertions, 0 deletions
diff --git a/260/CH3/EX3.14/3_14.sce b/260/CH3/EX3.14/3_14.sce
new file mode 100644
index 000000000..54441692d
--- /dev/null
+++ b/260/CH3/EX3.14/3_14.sce
@@ -0,0 +1,54 @@
+//Eg-3.14
+//pg-108
+
+clear
+clc
+
+ A=[1 -1 1;2 -2 3;1 5 -3];
+ B=[4;6;7];
+
+n=3;
+
+Z=A;
+Y=B;
+I=[1 0 0;0 1 0;0 0 1];//creates an identity matrix of size n*n
+X=zeros(3,1);
+inverse=zeros(3,3);
+ABI=zeros(3,7);
+ABI(:,:)=[A(:,:) B(:,:) I(:,:)];//augumented matrix of A,B,I
+ for k=1:n//proceeds from 1st row to the last row
+ u=k;
+ big=abs(ABI(k,k));
+ for t=k+1:n //this loop is for selecting the elementhaving max absolute value in a column
+ dummy=abs(ABI(t,k));
+ if dummy>big
+ big=dummy;
+ u=t;
+ end
+ end
+ if u~=k
+ for j=1:2*n+1//interchanging rows to make max absolute element as pivot
+ dummy=ABI(u,j);
+ ABI(u,j)=ABI(k,j);
+ ABI(k,j)=dummy;
+ end
+ end
+ pivot=ABI(k,k);
+
+ ABI(k,:)=ABI(k,:)/pivot;
+
+ for i=1:n
+ if i~=k;
+ factor=ABI(i,k);
+ ABI(i,:)=ABI(i,:)-ABI(k,:)*factor;
+
+ end
+ end
+ X(:,:)=[ABI(:,n+1)];//determining X using augumented matrix
+ inverse(:,:)=[ABI(:,n+2:2*n+1)];//calculating inverse using augmented matrix
+end
+
+
+ disp("result")
+ disp(inverse)
+ \ No newline at end of file