% fft_demo3
% Fourier series for h(z) = log(abs(z-R)), |z|=1
R=1.1;
n=16;
x1=linspace(0,2*pi,n+1)';
x=x1(1:n);
z1=exp(i*x1);
h1=log(abs(z1-R));
figure(1)
plot(x1,h1,'o');
axis([0 7 -3.5 3.5]);
hold on;
h=h1(1:n);
c=fft(h);  % nx Fourier coefficients
x4=linspace(0,2*pi,4*n+1);
c4=zeros(4*n,1);  % pad Fourier coefficients with zeros
c4(1:n/2)=c(1:n/2);
c4(3*n+n/2+1:4*n)=c(n/2+1:n);
h4=4*ifft(c4);
h41=[h4;h4(1)];
plot(x4,h41);
figure(2)
%hold off;
semilogy(1:n/2,abs(c(1:n/2)/n),'.')
%axis([1 n/2 10^(-7) 10]);