format long x = -1:0.01:1; y = -x.^2; f = exp(y); n = size(x,2); w = ones(1,n); w(2:2:n-1) = 4; w(3:2:n-2) = 2; s = w*f'*0.01/3