summaryrefslogtreecommitdiff
path: root/26/CH2/EX2.5.1
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /26/CH2/EX2.5.1
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 '26/CH2/EX2.5.1')
-rwxr-xr-x26/CH2/EX2.5.1/2_5_1.sce45
1 files changed, 45 insertions, 0 deletions
diff --git a/26/CH2/EX2.5.1/2_5_1.sce b/26/CH2/EX2.5.1/2_5_1.sce
new file mode 100755
index 000000000..591f40ab1
--- /dev/null
+++ b/26/CH2/EX2.5.1/2_5_1.sce
@@ -0,0 +1,45 @@
+disp('the lower triangular matrix is:')
+L=[1 0 0;-1 1 0;2 -5 1];
+disp(L)
+disp('the upper triangular matrix is:')
+U=[3 -7 -2;0 -2 -1;0 0 -1];
+disp(U)
+disp('the RHS of the equations are')
+b=[-7;5;2];
+disp(b)
+disp('combining matrices L and b')
+c=[L b];
+disp(c)
+disp('performing row operations')
+disp('R2=R2+R1')
+c(2,:)=c(2,:)+c(1,:)
+disp(c)
+disp('R3=R3-2*R1')
+c(3,:)=c(3,:)-2*c(1,:)
+disp(c)
+disp('R3=R3+5*R2')
+c(3,:)=c(3,:)+5*c(2,:)
+disp(c)
+y=c(:,4)
+disp(y,'y=')
+disp('combining U and y')
+d=[U y];
+disp(d)
+disp('performing row operations')
+disp('R3=R3/-6')
+d(3,:)=d(3,:)/(-1)
+disp(d)
+disp('R2=R2+R3 and R1=R1+2*R3')
+d(2,:)=d(2,:)+d(3,:)
+d(1,:)=d(1,:)+2*d(3,:)
+disp(d)
+disp('R1=R1-3.5*R2')
+d(1,:)=d(1,:)-3.5*d(2,:)
+disp(d)
+disp('R1=R1/3 and R2=R2/-2')
+d(1,:)=d(1,:)/3
+d(2,:)=d(2,:)/(-2)
+disp(d)
+disp('the solution is:')
+x=d(:,4)
+disp(x,'x=') \ No newline at end of file