function compareAnalyticalAndNumerical1dSolution(n)

h = 1/n;
x = 0:h:1;

%
% MKD
%
b = ones(n+1,1);
b(n) = 0;
A = zeros(n+1,n+1);
for i=1:n-1
    A(i,i) = -1/h^2;
    A(i,i+1) = 2/h^2;
    A(i,i+2) = -1/h^2;
end
A(n,1) = 1;
A(n+1,n) = 1/h;
A(n+1,n+1) = -1/h;
uMKD = A\b;

%
% MKP
%
b = h*ones(n,1);
b(n) = h/2-1;
A = zeros(n,n);
for i=1:n-1
    A(i,i) = 2/h;
    A(i,i+1) = -1/h;
    A(i+1,i) = -1/h;
end
A(n,n) = 1/h;
uMKP = A\b;


xx = 0:0.01:1;
uPresne = -0.5*xx.^2;
plot(xx,uPresne,'r',x,uMKD,'bo',x,[0;uMKP],'k--')
