summaryrefslogtreecommitdiff
path: root/413/CH1/EX1.2
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /413/CH1/EX1.2
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '413/CH1/EX1.2')
-rw-r--r--413/CH1/EX1.2/Table2.sce28
1 files changed, 28 insertions, 0 deletions
diff --git a/413/CH1/EX1.2/Table2.sce b/413/CH1/EX1.2/Table2.sce
new file mode 100644
index 000000000..45015c2db
--- /dev/null
+++ b/413/CH1/EX1.2/Table2.sce
@@ -0,0 +1,28 @@
+//The secant method for f(x)=3*x+sin(x)-exp(x), starting from 0 and 1 )
+clearglobal()
+clc;
+fx='3*x+sin(x)-exp(x)'//Define function here
+x0=0;// intial value
+x1=1;// second vale
+x2=4; //just to start loop
+tol=0.0000001; // tolerence value
+x = x0; fa=eval(fx);
+x = x1; fb=eval(fx);
+x = x2; fc=eval(fx);
+i=1;
+while abs(fc)>tol
+ if abs(fa)<abs(fb) then
+ xc=x0;
+ x0=x1;
+ x1=xc;
+ end
+ x = x0; fa=eval(fx);
+ x = x1; fb=eval(fx);
+ x2=x1-fb*(x0-x1)/(fa-fb);
+ x = x2; fc=eval(fx);
+ X = [i,x0,x1,x2,fc];
+ disp(X)
+ x0=x1;
+ x1=x2;
+ i=i+1;
+end; \ No newline at end of file