Chebyshev Collocation Method for Differential Equations

12
Lecture 8 Chebyshev collocation method for differential equations Katarina Gustavsson MA5251 Spectral Methods and Applications, 2011

description

How to use the Chebyshev matrix to solve complex differential equations and integrals.

Transcript of Chebyshev Collocation Method for Differential Equations

Page 1: Chebyshev Collocation Method for Differential Equations

Lecture 8

Chebyshev collocation method for differential equations

Katarina Gustavsson

MA5251 Spectral Methods and Applications, 2011

Page 2: Chebyshev Collocation Method for Differential Equations

Two point boundary value problem Time independent – linear/non-linear

i Time independent boundary value problem in a general form !uxx (x)+ p(x)ux (x)+ q(x)ux (x) = f (x,u), -1" x "1 ! >0 is a fixed parameter and p(x), q(x) and f (x) are given functionsi Boundary conditons on general (mixed) form: #$u($1)+ %$ux ($1) = g$ #+u(1)+ %+ux (1) = g+i Dirichlet boundary conditions: u($1) = g$ u(1) = g+i Neumann boundary conditions: ux ($1) = g$ ux (1) = g+ The coefficients # ± %± g± are known

Page 3: Chebyshev Collocation Method for Differential Equations

Time dependent problems - linear/non-linear

i Heat equation ut ! "uxx = 0 with boundary conditions given on u(-1,t) = g! and u(1,t) = g+ and initial condition u(x,0) = f (x)i Linear wave equation ut + ux= 0 boundary conditions given on u(-1,t) = g! and ux (1,t) = g+ and initial condition u(x,0) = f (x)i Burgers equation ut + uux ! "uxx = 0 with boundary conditions given on u(-1,t) = g! and u(1,t) = g+ and initial condition u(x,0) = f (x)

Page 4: Chebyshev Collocation Method for Differential Equations

Review on the Chebyshev transform

i A function u(x) can be expanded in Chebyshev series

u(x) = ukTk (x) k=0

!

" uk =2

#cku(x)Tk (x)$ (x)dx

%1

1

& $ (x) = (1% x2 )%1/2 and ck = 2 for k = 0 and ck = 1 for k '1i The Chebyshev polynomials are given by Tk (x) = cos(k cos

%1(x))i In the discrete Chebyshev-Gauss-Lobatto case:

x j = cos# jN, j = 0,1,2…,N and $ j =

#2 !ck

where

!ck = 2 for j = 0,N and !ck = 1 for j = 1,2,…,N %1i The discrete Chebyshev coefficients are given by

!uk =2!ckN

1!cju(x j )

j=0

N

" cos # kjN

()*

+,- =

2!ckN

1!cju(x j )

j=0

N

" . ei kj#N

()*

+,-, k = 0,1,…N

Page 5: Chebyshev Collocation Method for Differential Equations

Review on the Chebyshev transform, cont.

i A function u(x) can be expanded in discrete Chebyshev series

u(x j ) = !ukTk (x j ), j = 0,1,…,N k=0

N

!

i Chebyshev interpolant INu = !ukTk (x)k=0

N

! (1)

i Or in terms of Chebyshev lagrangian polynomials INu = u(x j )" jj=0

N

! (x) (2)

" j (x) =(#1) j+1(1# x2 ) $TN (x)!cjN

2 (x # x j )i Note that INu(x j ) = u(x j ) and that (1)% (2)

Page 6: Chebyshev Collocation Method for Differential Equations

Review on the Chebyshev transform - derivatives

i Derivative in transform (polynomial) space (discrete)

INu(x j )( )! := DNu( ) j = !uk(1)Tk

k=0

N

" (x j )

INu(x j )( ) !!!!! := D2Nu( ) j = !uk

(2)Tkk=0

N

" (x j )

i The coefficients can be found by a recursive relation ck !uk

(1) = !uk+2(1) + 2(k +1) !uk+1, k = N #1,N # 2,…0

ck !uk(2) = !uk+2

(2) + 2(k +1) !u(1)k+1 k = N #1,N # 2,…0 !uN+1

(1) = !uN(1) = 0 and !uN+1

(2) = !uN(2) = 0

i Cost of O(N logN ) if FFT is used

Typo!!

Page 7: Chebyshev Collocation Method for Differential Equations

Review on the Chebyshev transform - derivatives

i Derivative in "physical" space DNu( ) j = u(l=0

N

! xl ) "# l (x j ) = Djlu(l=0

N

! xl )

i Djl are the entries in the Chebyshev derivative matrix, D

