summaryrefslogtreecommitdiff
path: root/243/CH12/EX12.4/12_04.sce
diff options
context:
space:
mode:
Diffstat (limited to '243/CH12/EX12.4/12_04.sce')
-rwxr-xr-x243/CH12/EX12.4/12_04.sce28
1 files changed, 28 insertions, 0 deletions
diff --git a/243/CH12/EX12.4/12_04.sce b/243/CH12/EX12.4/12_04.sce
new file mode 100755
index 000000000..b38a5bb83
--- /dev/null
+++ b/243/CH12/EX12.4/12_04.sce
@@ -0,0 +1,28 @@
+//Example No. 12_04
+//Simpon's 1/3 rule
+//Pg No.382
+clear ;close ;clc ;
+
+deff('F = f(x)','F = sqrt( sin(x) )');
+x0 = 0 ;
+xa = %pi/2 ;
+
+//case(a) n = 4
+n = 4 ;
+h = ( xa-x0 )/n
+I = 0
+for i = 1:n/2
+ I = I + f(x0 + (2*i-2)*h) + 4*f(x0 + (2*i-1)*h) + f(x0 + 2*i*h) ;
+end
+I = h*I/3
+disp(I,'Integral value for n = 4 is',h,'h = ')
+
+//case(b) n = 6
+n = 6
+h = ( xa-x0 )/n
+I = 0
+for i = 1:n/2
+ I = I + f(x0 + (2*i-2)*h) + 4*f(x0 + (2*i-1)*h) + f(x0 + 2*i*h) ;
+end
+I = h*I/3
+disp(I,'Integral value for n = 6 is',h,'h = ') \ No newline at end of file