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 /1670/CH8/EX8.14 | |
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 '1670/CH8/EX8.14')
-rwxr-xr-x | 1670/CH8/EX8.14/8_14.sce | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/1670/CH8/EX8.14/8_14.sce b/1670/CH8/EX8.14/8_14.sce new file mode 100755 index 000000000..394997551 --- /dev/null +++ b/1670/CH8/EX8.14/8_14.sce @@ -0,0 +1,41 @@ +//Example 8.14
+//Trapezoidal Rule
+//Page no. 284
+clc;close;clear;
+
+ax=1;bx=2;ay=1;by=2;h=0.25
+n=(bx-ax)/h+1
+n=5;
+for i=1:n
+ x(i)=ax+(i-1)*h
+ y(i)=ay+(i-1)*h
+end
+printf(' y/x\t|')
+for i=1:n
+ printf('\t%g\t',x(i))
+end
+printf('\n--------|-------------------------------------------------------------------------------')
+for i=1:n
+ printf('\n%g\t|\t',y(i))
+ for j=1:n
+ z(i,j)=1/(x(j)+y(i))
+ printf('%.5g\t\t',z(i,j))
+ end
+end
+
+//trapezoidal rule
+s=0;
+for i=1:n
+ for j=1:n
+ if (i==1 | i==n) & (j==1 | j==n) then
+ s=s+z(i,j)
+ elseif i==1 | i==n | j==1 | j==n
+ s=s+2*z(i,j)
+ else
+ s=s+4*z(i,j)
+ end
+ end
+end
+s=(s*(h^2))/4
+printf('\n\n')
+disp(s,'Trapezoidal Rule Sum = ')
\ No newline at end of file |