function cviko5()

% -(k(x)*u'(x))' = 1 v (0,1),
%    u(0) = u(1) = 0,
% kde k(x) = 1 v (0,1/2) a k(x) = 2 v (1/2,1),
% Galerkinovou metodou v bazi
% ei(x) = x*(1-x)^i pro i=1,2,...,n

syms x

figure

for n = 10:10:100
    A = zeros(n,n);
    b = zeros(n,1);
    for i=1:n
        ei = x*(1-x)^i;
        for j=1:n
            ej = x*(1-x)^j;
            A(i,j) = int(diff(ei)*diff(ej),0,0.5)+5*int(diff(ei)*diff(ej),0.5,1);
        end
        b(i) = int(ei,0,1);
    end
    alpha = A\b;
    t = 0:0.01:1;
    u = t;
    u(:) = 0;
    for j=1:n
        u = u + alpha(j)*t.*(1-t).^j;
    end
    n
    hold on
    plot(t,u)
    pause
end


