diff options
author | prashantsinalkar | 2017-10-10 12:27:19 +0530 |
---|---|---|
committer | prashantsinalkar | 2017-10-10 12:27:19 +0530 |
commit | 7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch) | |
tree | dbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /260/CH4/EX4.5/4_5.sce | |
parent | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff) | |
download | Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2 Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip |
initial commit / add all books
Diffstat (limited to '260/CH4/EX4.5/4_5.sce')
-rw-r--r-- | 260/CH4/EX4.5/4_5.sce | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/260/CH4/EX4.5/4_5.sce b/260/CH4/EX4.5/4_5.sce new file mode 100644 index 000000000..6703a8b09 --- /dev/null +++ b/260/CH4/EX4.5/4_5.sce @@ -0,0 +1,40 @@ +//Eg-4.5
+//pg-149
+
+clear
+clc
+
+
+//False Position Method
+
+clear ;
+close ;
+clc ;
+//Coefficients of polynomial in increasing order of power of x
+A = [-3.1622777 -1.2649111 -0.1264911 0 0 100];
+x1 = 0 ;
+x2 = 2 ;
+fx = poly(A,'x','c');
+printf('\n\nThe given equation can be modified and written in the following form after substituting the values of given constants\n')
+disp(fx)
+i = 0;
+eps = 1;
+
+while(eps > 10^(-6))
+ i = i+1;
+ //printf('\n\nIteration No. %i \n',i);
+ fx1 = horner(fx,x1);
+ fx2 = horner(fx,x2);
+ xnew = (x1*fx2 - x2*fx1)/(fx2-fx1);
+ fxnew = horner(fx,xnew);
+ //printf('xnew = %f \nfxnew = %f',xnew,fxnew);
+
+ if fx1*fxnew < 0 then
+ x2 = xnew ;
+ else
+ x1 = xnew ;
+ end
+ eps = abs(fxnew);
+end
+
+printf('\n\nThe result obtained after %d iterations is x = %f\n',i,xnew)
\ No newline at end of file |