%-----------------------------------------------------------------------
% Script File: TangentPlot
% Displays increasingly smooth plots of Tangent(2*pi*x)
% in the range -pi/2 <= x <= 9pi/2
close all
% n=40
for n =[4 8 12 16 20 50 100 200 400 ]
% for n =4:4:36
  x=linspace(-pi/2,pi/2,n); y = tan(x);
   z=cos(x); plot(x,y,x,z)
  ymax = 4;
  axis([-pi/2 9*pi/2 -ymax ymax])
  title(' The Tangent function')
  xlabel(' x ')
  ylabel(' tan(x) ')
 hold on
  for k = 1:4
    xnew = x + k*pi;
%   plot(xnew,y)
%   plot(xnew,y,'*')
    z = cos(xnew);
%   plot(xnew,z)
    plot(xnew,y,'*',xnew,z,'o')
  title(' The cos-Tangent functions')
  end
 hold off
  pause(1)
end
