An Introduction To Spectral Methods
An Introduction To Spectral Methods
J. Frauendiener
Institut für Astronomie und Astrophysik
Abteilung Theoretische Astrophysik
Universität Tübingen
[email protected]
Contents
• Introductory example
• Spectral approximation
• Example
Introductory Example
∂u ∂u
(t, x) = (t, x) x ∈ [0, 2π], t ∈ [0, T ),
∂t ∂x
u(0, x) = u0(x) x ∈ [0, 2π]
u(t, 0) = u(t, 2π) t ∈ [0, T ).
∞
u(t, x) = ∑ ûk (t)eikx
k=−∞
• Approximate
N/2−1
u(t, x) ≈ ∑ ûk (t)eikx
k=−N/2
• Insert into PDE
N/2−1
∂ûk ikx N/2−1
∑ ∂t e = ∑ ik û k e ikx
,
k=−N/2 k=−N/2
∂ûm
= imûm, m = −(N/2) : N/2 − 1
∂t
• Solve
ûm(t) = eimt ûm(0), m = −(N/2) : N/2 − 1.
• Reconstruct
N/2−1
u(t, x) ≈ ∑ ûk (0) eik(x+t)
k=−N/2
ut = Mu, on U ⊂ Rm
Bu = 0, on ∂U
R := ūt − Mū
is small.
What is “small”?
N
ū = ∑ uiφi
i=0
• Use test functions (χ0, χ1, . . . , χN ) to probe for the smallness of the
residual R = ūt − Mū
hχn|Ri = 0, for n = 0, 1, . . . , N
• Galerkin method:
– χn = φn
– all φn satisfy the boundary conditions B(φn) = 0
– residual is orthogonal to VN
R ⊥ VN ,
• Tau method:
– χn = φn
– boundary conditions are imposed as additional equations
– equations for the expansion coefficients
• Pseudo-spectral method:
– χn = δ(x − xn)
R(xn) = 0
– two representations of ū, ‘coefficients’ and ‘values’
N
ū(xn) = ∑ uiφi(xn)
i=0
Spectral approximation
The trigonometric polynomials φk (x) = eikx are orthogonal on [0, 2π] with the
inner product Z 2π
hφk |φl i = φk (x)φl (x) dx = 2π δkl
0
For a function u : [0, 2π] → C define the continuous Fourier coefficients by
1
Z 2π
ûk = u(x)e−ikx dx, k∈Z
2π 0
Convergence?
For u ∈ C 1 compute
Z 2π i i
Z 2π
2π ûn = u(x)e−inx dx = [u(2π) − u(0)] − u0(x)e−inx dx = O (n−1).
0 n n 0
1 N−1
ũk = ∑ u(x j ) e−ikx j
N j=0
N/2−1
IN u(x) = ∑ ũk eikx
j=−N/2
and
! " #
1 N−1 1 N−1 1 N−1 i(m−k)x j
ũk = ∑ u(x j ) e −ikx j
= ∑ ∑ ûm e imx j
e −ikx j
= ∑ ûm ∑ e
N j=0 N j=0 m∈Z m∈Z N j=0
| {z }
=1 for m=k+NZ
∞
ũk = ûk + ∑ ûk±mN
m=1
Aliasing error
IN u = PN u + RN u
k = −10 k = −2 k=6
Differentiation
Two possibilities:
D : ûk 7→ ikûk .
1 N−1
ũk = ∑ u(x j ) e−ikx j
N j=0
w(x) = 1 Legendre
1
w(x) = √ Chebyshev
1 − x2
w(x) = (1 − x)α(1 + x)β Jacobi
∞
u(x) = ∑ ûkφk(x)
k=0
hu|φk i 1
Z 1
ûk = = u(x)φk (x)w(x) dx
hφk |φk i hφk |φk i −1
Gauß integration
Approximate
Z 1 N
f (x)w(x) dx ≈ ∑ wi f (xi)
−1 i=0
If the collocation points xi’s are the N + 1 zeros of the polynomial φN+1 and
if the weights wi are the solution of the linear system
N Z 1
∑ wi (xi) k
=
−1
xk w(x) dx
i=0
Gauß-Lobatto integration
where (a, b) are chosen so that q(±1) = 0 and if the weights wi solve the
linear system
N Z 1
∑(xi) k
wi =
−1
xk w(x) dx
i=0
then
N Z 1
∑ p(xi) wi = −1
p(x)w(x) dx
i=0
for every polynomial with degree ≤ 2N − 1.
1 N N
ũk = ∑ u(xi)φk (xi)wi, with γk = ∑ φk (xi)2 wi
γk i=0 i=0
N
IN u = ∑ ũk φk
k=0
It satisfies
IN u(x j ) = u(x j ).
N
PN u = ∑ ûk φk
k=0
PN u = IN u + RN u
Same results hold for truncation error and aliasing error as for
trigonometric polynomials.
T0(x) = 1
T1(x) = x
T2(x) = 2x2 − 1
T3(x) = 4x3 − 3x
T4(x) = 8x4 − 8x2 + 1
T5(x) = 16x5 − 20x3 + 5x
Orthogonality
1 dx π
Z
Tn(x)Tm(x) √ = cmδmn, c0 = 2, cl = 1 otherwise
−1 1 − x2 2
xk = cos(kπ/N),
Boundary values
Tn(±1) = ±1,
Product formula
1
TmTn = Tm+n + T|m−n|
2
Solve on [−1, 1]
Approximation
N
uN = ∑ ai Ti
i=0
Collocation: with uN (t, xk ) = uk (t), u00N (t, xk ) = u00k (t)
(Method of lines)
Differentiate
Solve on [−1, 1]
Approximation
N
uN = ∑ ak(t) ψk = ak(t)ψk
k=0
Differentiation matrix:
D2Tm = Tm00 = Dl mTl
Residual:
RN = u̇N − u00N = ȧk (t)ψk − ak ψ00k
Galerkin: test functions = trial functions
similarly:
For N = 3:
2 0 0 0 0
0 1 0 0 0 −2 0 1 0 0 3 0 −1
S∗ = 0 −1 0 1 0 S∗S = 0 2 0
G= 0 0 1 0 0
0 0 0 1 0 0 0 −1 0 1 −1 0 2
0 0 0 0 1
• Spherical harmonics
• Stability issues
• Non-linearities
• Domain decomposition
References