summaryrefslogtreecommitdiff
path: root/1670/CH3/EX3.20/3_20.sce
diff options
context:
space:
mode:
Diffstat (limited to '1670/CH3/EX3.20/3_20.sce')
-rwxr-xr-x1670/CH3/EX3.20/3_20.sce16
1 files changed, 16 insertions, 0 deletions
diff --git a/1670/CH3/EX3.20/3_20.sce b/1670/CH3/EX3.20/3_20.sce
new file mode 100755
index 000000000..5f8f0db43
--- /dev/null
+++ b/1670/CH3/EX3.20/3_20.sce
@@ -0,0 +1,16 @@
+//Example 3.20
+//Gauss Seidel Method
+//Page no. 75
+clc;clear;close;
+
+x0=0;y0=0;z0=0;
+deff('x=f1(y,z)','x=(17-y+2*z)/20')
+deff('y=f2(x,z)','y=(-18-3*x+z)/20')
+deff('z=f3(x,y)','z=(25-3*x+3*y)/20')
+for i=1:3
+ x0=f1(y0,z0);
+ y0=f2(x0,z0);
+ z0=f3(x0,y0);
+ printf('\tx(%i) = %g\n\n\ty(%i) = %g\n\n\tz(%i) = %g\n\n\n\n',i,x0,i,y0,i,z0)
+end
+printf('Thus we find that solution converges to %.1g, %.1g and %.1g',x0,y0,z0) \ No newline at end of file