function t = ch5(n, x) % ch5 - calculate T_n(x) using recurrence relations % T_n+1(x) = 2*x*T_n(x) - T_n-1(x) tm = x .^ 0; tn = x; for i = 1:n-1 tp = 2 .* x .* tn - tm; tm = tn; tn = tp; end t = tp; end