We repeat p11 but using FFT.
%config InlineBackend.figure_format = 'svg'
from chebfftPy import chebfft
from numpy import pi,linspace,sin,cos,exp,round,zeros,arange,real, flipud
from numpy.fft import fft,ifft
from matplotlib.pyplot import figure,subplot,plot,grid,title,axis
figure(figsize=(10,12))
plot_count = 1
for N in [10,20]:
xx = linspace(-1.0,1.0,100)
ff = exp(xx)*sin(5*xx)
x = cos(arange(0,N+1)*pi/N)
f = exp(x)*sin(5*x)
error = chebfft(f) - exp(x)*(sin(5*x)+5*cos(5*x))
subplot(3,2,plot_count); plot_count +=1
plot(xx,ff,'-',x,f,'o')
grid(True)
axis([-1, 1, -4,2])
title('f(x), N='+str(N))
subplot(3,2,plot_count); plot_count +=1
plot(x,error,'-o')
title('error in f\'(x), N='+str(N))
grid(True)