function cviko1()

x = 0:0.01:1;
u = -0.5*x.^2+x+1;
% plot(x,u,'r')

for k=3:20
    n = 2^k;
    h = 1/(n-1);
    A = sparse(n,n); b = zeros(n,1);
    A(1,1) = 1; b(1) = 1;
    A(n,n-1) = 1/h; A(n,n) = -1/h;
    
    for j=2:n-1
        A(j,j-1) = -1/h^2;
        A(j,j) = 2/h^2;
        A(j,j+1) = -1/h^2;
        b(j) = cos(exp((j-1)*h));
    end
    u = A\b;
    
    x = 0:h:1;
    hold on
    plot(x,u','b')
    pause
end