i The matrix entries for the second order derivative matrix, D2, are given by (DD) jl where DD is a matrix-multiplicationi The Chebyshev derivative matrix at quadrature points is given by

Djl =

!cj ($1)j+l

!cl (x j $ xl ) l % j

$ xl2(1$ xl

2 ) 1& l = j & N $1

'

())

*))

Djl =

2N 2 +16

l = j = 0

$ 2N2 +16

l = j = N

'

())

*))

i The matrix approach costs O(N 2 )

Page 8: Chebyshev Collocation Method for Differential Equations

Example of a Dirichlet problem

i We wish to solve, by a Chebyshev collocation method,

uxx + xux ! u = (24 + 5x2 )e5x + (2 + 2x2 )cos(x2 )! (4x2 +1)sin(x2 )

f (x )! "######### $######### ,

on !1" x "1 (1)i With boundary conditions

u(!1) = e!5 + sin(1) = g! and u(1) = e5 + sin(1) = g+

i Let x = (x0, x1,…, xN )T where x j = cos

j#N

$%&

'() , j = 0,1,2,…N

are the Chebyshev-Gauss-Lobatto points

i Let f = ( f (x0 ), f (x1),…, f (xN ))T

i Let u = (g+ ,u(x1),u(x2 ),…,u(xN!1),g! )T and

uM = (u(x1),u(x2 ),…,u(xN!1))T be the vector of unknows to be determined

i We will work with the Chebyshev derivative matrices D and D2

i The entries in D are given by Dij , 0 " i, j " N and D2 = DD

Page 9: Chebyshev Collocation Method for Differential Equations

Example of a Dirichlet problem, cont.

i The approximation to (1) is given by

DM2 uM ! xM "DMuM ! uM = F

i xM = x(1:N !1), DM = D(1:N !1,1:N !1), DM2 = D2 (1:N !1,1:N !1)

F = f(1:N !1)! D2 (1:N !1,0)+ xM "D(1:N !1,0)#$ %&g+ !

D2 (1:N !1,N )+ xM "D(1:N !1,N )#$ %&g!i The approximation can also be written on the form AuM = F where A is a matrix of size (N !1)' (N !1)i The matrix A is given by A = D2 + (D! I where ( is a diagonal matrix with the values of xM on the diagonal and I is the identity matrixi The approximate solution is given as the solution to the

linear system of equations uM = A!1F

Page 10: Chebyshev Collocation Method for Differential Equations

Solution

1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 120

0

20

40

60

80

100

120

140

160

x

u(x)

Exact solutionN=5N=10N=20

0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.85

10

15

20

25

30

35

40

45

50

x

u(x)

Exact solutionN=5N=10N=20

100 101 10210 12

10 10

10 8

10 6

10 4

10 2

100

102

N

err

i The exact solution is u(x) = e5x + sin(x2 )

i The error is defined by err = max1! j!N"1! uj " u(x j )

Convergence

i The error obtained by a second order finite difference approximation with N = 512 is approximately the same as with N = 10 in the spectral method

Page 11: Chebyshev Collocation Method for Differential Equations

Code example - MATLAB N=10![D, x] = cheb(N); Chebyshev derivation matrix, D!D2=D*D; Chebyshev derivation matrix, D2!!DM=D(2:N,2:N); For the inner points only!D2M=D2(2:N,2:N); Note that the numbering of the !L=diag(x(2:N),0); elements in a vector/matrix is !I=diag(ones(N-1,1),0); from 1 to N+1 (not 0 to N)! !A=D2M+L*DM-I; A as in Au=F!!f=(24+5*x).*exp(5*x)+(2+2*x.^2).*cos(x.^2);!f=f-(4*x.^2+1).*sin(x.^2);!gminus=exp(-5)+sin(1);!gplus=exp(5)+sin(1);! !F=f(2:N)-(D2(2:N,1)+x(2:N).*D(2:N,1))*gplus!F=F-(D2(2:N,end)+x(2:N).*D(2:N,end))*gminus;! !sol=A\F u=A-1F! !u=[gplus;sol;gminus]; Add the known boundary conditions!!

Page 12: Chebyshev Collocation Method for Differential Equations

Remarks •  The collocation method will lead to a full and ill-conditioned

linear system •  Gaussian elimination to solve Au=F is only feasible for

problems with a small number of unknowns (one-dimensional problems)

•  For multi-dimensional problems an iterative method together with an appropriate pre-conditioner should be used

•  We will get back to this when we speak about multi-dimensional problems

100 101 102 103100

102

104

106

108

1010

N

max(||)

Eigenvalues of A are growing as N4