p11: Chebyshev differentiation of a smooth function

p11: Chebyshev differentiation of a smooth function#

\[ u(x) = e^x \sin(5x), \qquad x \in [-1,1] \]
%config InlineBackend.figure_format='svg'
from numpy import linspace,exp,sin,dot
from matplotlib.pyplot import figure,subplot,plot,title
from chebPy import *
xx = linspace(-1.0,1.0,200,True)
uu = exp(xx)*sin(5.0*xx)
c = 1; figure(figsize=(10,8))
for N in [10,20]:
    D,x = cheb(N); u = exp(x)*sin(5.0*x)
    subplot(2,2,c); c += 1
    plot(x,u,'o',xx,uu)
    title('u(x), N='+str(N))
    
    error = dot(D,u) - exp(x)*(sin(5.0*x)+5.0*cos(5.0*x))
    subplot(2,2,c); c += 1
    plot(x,error,'o-')
    title('error in u\'(x), N='+str(N));
_images/644bf609286e23f6edf8593571f7ff1e9cf4488c28c597d1d4192961003d6f06.svg