From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 845/CH3/EX3.10/Ex3_10.sce | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 845/CH3/EX3.10/Ex3_10.sce (limited to '845/CH3/EX3.10') 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) = ") -- cgit