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/47d5461f1aceb36e5aa314e6ca0afe4b40312b6927b3b1dbd1ec7e02417da373.svg