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 --- 26/CH2/EX2.5.1/2_5_1.sce | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 26/CH2/EX2.5.1/2_5_1.sce (limited to '26/CH2/EX2.5.1') 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 -- cgit