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
1 Basic principles
Problem formulation
Various numerical methods
Various spectral methods
How to choose trial functions
2 Two illustrative examples of spectral methods
A Fourier Galerkin method for the wave equation
A Chebyshev collocation method for the heat equation
3 Summary
Basic principles Two illustrative examples of spectral methods Summary The end
Problem formulation
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
X
u(x, t) ≈ u N (x, t) = an (t)φn (x)
n=0
and use some strategy to minimize the Residual Lu N − f .
Basic principles Two illustrative examples of spectral methods Summary The end
Problem formulation
Trial functions and test functions
Search for solution u N in a finite-dimensional sub-space HN of
some Hilbert space H.
Trial Functions: basis of HN : (φ0 , . . . , φN )
N
X
N
u = ak φk
k =0
Test Functions: family of functions (ψ0 , . . . , ψN )
∀n ∈ 0, . . . , N, (ψn , R) = 0
Basic principles Two illustrative examples of spectral methods Summary The end
Various numerical methods
Classification 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 Two illustrative examples of spectral methods Summary The end
Various spectral methods
Classification 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 Two illustrative examples of spectral methods Summary The end
How to choose trial functions
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
X
u N (x, t) = ak (t)φk (x).
−N/2
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
6= M(u N ).
∂t
The approximation is obtained by selecting a set of test
functions ψk and requiring that
2π
∂u N
Z
[ − M(u N )]ψk (x)dx = 0, (1)
0 ∂t
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 −ikx
ψk (x) = 2π e .
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
Z 2π
ak (t) = u(x, t)ψk (x)dx.
0
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
∂u
M(u) = ,
∂x
condition (1) becomes
Z 2π N/2
1 ∂ ∂ X
[( − ) al (t)eilx ]e−ikx dx = 0,
2π 0 ∂t ∂x
−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:
Z 2π
ak (0) = u(x, 0)ψk (x)dx.
0
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
∞
X
u(x, t) = ak (t)eikx ,
k =−∞
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 coefficients are
kπ
ak (t) = sin( )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
X
u N (x, t) = ak (t)eikx
−N/2
converges faster than any finite 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 finite difference method
An illustrative of the superior accuracy from the spectral
method for this problem is given in the following figure.
Figure: Maximum errors for the linear hyperbolic problem at t = 2π
for Fourier Galerkin and several finite 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 cos−1 x), for k = 0, 1, . . . .
The first few Chebshev polynomials are
T0 (x) = 1
T1 (x) = x
T2 (x) = 2x 2 − 1
...
Tn+1 (x) = 2xTn (x) − Tn−1 (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
X
N
u (x, t) = ak (t)φk (x).
k =0
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 satisfied
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. (2)
∂t
u N (−1, t) = 0, u N (1, t) = 0.
u N (xk , 0) = u(xk , 0), k = 0, . . . , N.
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
πj
xj = cos( ).
N
Note that
πjk
φk (xj ) = cos(
).
N
We can apply Fast Fourier Transform (FFT) to evaluate
M(u N )|x=xj .
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
2
u(x, t) = e−π t sin πx.
It has the infinite Chebyshev expansion
∞
X
u(x, t) = bk (t)Tk (x),
k =0
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
2 kπ 2
bk (t) = sin( )Jk (π)e−π t
ck 2
with
2, k = 0,
ck =
1, k ≥1
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
X
u N (x, t) = uj (t)φj (x),
j=0
and now φj denote the characteristic Lagrange polynomials
with the property φj (xi ) = δij for 0 ≤ i, j ≤ N. The expansion
coefficients are given by
N
2 X −1 πlk
ak (t) = cl ul (t) cos , k = 0, 1, . . . , N,
Nc k N
l=0
where
2, k = 0 or N
ck =
1, 1≤k ≤N −1
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
N
∂2uN X (2)
(t) = ak (t)Tk (x),
∂x 2
k =0
where
(1) (1)
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
(2) (2)
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.
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)
(2)
The coefficients ak depend linearly on the nodal values ul ;
thus, there exists a matrix DN2 such that
N N
∂2uN X (2) πjk X
2
(t)|x=xj = ak (t) cos = (DN2 )jl ul (t).
∂x N
k =0 l=0
Substituting the above expression into (2), we obtain a system
of ODE for the nodal unknowns:
N
duj X
(t) = (DN2 )jl ul (t), j = 1, . . . , N − 1.
dt
l=0
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 figure.
Figure: Maximum errors for the heat equation problem at t = 1 for
Chebyshev collocation and several finite 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
efficiency
exponential convergency/spectral convergency
However, spectral methods also suffers drawbacks in the
following folds:
coding: more difficult 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!