summaryrefslogtreecommitdiff
path: root/964/CH7/EX7.2/7_2.sce
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /964/CH7/EX7.2/7_2.sce
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '964/CH7/EX7.2/7_2.sce')
-rwxr-xr-x964/CH7/EX7.2/7_2.sce36
1 files changed, 36 insertions, 0 deletions
diff --git a/964/CH7/EX7.2/7_2.sce b/964/CH7/EX7.2/7_2.sce
new file mode 100755
index 000000000..ac713b96e
--- /dev/null
+++ b/964/CH7/EX7.2/7_2.sce
@@ -0,0 +1,36 @@
+clc;
+clear;
+function y=f(x)
+ y=x^3 - 13*x - 12
+endfunction
+
+x1t=-3;
+x2t=-1;
+x3t=4;
+x0=4.5;
+x1=5.5;
+x2=5;
+disp(0,"iteration:")
+disp(x2,"xr:")
+disp("---------------------------------------------")
+for i=1:4
+
+h0=x1-x0;
+h1=x2-x1;
+d0=(f(x1)-f(x0))/(x1-x0);
+d1=(f(x2)-f(x1))/(x2-x1);
+a=(d1-d0)/(h1+h0);
+b=a*h1+d1;
+c=f(x2);
+d=(b^2 - 4*a*c)^0.5;
+if abs(b+d)>abs(b-d) then x3=x2+((-2*c)/(b+d));
+else x3=x2+((-2*c)/(b-d)); end
+ea=abs(x3-x2)*100/x3;
+x0=x1;
+x1=x2;
+x2=x3;
+disp(i,"iteration:")
+disp(x2,"xr:")
+disp(ea,"ea(%):")
+disp("---------------------------------------------")
+end