diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /191/CH3/EX3.3/Example3_3.sce | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '191/CH3/EX3.3/Example3_3.sce')
-rwxr-xr-x | 191/CH3/EX3.3/Example3_3.sce | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/191/CH3/EX3.3/Example3_3.sce b/191/CH3/EX3.3/Example3_3.sce new file mode 100755 index 000000000..0cd02ef26 --- /dev/null +++ b/191/CH3/EX3.3/Example3_3.sce @@ -0,0 +1,40 @@ +//We have quadratic equation x^2-2*x-8=0 with roots -2 and 4
+//for solving it we use fixed point iteration method for that we rearrange it in 3 ways.
+//first way x=(2*x+8)^(1/2)
+//here x0 is chosen arbitrarily
+
+clear;
+clc;
+close();
+format('v',5)
+funcprot(0);
+deff('[fixed_point]=fx(x)','fixed_point=(2*x+8)^0.5')
+x0=5;
+while abs(x0-fx(x0))>0.5*10^(-2)
+ x0=fx(x0);
+end
+disp(x0,'root is :')
+
+//second way x=(2*x+8)/x
+
+format('v',5)
+funcprot(0);
+deff('[fixed_point]=fx(x)','fixed_point=(2*x+8)/x')
+x0=5;
+while abs(x0-fx(x0))>0.5*10^(-2)
+ x0=fx(x0);
+end
+disp(x0,'root is :')
+
+//third way x=(x^2-8)/2
+
+format('v',10)
+funcprot(0);
+deff('[fixed_point]=fx(x)','fixed_point=(x^2-8)/2')
+x0=5;
+for i=1:5
+ x0=fx(x0);
+ disp(x0,'value is :')
+end
+disp(x0,'As you can see that the root is not converging.So this method is not applicable.')
+
|