function res = ChebRek(n,x)
    switch n
        case 0
            res = ones(size(x));
        case 1
            res = x;
        otherwise
            res = 2*x.*ChebRek(n-1,x) - ChebRek(n-2,x);
    end
end