You are on page 1of 28

Basic principles

Two illustrative examples of spectral methods

Summary

The end

Introduction to Spectral Methods


Lu Yixin

September 26, 2007

Basic principles

Two illustrative examples of spectral methods

Summary

The end

Outline

Basic principles Problem formulation Various numerical methods Various spectral methods How to choose trial functions Two illustrative examples of spectral methods A Fourier Galerkin method for the wave equation A Chebyshev collocation method for the heat equation Summary

Basic principles Problem formulation

Two illustrative examples of spectral methods

Summary

The end

Solving a PDE numerically

Consider the PDE with boundary condition Lu = f , in u = g, on . Question: How to solve the above PDE numerically? Approximate the unknown u(x, t) by a sum of basis functions:
N

u(x, t) u N (x, t) =
n=0

an (t)n (x)

and use some strategy to minimize the Residual Lu N f .

Basic principles Problem formulation

Two illustrative examples of spectral methods

Summary

The end

Trial functions and test functions

Search for solution u N in a nite-dimensional sub-space HN of some Hilbert space H. Trial Functions: basis of HN : (0 , . . . , N )
N

u =
k =0

ak k

Test Functions: family of functions (0 , . . . , N ) n 0, . . . , N, (n , R) = 0

Basic principles Various numerical methods

Two illustrative examples of spectral methods

Summary

The end

Classication according to trial functions

Finite difference: trial functions: overlapping local polynomials of low order Finite element: trial functions: local smooth functions, nearly orthogonal Spectral methods: trial functions: global smooth functions, nearly orthogonal

Basic principles Various spectral methods

Two illustrative examples of spectral methods

Summary

The end

Classication according to test functions

Galerkin: n = n , n satisfy some or all of the boundary conditions. Collocation: n = (x xn ), xn are collocation points. Tau: n = n , but n do not satisfy the boundary conditions.

Basic principles How to choose trial functions

Two illustrative examples of spectral methods

Summary

The end

What sets of "trial functions" will work?

It is obvious that we would like our trial function sets to have a number of properties: easy to compute rapid convergence completeness

Basic principles

Two illustrative examples of spectral methods

Summary

The end

Outline of the second part

A Fourier Galerkin method for the wave equation:


trial function test function weak formulation accuracy comparison with FD

A Chebyshev collocation method for the heat equation: . . . , comparison with Galerkin method, . . .

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Fourier Galerkin method for the wave equation

Wave equation

Many evolution equations can be written as u = M(u). t Consider the domain (0, 2) with periodic boundary conditions. The approximate solution u N is represented as
N/2

u N (x, t) =
N/2

ak (t)k (x).

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Fourier Galerkin method for the wave equation

Weak formulation

In general, u N = M(u N ). t The approximation is obtained by selecting a set of test functions k and requiring that
2

[
0

u N M(u N )]k (x)dx = 0, t

(1)

for k = N/2,. . . ,N/2.

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Fourier Galerkin method for the wave equation

Spectral method using trigonometric polynomials

Trigonometric polynomials: k (x) = eikx , 1 k (x) = 2 eikx . If this were merely an approximation problem, then u N (x, t) would be the truncated Fourier series of the known function u(x, t) with
2

ak (t) =
0

u(x, t)k (x)dx.

However, for the PDE, u(x, t) is not known; the approximation is determined by (1).

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Fourier Galerkin method for the wave equation

How does the scheme work (1) ?

For the linear hyperbolic problem u u = 0, t x i.e.,for M(u) = condition (1) becomes 1 2
2

u , x

[(
0

) t x

N/2

al (t)eilx ]eikx dx = 0,
N/2

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Fourier Galerkin method for the wave equation

How does the scheme work (2)?

The analytical (spatial) differentiation of the trial functions and the analytical integration of that expression produce the dynamical equations: dak ikak = 0, k = N/2, . . . , N/2. dt The initial conditions are:
2

ak (0) =
0

u(x, 0)k (x)dx.

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Fourier Galerkin method for the wave equation

The accuracy of the Fourier Galerkin method (1) Use the initial condition u(x, 0) = sin( cos(x)) to illustrate the accuracy of the Fourier Galerkin method for the above hyperbolic equation. The exact solution, u(x, t) = sin( cos(x + t)), has the Fourier expansion

u(x, t) =
k =

ak (t)eikx ,

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Fourier Galerkin method for the wave equation

The accuracy of the Fourier Galerkin method (2) The Fourier coefcients are ak (t) = sin( k )Jk ()eikt 2

and Jk (t) is the Bessel function of order k . The asymptotic properties of the Bessel functions imply that k p ak (t) 0 as k

for all positive integers p. Thus,the truncated Fourier series,


N/2

u N (x, t) =
N/2

