function konvergence1dMKP()

% Priklad 3: -[k(x)*u'(x)]' = 10, u(0) = 1, k(1)*u'(1) = 0
%            k(x) := 1 na (0,1/2), k(x) := 4 na (1/2,1)
k1 = 1; k2 = 1; a = 0.5; l = 1; F = 10; u0 = 1; tau = 0;
xx = 0:0.01:l; [uu,auu] = analytickeReseni1d(k1,k2,a,l,F,u0,tau,xx);

h = 0.5.^[1:6];
err = h;
for i=1:length(h)
  i
  uzly = 0:h(i):l;
  n = round(l/h(i))+1;
  prvky = [1:n-1;2:n];
  stredy = 0.5*(uzly(prvky(1,:))+uzly(prvky(2,:)));
  m = n-1;
  f = F*ones(1,m);
  k = k1*ones(1,m);
  idx = find(stredy>a);
  k(idx) = k2;
  [A,b,Avlnka] = mkp1d(uzly,prvky,k,f,u0,tau);
  uH = A\b;
  u = [u0;uH];
  auu - u'*Avlnka*u
  err(i) = sqrt(auu - u'*Avlnka*u);
end

plot(h,err)
xlabel('h'); ylabel('\|u-uh\|_a')