diff options
Diffstat (limited to '243/CH11/EX11.3/11_03.sce')
-rwxr-xr-x | 243/CH11/EX11.3/11_03.sce | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/243/CH11/EX11.3/11_03.sce b/243/CH11/EX11.3/11_03.sce new file mode 100755 index 000000000..08da4ffd2 --- /dev/null +++ b/243/CH11/EX11.3/11_03.sce @@ -0,0 +1,21 @@ +//Example No. 11_03
+//Pg No. 353
+close ;clear ;clc ;
+
+x = 0.45;
+deff('F = f(x)','F = sin(x)');
+deff('DF = df(x,h)','DF = (f(x+h) - f(x))/h');
+dfactual = cos(x);
+h = 0.01:0.005:0.04;
+n = length(h);
+for i = 1:n
+ y(i) = df(x,h(i))
+ err(i) = y(i) - dfactual ;
+end
+table = [ h' y err];
+disp(table)
+//scilab uses 16 significant digits so the bound for roundoff error is 0.5*10^(-16)
+e = 0.5*10^(-16)
+M2 = max(sin(x+h));
+hopt = 2*sqrt(e/M2);
+disp(hopt,'hopt = ',M2,'M2 = ')
\ No newline at end of file |