

x = -3*pi:0.05:3*pi;
f = cos(x);

p0 = 1+0*x;
p2 = 1 - (1/2)*x.^2;
p4 = 1 - (1/2)*x.^2 + (1/24)*x.^4;
p6 = 1 - (1/2)*x.^2 + (1/24)*x.^4 - (1/720)*x.^6;

figure(2)
plot(x,p0,x,p2,x,p4,x,p6,x,f,'k-.','linewidth',3)
axis([-6 6 -2 2])
grid
legend('\fontsize{16} p0','\fontsize{16} p2', ...
       '\fontsize{16} p4','\fontsize{16} p6', ...
       '\fontsize{16} cos(x)','Location','South')
title('\fontsize{16} Taylor polys for cos(x)')


