clear clf ch5def = @(n, x) cos(n*acos(x)); N = 7 np = 100; x = linspace(-1, 1, np); tic(); y = ch5def(N, x); ttt1 = toc(); plot(x, y) hold on tic(); z = ch5(N, x); ttt2 = toc(); plot(x, z) xlabel('x') ylabel('T_n(x)') title('Chebyshev polynomials') legend('definition', 'recurrence', 'location', 'best') grid on ylim([-1, 1.5]) ttt1 ttt2