close all;
clear all;

% Taylor of sin(x) function
x = linspace(-4,4,100);

s1 = x;
s2 = s1-x.^3/6;
s3 = s2+x.^5/120;
s4 = s3-x.^7/(7*6*120);

% plot functions
figure(1);
plot(x,sin(x),'m',x,s1,'r',x,s2,'y',x,s3,'g',x,s4,'b');
xlabel('x'), ylabel('sinx'),
legend ('sin(x)','s1','s2','s3','s4')

figure(2);
x = linspace(-4,4,100);
plot(x,sin(x),'mo',x,s1,'r',x,s2,'y',x,s3,'g',x,s4,'b');
xlabel('x'), ylabel('sinx'),
legend ('sin(x)','s1','s2','s3','s4')
