summaryrefslogtreecommitdiff
path: root/260/CH4/EX4.10/4_10.sce
diff options
context:
space:
mode:
Diffstat (limited to '260/CH4/EX4.10/4_10.sce')
-rw-r--r--260/CH4/EX4.10/4_10.sce29
1 files changed, 29 insertions, 0 deletions
diff --git a/260/CH4/EX4.10/4_10.sce b/260/CH4/EX4.10/4_10.sce
new file mode 100644
index 000000000..255b61639
--- /dev/null
+++ b/260/CH4/EX4.10/4_10.sce
@@ -0,0 +1,29 @@
+//Eg-4.10
+//pg-161
+
+clear
+clc
+
+
+// Secant Method
+
+A=[-6 5 -3 2];
+x1=0.5;
+x2=0.7;
+eps=10^(-10);
+fx=poly(A,'x','c');
+iter=1;
+Abserr=100;
+while Abserr>eps
+ printf('iteration number %i\n',iter);
+ xnew1=x2-horner(fx,x2)*(x2-x1)/(horner(fx,x2)-horner(fx,x1));
+ printf('xnew1 = %f \n',xnew1);
+ Abserr = abs(horner(fx,xnew1) - horner(fx,x1))/abs(horner(fx,xnew1));
+ x1=x2;
+ x2=xnew1;
+ iter=iter+1;
+end
+
+disp("result was found in iterations")
+disp(iter-1)
+