clear all;
close all;
clc;

x=0:pi/200:pi;
y=cos(x);

y0=ones(size(x));
y2=y0-x.^2/prod(1:2);
y4=y2+x.^4/prod(1:4);
y6=y4-x.^6/prod(1:6);

plot(x',[y' y0' y2' y4' y6'],'LineWidth',3);
set(gca,'XTick',0:pi/4:pi)
set(gca,'XTickLabel',{'0','pi/4','pi/2','3*pi/4','pi'})
xlabel('0 \leq \theta \leq \pi','FontSize',16)
ylabel('cos(\theta)','FontSize',16)
axis([0,pi,-1.2,1.2])
legend('cos(\theta)','1','1-\theta^2/2!','1-\theta^2/2!+\theta^4/4!','1-\theta^2/2!+\theta^4/4!-\theta^6/6!')
