f= @(x)(cos(x))^2;
l=-0.25;u=0.25;n=4;
h=(u-l)/n;
sum=0;
for i=1:n-1
    sum=sum+f(l+(i*h));
end
itg=(h/2)*(f(l)+f(u)+(2*sum))
*********************************
f=@(x) (cos(x))^2;l=-0.25;u=0.25;n=4;
h=(u-l)/n;
sum=0;
for i=1:n-1
    if rem(i,2)==0
        sum=sum+2*f(l+i*h);
    else
        sum=sum+4*f(l+i*h);
    end
end
itg=(h/3)*(f(l)+f(u)+sum)