function fouriersmooth % Fourier coefficients for a smooth function kmax = 20; f = zeros(kmax+1,1); f(1) = abs(quadgk(@(x)mycos(x,0),0,2*pi)); for k = 1:kmax, f1 = quadgk(@(x)mysin(x,k),0,2*pi); f2 = quadgk(@(x)mycos(x,k),0,2*pi); f(k+1) = sqrt(f1^2+f2^2); end semilogy(0:kmax,f), makelarge xlabel('k'); title('Fourier coefficients of smooth function'); function y = mysin(x,k) y = exp(cos(x)) .* sin(k*x); function y = mycos(x,k) y = exp(cos(x)) .* cos(k*x);