diff options
Diffstat (limited to '260/CH4/EX4.4/4_4.sce')
-rw-r--r-- | 260/CH4/EX4.4/4_4.sce | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/260/CH4/EX4.4/4_4.sce b/260/CH4/EX4.4/4_4.sce new file mode 100644 index 000000000..cf59e091f --- /dev/null +++ b/260/CH4/EX4.4/4_4.sce @@ -0,0 +1,32 @@ +//Eg-4.4
+//pg-147
+
+clear
+clc
+
+
+//False Position Method
+
+clear ;
+close ;
+clc ;
+//Coefficients of polynomial in increasing order of power of x
+A = [-2 1 -2 1];
+x1 = 1 ;
+x2 = 3 ;
+fx = poly(A,'x','c');
+for i = 1:20
+ printf('\n\nIteration No. %i \n',i);
+ fx1 = horner(fx,x1);
+ fx2 = horner(fx,x2);
+ x0 = x1 - fx1*(x2-x1)/(fx2-fx1)
+ printf('xnew = %f \n',x0);
+ fx0 = horner(fx,x0);
+ if fx1*fx0 < 0 then
+ x2 = x0 ;
+ else
+ x1 = x0 ;
+ end
+end
+
+printf('\n\nPlease note that the author has considered only 5 decimal places, but here we have taken 6 decimal places, so a minor difference in the answer may occur')
\ No newline at end of file |