x=randi([-20 20]);
a=x+randi([2 20]);
k = sin(x); % true value
y = zeros(1,201); % approximation
y(1) = sin(a);
d = zeros(1,200) % derivative
for n = 1:200
e = mod(n,4);
if e==1;
d(n) = sin(a);
elseif e==2;
d(n) = cos(a);
elseif e==3;
d(n) = -sin(a);
elseif e==0;
d(n) = -cos(a);
end
y(n+1) = y(n)+d(n).*(x-a).^(n)./factorial(n);
end
error = abs((y-k)./k);
check = error<=0.05
t = find(check==1);
w = y(t);
est = k(1);