ak (t)eikx

converges faster than any nite power of 1/N.

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Fourier Galerkin method for the wave equation

Comparison with nite difference method An illustrative of the superior accuracy from the spectral method for this problem is given in the following gure.

Figure: Maximum errors for the linear hyperbolic problem at t = 2 for Fourier Galerkin and several nite difference schemes

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

Chebyshev polynomials for the heat equation Chebyshev polynomials: Tk (x) = cos(k cos1 x), for k = 0, 1, . . . . The rst few Chebshev polynomials are T0 (x) = 1 T1 (x) = x T2 (x) = 2x 2 1 ... Tn+1 (x) = 2xTn (x) Tn1 (x).

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

The approximate solution (1) Given the heat equation u 2 u 2u = 0, i.e., M(u) = t x 2 x 2 on (1, 1) with homogeneous Dirichlet boundary conditions, u(1, t) = 0, u(1, t) = 0. Choosing the trial functions k (x) = Tk (x), k = 0, 1, . . . , N,

the approximate solution has the representation


N

u (x, t) =
k =0

ak (t)k (x).

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

The approximate solution (2)

In the collocation approach the above PDE must be satised exactly by the approximate solution at collocation points xj in the domain of (1, 1): u N M(u N )|x=xj = 0, j = 1, . . . , N 1. t u N (1, t) = 0, u N (1, t) = 0. u N (xk , 0) = u(xk , 0), k = 0, . . . , N. (2)

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

Choice of collocation points

A convenient choice for the collocation points xj is xj = cos( Note that j ). N

jk ). N We can apply Fast Fourier Transform (FFT) to evaluate M(u N )|x=xj . k (xj ) = cos(

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

How the Chebyshev collocation approach works (1)

For the particular initial condition u(x, 0) = sin x, the exact solution is u(x, t) = e t sin x. It has the innite Chebyshev expansion

u(x, t) =
k =0

bk (t)Tk (x),

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

How the Chebyshev collocation approach works (2)

. . . where bk (t) = with

k 2 2 sin( )Jk ()e t ck 2 2, 1, k = 0, k 1

ck =

Since Jk () is decaying rapidly, the truncated series converges at an exponential rate. A well-designed collocation method will do the same.

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

How the Chebyshev collocation approach works (3) A collocation method is implemented in terms of the nodal values uj (t) = u N (xj , t) and we have the expansion
N

u N (x, t) =
j=0

uj (t)j (x),

and now j denote the characteristic Lagrange polynomials with the property j (xi ) = ij for 0 i, j N. The expansion coefcients are given by ak (t) = where ck = 2, 1, k = 0 or N 1k N 1 2 Nc k
N

cl
l=0

ul (t) cos

lk , N

k = 0, 1, . . . , N,

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

How the Chebyshev collocation approach works (4) The exact derivative of u N (x, t) becomes 2uN (t) = x 2 where aN+1 (t) = 0, aN (t) = 0, (1) (1) c k ak (t) = ak +2 (t) + 2(k + 1)ak +1 (t), k = N 1, . . . , 0, and aN+1 (t) = 0, aN (t) = 0, (2) (2) (1) c k ak (t) = ak +2 (t) + 2(k + 1)ak +1 (t), k = N 1, . . . , 0.
(2) (2) (1) (1) N

ak (t)Tk (x),
k =0

(2)

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

How the Chebyshev collocation approach works (5) The coefcients ak depend linearly on the nodal values ul ; 2 thus, there exists a matrix DN such that 2uN (t)|x=xj = x 2
N (2)

ak (t) cos
k =0

(2)

jk = N

N 2 (DN )jl ul (t). l=0

Substituting the above expression into (2), we obtain a system of ODE for the nodal unknowns: duj (t) = dt
N 2 (DN )jl ul (t), l=0

j = 1, . . . , N 1.

Supplemented by the initial conditions, the ODE system for the nodal values of solution is readily integrated in time.

Basic principles

Two illustrative examples of spectral methods

Summary

The end

A Chebyshev collocation method for the heat equation

Comparison with Finite difference method An illustrative of the superior accuracy from the spectral method for this problem is given in the following gure.

Figure: Maximum errors for the heat equation problem at t = 1 for Chebyshev collocation and several nite difference schemes

Basic principles

Two illustrative examples of spectral methods

Summary

The end

Pros and Cons of spectral methods

Spectral methods have many advantages over FD and FE methods: high accuracy efciency exponential convergency/spectral convergency However, spectral methods also suffers drawbacks in the following folds: coding: more difcult to code than FD cost: costly per degree of freedom than FD geometry: for complicated domains, heavy loss of accuracy

Basic principles

Two illustrative examples of spectral methods

Summary

The end

Thanks for your attention!

You might also like