%
%  hw02b.m
%

%  initialize workspace & set some control variables
clear;
Nt = 2000;  %  number of terms

%Np = 16*Nt;  %  number of plot points
%dx = pi/Np;  x = -pi+dx:dx:pi;

Np = 500;  %  number of plot points
dx = 0.15/Np;  x = -0.05:dx:0.2;

%  compute series

yf = 0;
for jf = 1:Nt
    yf = yf + exp(i*jf*x)/jf;
end

%  choose figure & clear (type "help hold")
figure(1);%  clf
subplot(2,1,1);  hold on

yfr = real(yf);
plot(x,yfr,'b');  plot(x,real(-log(1-exp(i*x))),'r--')
abox = [0.05 0.2 1 3.5];
axis(abox);

%  !!! put some info on the plot !!!
title('\bf uniform convergence')
ylabel('\bf Re[H(x)]')

subplot(2,1,2);  hold on

yfi = imag(yf);
plot(x,yfi,'b');  plot(x,imag(-log(1-exp(i*x))),'r--')
abox = [0.05 0.2 0.8 2];
axis(abox);
xlabel('\bf x-axis')
ylabel('\bf Im[H(x)]')
