function [u,k,konvergHist] = CebysevovaMetoda(A,b,epsil,kmax)

n = length(b);
Lambda = sort(eig(full(A)));

i = [0:(kmax-1)];
xvlnka = cos((2*i+1)*pi./(2*kmax));
lambdak = 0.5*(Lambda(1)+Lambda(end)-(Lambda(end)-Lambda(1))*xvlnka);
omegak = 1./lambdak;


u = zeros(n,1);
k = 0;
r = b - A*u;
normr = norm(r);
normr0 = normr;
konvergHist(k+1) = normr/normr0;

while normr/normr0 > epsil
    u = u + omegak(k+1)*r;
    r = b - A*u;
    normr = norm(r);
    k = k+1;
    konvergHist(k+1) = normr/normr0;
end