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+(ih)); 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+2f(l+ih); else sum=sum+4f(l+ih); end end itg=(h/3)*(f(l)+f(u)+sum)