KAUSTUBH DEEPAK URADE - Practical No. 12 - Numerical Integration by Simpson's 1 - 3rd Rule PDF

You might also like

You are on page 1of 1

%% Simpsons 1/3th

f=@(x)4*x-3*x^2
n=6; %no. of intervals
U=1; %upper limit
L=0; %lower limit
h=(U-L)/n %interval gap
x=(L:1/n:U)
for i = 1:n+1
y(i)=f(x(i));
end
y

K=0
for i=2:2:n
K=K+y(i)
end
K

KU=0
for i=3:2:n-1
KU=KU+y(i)
end
KU
answer=(y(1)+y(n+1)+4*(K)+2*(KU))*(h/3)

ANSWER=1

You might also like