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.1 | |
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.1')
-rwxr-xr-x | 1670/CH8/EX8.1/8_1.sce | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/1670/CH8/EX8.1/8_1.sce b/1670/CH8/EX8.1/8_1.sce new file mode 100755 index 000000000..5eacaece2 --- /dev/null +++ b/1670/CH8/EX8.1/8_1.sce @@ -0,0 +1,27 @@ +//Example 8.1
+//Simpsons 1/3rd Rule
+//Page no 264
+clc;clear;close;
+a=0;b=5;n=10;h=(-a+b)/n
+
+for i=1:n
+ if i==1 then
+ x(1,i)=a
+ else
+ x(1,i)=x(i-1)+h
+ end
+ y(1,i)=1/(4*x(i)+5)
+end
+disp(y,"f(x) = ",x,"x = ")
+S=0;
+for i=1:n
+ if(i==1 | i==n)
+ S=S+y(1,i)
+ elseif(((i)/2)-fix((i)/2)==0)
+ S=S+4*y(1,i)
+ else
+ S=S+2*y(1,i)
+ end
+end
+S=S*h/3;
+printf('\n\nSimpsons 1/3rd Rule Sum = %g\n\nlog(5) = %.3g',S,log(5))
\ No newline at end of file |