summaryrefslogtreecommitdiff
path: root/191/CH2/EX2.8/Example2_8.sce
diff options
context:
space:
mode:
Diffstat (limited to '191/CH2/EX2.8/Example2_8.sce')
-rwxr-xr-x191/CH2/EX2.8/Example2_8.sce27
1 files changed, 27 insertions, 0 deletions
diff --git a/191/CH2/EX2.8/Example2_8.sce b/191/CH2/EX2.8/Example2_8.sce
new file mode 100755
index 000000000..c393eb799
--- /dev/null
+++ b/191/CH2/EX2.8/Example2_8.sce
@@ -0,0 +1,27 @@
+//The method used to solve is SOR(Successive over-relaxation) method
+//only marginal improvement is possible for this pasticular system since
+//Gauss-Seidel iteration itself converges quite rapidly
+
+clear;
+close();
+clc;
+format('v',7);
+x1=[0,0];
+x2=[0,0];
+x3=[0,0];
+w =0.9;
+x1(1,2)=x1(1,1)+0.2*w*(6-5*x1(1,1)-2*x2(1,1)+x3(1,1));
+x2(1,2)=x2(1,1)+0.16667*w*(4-x1(1,2)-6*x2(1,1)+3*x3(1,1));
+x3(1,2)=x3(1,1)+0.25*w*(7-2*x1(1,2)-x2(1,2)-4*x3(1,1));
+i=1;
+while (abs(x1(1,1)-x1(1,2))>0.5*10^-2 | abs(x2(1,1)-x2(1,2))>0.5*10^-2 | abs(x3(1,1)-x3(1,2))>0.5*10^-2 )
+ x1(1,1)=x1(1,2);
+ x2(1,1)=x2(1,2);
+ x3(1,1)=x3(1,2);
+ x1(1,2)=x1(1,1)+0.2*w*(6-5*x1(1,1)-2*x2(1,1)+x3(1,1));
+ x2(1,2)=x2(1,1)+0.16667*w*(4-x1(1,2)-6*x2(1,1)+3*x3(1,1));
+ x3(1,2)=x3(1,1)+0.25*w*(7-2*x1(1,2)-x2(1,2)-4*x3(1,1));
+ i=i+1;
+end
+disp([x1; x2; x3],'Answers are:')
+disp(i,'Number of Iterations :')