summaryrefslogtreecommitdiff
path: root/845/CH3/EX3.10
diff options
context:
space:
mode:
Diffstat (limited to '845/CH3/EX3.10')
-rwxr-xr-x845/CH3/EX3.10/Ex3_10.sce27
1 files changed, 27 insertions, 0 deletions
diff --git a/845/CH3/EX3.10/Ex3_10.sce b/845/CH3/EX3.10/Ex3_10.sce
new file mode 100755
index 000000000..9ae7b2b35
--- /dev/null
+++ b/845/CH3/EX3.10/Ex3_10.sce
@@ -0,0 +1,27 @@
+//Example 3.10
+clc
+clear
+
+A = [1 1 1; 4 3 -1; 3 5 3];
+n = length (A(1,:));
+Aug = [A,eye(n,n)];
+
+N = 1:n;
+for i = 1:n
+ dummy1 = N;
+ dummy1(i) = [];
+ index(i,:) = dummy1;
+end
+
+// Forward Elimination
+for j = 1:n
+ [dummy2,t] = max(abs(Aug(j:n,j)));
+ lrow = t+j-1;
+ Aug([j,lrow],:) = Aug([lrow,j],:);
+ Aug(j,:) = Aug(j,:) / Aug(j,j);
+ for i = index(j,:)
+ Aug(i,:) = Aug(i,:) - Aug(i,j) / Aug(j,j) * Aug(j,:);
+ end
+end
+Inv_A = Aug(:,n+1:2*n);
+disp(Inv_A,"Inverse of A (A-1) = ")