Skip to content

Commit

Permalink
Date - 13 october,2020
Browse files Browse the repository at this point in the history
  • Loading branch information
masum035 authored Apr 27, 2021
1 parent 683df6b commit f909b2b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Simpson_Rule/Simpson_Rule_for_sin-x.m
Original file line number Diff line number Diff line change
@@ -0,0 1,33 @@
sine = @(x) sin( x * pi / 180);


lo = 0;
hi = pi / 2;

h = pi / 16;
n = (hi - lo) / h;


f = @(x) sin(x);

%cur = 0

for i = 1 : n 1
y(i) = f (lo (i-1) * h);
% y(i) = f(cur);
% cur = cur h;
end

I = 0;

for i = 2 : 2 : n
I = I 4 * y(i);
end

for i = 3 : 2 : n - 1
I = I 2 * y(i);
end

I = (h / 3) * ( y(1) I y(n 1) );

disp(I);

0 comments on commit f909b2b

Please sign in to comment.