function konvergenceRichardsonovyMetody()

h = 0.01;
[A,b] = mkd1d('sin',h);
x = linspace(0,1,length(b)+2);

N = 20;

'vlastni funkce Laplaceova operatoru (vlastni kmity struny)'
[V,D] = eig(full(A));
%for i=1:N
%    plot(x,[0;V(:,i);0]');
%    pause(0.5);
%end

lambda1 = min(diag(D));
lambdan = max(diag(D));
omega = 2/(lambda1+lambdan);
'konvergence Richardsonovy pro obecnou pravou stranu a omegaopt'
u0 = zeros(length(b),1);
[u,it] = Richardson(A,b,u0,1e-6,omega,100000);
it
'konvergence Chebyshevovy pro obecnou pravou stranu'
[u,it] = Chebyshev(A,b,u0,1e-6,lambda1,lambdan,100000);
it
pause

'konvergence Richardsonovy metody pro rychle vlastni funkce a omega = 1/lambdan'
omega = 1/lambdan;
u0 = zeros(length(b),1);
for i=length(b):-1:length(b)-N
    plot(V(:,i));
    D(i,i)
    [u,it] = Richardson(A,V(:,i),u0,1e-6,omega,10000);
    it
    pause(0.5)
end

