diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /1332/CH14/EX14.5/14_5.sce | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '1332/CH14/EX14.5/14_5.sce')
-rwxr-xr-x | 1332/CH14/EX14.5/14_5.sce | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/1332/CH14/EX14.5/14_5.sce b/1332/CH14/EX14.5/14_5.sce new file mode 100755 index 000000000..eecf2d374 --- /dev/null +++ b/1332/CH14/EX14.5/14_5.sce @@ -0,0 +1,35 @@ +//Example 14.5
+//Romberg Method
+//Page no. 457
+clc;close;clear;
+
+deff('y=f(x)','y=1/(1+x)')
+
+h=[0.5,0.25,0.125]
+for k=1:3
+ for i=0:h(k):1
+ x(i/h(k)+1)=i;
+ y(i/h(k)+1)=f(x(i/h(k)+1))
+ end
+ n=1+(1/h(k))
+ //trapezoidal rule
+ S=0;
+ for i=1:n
+ if(i==1 | i==n)
+ S=S+y(i)
+ else
+ S=S+2*y(i)
+ end
+ end
+ S=S*h(k)/2
+ printf('\n\nI(%g) = %g',h(k),S)
+ z(2*k-1,1)=S
+end
+for i=2:3
+ for k=1:4-i
+ z(k*2+i-2,i)=z(2*k-1+i,i-1)+(z(2*k-1+i,i-1)-z(2*k-3+i,i-1))/3
+end
+end
+
+printf('\n\n')
+disp(z,'The Table of values:')
\ No newline at end of file |