function ss=cheb(k, x) if k==0 ss=1; elseif k==1 ss=x; else t(1)=1; t(2)=x; for j=2:k t(j+1)=2*x*t(j)-t(j-1); end ss=t(k+1); end