format long e a=0; b=1; n=64; h=(b-a)/n; g=@(x) a+h*x; f=@(x) exp(-x); s1=0; for j=1:n/2 s1=s1+f(g(2*j-1)); end s2=0; for j=1:n/2-1 s2=s2+f(g(2*j)); end t=h/3*(f(0)+4*s1+2*s2+f(1)); t