diff options
Diffstat (limited to '60/CH4/EX4.8/ex_8.sce')
-rwxr-xr-x | 60/CH4/EX4.8/ex_8.sce | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/60/CH4/EX4.8/ex_8.sce b/60/CH4/EX4.8/ex_8.sce new file mode 100755 index 000000000..7271a528a --- /dev/null +++ b/60/CH4/EX4.8/ex_8.sce @@ -0,0 +1,24 @@ +//example 4.1 (pg 149) + + //2x1 + 3x2 - x3 = 5 + //-2x2 - x3 = -7 + //-5x3 = -15 + +A = [2 3 -1;0 -2 -1;0 0 -5] +b = [5 -7 -15]' +a=[A b] +[nA,mA]=size(A) +n=nA + + //Backward substitution + +x(3) = a(n,n+1)/a(n,n); + +for i = n-1:-1:1 + sumk=0; + for k=i+1:n + sumk=sumk+a(i,k)*x(k); + end + x(i)=(a(i,n+1)-sumk)/a(i,i); +end + disp(x)
\ No newline at end of file |