format long f = @(x) e^(-x); pointsNum = 51; h = 1/(pointsNum-1); sum = 0; for i=0:2*h:1-2*h sum += (h/3)*(f(i)+4*f(i+h)+f(i+2*h)); end sum