function prikladIntegrace()

f = @(x) exp(x).*sin(x);
a = 0; b = 1;

for N=1:100
    H = (b-a)/N;
    x = a+H*(2*[1:N]-1)./2;
    ksi = a+H*[0:N];
    I0(N) = H*sum(feval(f,x));
    I1(N) = H*(sum(feval(f,ksi)) - ...
        0.5*(feval(f,ksi(1))+feval(f,ksi(end))));
    I2(N) = (2/3)*I1(N)+(4/3)*I0(N);
end
N = 1:100;
plot(log10(N(1:end-1)),log10(abs(I0(1:end-1)-I0(end))),'r',...
    log10(N(1:end-1)),log10(abs(I1(1:end-1)-I1(end))),'k',...
    log10(N),log10(N.^(-2)),'r--',...
    log10(N(1:end-1)),log10(abs(I2(1:end-1)-I2(end))),'b',...
    log10(N),log10(N.^(-4)),'b--')
