function priklad1dMKP()

% -u''(x) = 1 v (0,1)
%    u(0) = 0
%  -u'(1) = tau

tau = 0; %0.1;

upresne = @(x) (-0.5*x.^2+(1-tau)*x);

for n = 5:5:200;
    h = 1/n;
    
    A = zeros(n,n);
    b = [h*ones(n-1,1);h/2-tau];
    for i=1:n
        for j=1:n
            if i==j
                if i<n
                    A(i,i) = 2/h;
                else
                    A(i,i) = 1/h;
                end
            elseif abs(i-j)==1
                A(i,j) = -1/h;
            end
        end
    end
    
    u = A\b;
    x = 0:h:1; xx = linspace(0,1,100);
    plot(x,[0;u]','b',xx,upresne(xx),'r')
    axis equal
    pause
end
