% Employing the Composite Simpson's Rule

% Input endpoints
a=0;
b=1;
% Input number of subintervals
n=10;

h=(b-a)/n;
XI0=intf(a)+intf(b);
XI1=0;
XI2=0;

for i=1:n-1
   X=a+i*h;
   if mod(i,2)==0
      XI2=XI2+intf(X);
   else
      XI1=XI1+intf(X);
   end
end
XI=h*(XI0+2*XI2+4*XI1)/3;
display(XI)


