0% found this document useful (0 votes)
67 views20 pages

Chap 1

This document discusses spectral methods for solving differential equations numerically. It begins by deriving second-order and fourth-order finite difference formulas on a uniform grid for the derivative of a function. It then shows how to represent these formulas in matrix form using sparse matrices in Matlab. Examples are provided to demonstrate spectral accuracy and exponential convergence of the method. Tables of error values for different resolutions are given. Fourier components of the solution are computed and observed to match the continuous solution to machine precision for certain modes.

Uploaded by

torinomg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views20 pages

Chap 1

This document discusses spectral methods for solving differential equations numerically. It begins by deriving second-order and fourth-order finite difference formulas on a uniform grid for the derivative of a function. It then shows how to represent these formulas in matrix form using sparse matrices in Matlab. Examples are provided to demonstrate spectral accuracy and exponential convergence of the method. Tables of error values for different resolutions are given. Fourier components of the solution are computed and observed to match the continuous solution to machine precision for certain modes.

Uploaded by

torinomg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Chapter 1 Spectral method in Matlab

Centered second-order and 4-th order finite difference on uniform grid


u j +1 u j 1 h 2 (3)
du
( x j ) = 2h 3! u ( c )
dx

(Eq. 1)

u j + 2 + 8u j +1 8u j 1 + u j 2 h 4 ( 5)
du
=
+ u (c)
x
( j)
12h
30
dx
We can use another representation to derive this formula, consider polynomial interpolation
(Eq. 2)

p j ( x ) with degree 2 for smooth u over x j 1 , x j +1 .


p j ( x ) = u j 1a1 ( x ) + u j a0 ( x ) + u j +1a1 ( x )
satisfying p j ( x j 1 ) = u j 1 , p j ( x j ) = u j and p j ( x j +1 ) = u j +1 . In other words,

a1 ( x ) , a0 ( x ) , a1 ( x ) are Lagrange polynomial satisfying


a1 ( x j 1 ) = 1

a1 ( x j ) = 0 ,

a1 ( x j +1 ) = 0

(Eq. 3)

a0 ( x j 1 ) = 0
a1 ( x j 1 ) = 0

a0 ( x j ) = 1 and a1 ( x j ) = 0

a1 ( x j +1 ) = 1
a0 ( x j +1 ) = 0

we know
a1 ( x ) =

( x x )( x x ) = ( x x )( x x ) ,
2h
( x x )( x x )

a1 ( x j ) =

( x x )( x x ) = ( x x )( x x ) ,
h
( x x )( x x )

a0 ( x j ) = 0

j 1

j 1

j +1

j +1

j 1

j +1

a1 ( x ) =

j +1

j 1

a0 ( x ) =

j +1

j 1

1
2h

j +1

( x x )( x x ) = ( x x )( x x ) , a x = 1
( ) 2h
2h
( x x )( x x )
j 1

j 1

j +1

j 1

j +1

u j +1 u j 1
d
p j ( x ) |x = x j = u j 1a1 ( x j ) + u j a0 ( x j ) + u j +1a1 ( x j ) =
dx
2h

If we write w j =

u j +1 u j 1

or w j =

u j + 2 + 8u j +1 8u j 1 + u j 2

, then general matrix form can


2h
12h
be represented as w = Au , see Figure 1 and Figure 2. In fact matrix A is skew symmetry, say
A = AT , this can be obtained from antiHermitian of operator

d
under periodic boundary
dx

condition through integration by parts.

w1
w2
w3
w4

-1

-1

-1

-1

-1

-1

1
2h

w5
w6

Figure 1: matrix representation of w j =

w1
w2
w3
w4

w5
w6
w7
w8

-1

u j +1 u j 1
2h

with periodic boundary condition

-1

u1
u2
u3
u4

-8

-1

-8

-1

-8

-1

-8

-1

-8

-1

-8

-1

-8

-1

-8

-1

1
-8

u j + 2 + 8u j +1 8u j 1 + u j 2

u j +1 u j 1

u5
u6

1
12h

Figure 2: w j =

u1
u2
u3
u4

-1

12h

u5
u6
u7
u8

with periodic boundary condition.

1
1
and A ( j , j 1) =
. In fact if we want to
2h
2h
2h
use Matlab as platform, what we only do is to construct triangle part R of A , then

From w j =

, we have A ( j , j + 1) =

A = R RT . Moreover we can use sparse matrix representation in Matlab to construct matrix


R . (how to construct R : please see source code p1.m in Example 1)

Figure 3: document of sparse matrix representation in Matlab.

Example 1: try u ( x ) = exp ( sin ( x ) ) over [ , ] by using 4-th order finite difference
scheme. Matlab script: F:\course\2008spring\spectral_method\matlab\p1.m.
In this example we use N = 8,16, 32, , 4048 , test convergence rate of Dhu u , result is
shown in Figure 4.

Figure 4: log-log plot for

( )

Dhu u , note that it is clear O h 4

Example 2: try u ( x ) = exp ( sin ( x ) ) over [ , ] by using spectral method.


We plot error for Dhu u and Dhu u 2 .

Question 1: dots in Figure 5 and Figure 6 lies in pair, means that error of n = 8,10 ,
n = 12,14 are almost the same, why? (Note that this pair phenomenon occurs even we
use Dhu u 2 ).

Figure 5: spectral accuracy of the spectral method, it achieve machine accuracy. Sup-norm

Figure 6: spectral accuracy of the spectral method, it achieve machine accuracy. 2-norm

Table 1: we list the value of pair ( L2 err )


L err
2

L2 err

n = 4, 6

n = 8,10

n = 12,14

0.24777190419502

0.00871672632422

0.94197188122419E-4

0.33078448076569

0.00864342870238

0.84097522689018E-4

n = 16,18

n = 20, 22

n = 24, 26

0.50008967910710E-6

0.15812146492563E-8

0.33254794093191E-11

0.42247516569957E-6

0.12910423145203E-8

0.26512109052603E-11

Table 2: we list the value of pair ( L err )


L err

L err

n = 4, 6

n = 8,10

n = 12,14

0.17520119364380

0.00431791109859

0.38249095565268E-4

0.16307358056713

0.00316947217836

0.25253568612049E-4

n = 16,18

n = 20, 22

n = 24, 26

0.17618931913432E-6

0.49879544938847E-9

0.97200025805932E-12

0.10953028789507E-6

0.29827984526776E-9

0.59258153939368E-12

Table 3: we list the value of pair ( L err ) for arprec 128 digits
n = 28, 30
n = 32,34
n = 36,38
n = 40, 42
n = 44, 46
n = 48, 50
n = 52,54
n = 56,58
n = 60, 62
n = 64, 66
n = 68, 70
n = 72, 74
n = 76, 78
n = 80,82
n = 84,86
n = 88, 90
n = 92,94
n = 96,98

1.32624221983015620680098434362948e-15
7.56612859983412967818296086049246e-16
1.39095872807168126193852953110517e-18
7.81451569905447385343012380339833e-19
1.14244909925972473070099230882981e-21
6.34086538799698880852642854985210e-22
7.54806757417172375166373940244838e-25
4.14826359601086676154821757222175e-25
4.09864701833461299055736676547760e-28
2.23423056735975763167625559605640e-28
1.86164252456817011022120353206289e-31
1.00786673375963438339376505661880e-31
7.17767982003012719000648270914229e-35
3.86321334725399173651104700894601e-35
2.37854454643974045195143562239834e-38
1.27374376983182194482918312198058e-38
6.84730032444346812021198287838704e-42
3.65071328394049314224342346654448e-42
1.72836808647069444865147310660496e-45
9.17936617551766050908476538695563e-46
3.85647559072931642402400673411656e-49
2.04115689771413325003291669779317e-49
7.66124774385363632507038345929950e-53
4.04254667547222108076077515483580e-53
1.36375587422112860698500475832273e-56
7.17625294246753762277314925189095e-57
2.18769132299786362708446911624823e-60
1.14833541792638712588483843196297e-60
3.17896250168716103543670487976991e-64
1.66490575382791587484894062926081e-64
4.20398304881730575304253164828023e-68
2.19721922822932053740570006526006e-68
5.08108143833400125413169287191248e-72
2.65065013672443604039455837009901e-72
5.63449984243390032676388653577986e-76
2.93428197672848600468452855610906e-76
5

Table 4: we compute Fourier component vk = h e

ikx j

j =1

, m , N = 2m

v j for k = 0,1, 2,

since v k = vk = vN k . Since vk C , we represent it as two value, real part (top value) and
imaginary part (bottom value)
n=8
n = 10
n = 12
n = 14

V0

7.95492777270178

7.95492651755339

7.95492652101937

7.95492652101284

V1

-3.55100946128190

-3.55099934367285

-3.55099937850296

-3.55099937842424

V2

-0.85306906632123

-0.85292713831639

-0.85292776589386

-0.85292776416086

V3

0.14099397515943

0.13927827358326

0.13928835644092

0.13928832168940

V4

0.03439566712026

0.01705653312949

0.01719845940133

0.01719783182714

eps

eps

-0.00171570149744

-0.00170561863991

-0.00028260085474

-0.00014067458291

V5
V6

eps

V7

eps

n = 16

n = 18

n = 20

n = 22

V0

7.95492652101284

7.95492652101284

7.95492652101284

7.95492652101285

V1

-3.55099937842436

-3.55099937842436

-3.55099937842436

- 3.55099937842436

V2

-0.85292776416412

-0.85292776416412

-0.85292776416412

-0.85292776416412

V3

0.13928832176800

0.13928832176787

0.13928832176788

0.13928832176788

V4

0.01719783356013

0.01719783355686

0.01719783355687

0.01719783355687

V5

-0.00170565339142

-0.00170565331282

-0.00170565331295

- 0.00170565331295

V6

-0.00014130215710

-0.00014130042411

-0.00014130042738

-0.00014130042737

V7

0.00001008285753

0.00001004810602

0.00001004818462

0.00001004818449

V8

0.00000125168893

0.00000062411474

0.00000062584773

0.00000062584446

Eps

Eps

- 0.00000003475152

-0.00000003467292

-0.00000000345946

-0.00000000172646

V9
V10

Eps

V11

Eps

n
In order to avoid confusion in discussion, we define Vk( ) as Fourier component Vk for degree
n . Then we have some observations
n
n
(O1) ReV2(k +)1 = 0 and Im V2(k ) = 0 up to machine accuracy, this matches continuous

counterpart, see Lemma 2. Note that in the proof of Lemma 2, we use sin ( x ) = sin ( x )

/2

esin x

e sin ( 2kx ) dx =

cos ( ( 2k + 1) x ) dx = e

and claim

sin x

/2

/ 2 sin x

/2

sin x

sin ( 2kx ) dx and

cos ( ( 2k + 1) x ) dx .

sin ( 2 kx j ) = cos ( ( 2 k + 1) x j ) = 0
j=3

j=2
j=1

j=4
j=5

j =10

j=6

j=5

j=1

j=6

j =12

j=7

j=9

j = 11
j=8

j=8

j=7

j=3

j=4

j=2

j=9

Case 1

j = 10

Case 2

( n)

( n)

Figure 7: There are two cases in discrete version of Re V2 k +1 = 0 and Im V2 k = 0 .

Since we use uniform grids and N is even, we have symmetry over half pane, we just need to
take care one case that x j =

for some j (see Figure 7) and x j = 0, in the discrete sum.

However sin ( 2kx j ) = sin ( k ) = 0 and cos ( ( 2k + 1) x j ) = cos k + = 0 , also


2

sin ( 2k 0 ) = sin ( 2k ) = 0 , cos ( ( 2k + 1) ) = cos ( ) = 1 (this means esin x cos ( ( 2k + 1) x )

n
n
summation, hence Re V2(k +)1 = 0 and Im V2(k )

, 0, does not affect the


2
= 0 hold in discrete sum.

cancels each other at x = 0, ), hence function value at point x j =

10
14
18
22
(O2) V5( ) = V7( ) = V9( ) = V11( ) = 0 up to machine accuracy, in fact they are exact zero, we
would show this and verify this with high precision package. Note this is key point for pair
10
12
phenomenon, we would discuss this later. First let us show why V5( ) = 0 but V5( ) 0 and
10

j
V6(12) 0 . First it is easy to show that V5(10) = h ( 1) v j , where v j = exp ( sin ( hj ) ) . We
j =1

10
would demo V5( ) = 0 is due to (1)

( 1)

v j = exp ( sin ( hj ) ) .

= exp ( i5 x j ) and (2) symmetry of

exp ( i5 x j ) = ( 1)

exp ( sin ( hj ) )
j=3

j=2

j=1

j=4

j=5

j =10

j=6

j=9

j=8

j=7

Figure 8: distribution of v j = exp sin ( hj )

(left panel) and

( 1)

= exp ( i5 x j ) (right panel).

In left panel of Figure 8, we plot distribution of v j = exp ( sin ( hj ) ) , please note the locations
with same color and shape have the same value, that is, v1 = v4 , v2 = v3 , v5 = v10 , v6 = v9 and

v7 = v8 , this is consequence of sin ( x ) = sin ( x ) and we use uniform grid.

exp ( i 6 x j ) = ( 1)

exp ( sin ( hj ) )

j=3

j=4

j=2
j=5

j=1

+
j=6

j =12

j=7

j = 11

In right panel of Figure 8, we plot distribution of

( 1)

j=8
j=9

j = 10

(12 )
Figure 9: no cancellation for V6

10

= exp ( i5 x j ) . From the graph, one can

j
10
10
show cancellation in summation V5( ) = h ( 1) v j , so V5( ) = 0 .
j =1

However when n = 12 ,

5
j , hence no cancellation occurs, that is
exp ( i5 x j ) = exp i
12
0 is result of no cancellation, see Figure 9.

( 1)

V5(12) 0 . Moreover V6(12)

14
18
22
similarly, V7( ) = V9( ) = V11( ) = 0 .

Remark 1: From above argument, (O2) is valid when V ( x ) = V ( x ) , for example,


V = V ( sin ( x ) ) on [ 0, 2 ] . However cos ( x ) is not permitted though cos ( x ) = 1 sin 2 x ,

why? Since in general cos ( x ) = 1 sin 2 x , the sign depends on branch, that is

cos ( x ) cos ( x ) .
8
10
12
14
16
18
20
22
(O3) V4( ) 2V4( ) , V6( ) 2V6( ) , V8( ) 2V8( ) and V10( ) 2V10( ) , although we cannot
interpret this phenomenon, but such fact is also a key to pair phenomenon. Now we explain this.
1
N
First, in chapter 3 (see chap3.doc), we split Vm( ) into 2 parts, (say V(mN ) = Vm( N ) Vm( N ) ), for
2
symmetry inteepolant p ( x ) defined by

pN ( x ) =

(Eq. 4)

m
1
eikxVk( N )
2 k = m

for x [ 0, 2 ] , N = 2m

where (principal value) indicates that the terms k = m are multiplied by

1
.
2

1 (8) (10 )
1 (8)
V4 V4 = 1.413004306399998e-004 .
V4 = 0.01719783356013 and then
2
2
Now we estimate the difference between p8 ( x ) and p10 ( x ) .

Hence

p10 ( x ) p8 ( x ) =

1
2

ikx

(V (

10 )

k =3

1
Vk(8) +
2

k =4

10
However we have shown V5( ) = 0 , so

p10 ( x ) p8 ( x )

(10)

V0

(8)

V0

1
2

V (

k =3

10 )

Vk(8) +

1
2

V (

10 )

k =4

ikx

(10 ) 1 (8) 1
Vk Vk +
2

k =5

1
Vk(8)
2

= 1.255148390555405e-006

V1(10) V1(8) = 1.011760904967574e-005


V2(10) V2(8) = 1.419280048400307e-004
V3(10) V3(8) = 0.00171570157617
1 (8) (10 )
V4 V4 = 1.413004306399998e-004
2

Hence p10 ( x ) p8 ( x ) 6.396994825534096e-004 for any x [ 0, 2 ] .


Further p10 ( x ) p8 ( x ) =

1
2

ike

k =3

ikx

(V (

10 )

1
Vk(8) +
2

ike

k =4

( x ) p8 ( x ) 0.00191185832541 for any x [ 0, 2 ] .


p10
9

ikx

Vk(10 )

ikx

(10 ) 1 (8)
Vk Vk
2

This number is about

1
p8 V
2

I ,

, hence pair phenomenon occurs at n = 8,10 .

Table 5: we copy data from Table 2 and add two new fields, one is errn errn + 2 and the other
is pn ( x ) pn + 2 ( x ) , errn errn + 2 is difference of two value in the field L err , it measure
derivation between pair, for example
err8 err10 = 0.00431791109859 0.00316947217836 = 0.00114843892023
n
n+ 2
pn ( x ) pn + 2 ( x ) measure derivation due to Vk( ) Vk( ) .

n = 8,10

n = 12,14

0.00431791109859

0.38249095565268E-4

0.00316947217836

0.25253568612049E-4

errn errn + 2

0.00114843892023

1.299552695321900e-5

pn ( x ) pn + 2 ( x )

0.00191185832541

1.807600691270616e-5

L err

n = 16,18

n = 20, 22

n = 24, 26

0.17618931913432E-6

0.49879544938847E-9

0.97200025805932E-12

0.10953028789507E-6

0.29827984526776E-9

0.59258153939368E-12

errn errn + 2

6.665903123925001e-8

2.00515604120710e-10

3.794187186656399e-13

pn ( x ) pn + 2 ( x )

8.527607765287214e-8

2.441827585710109e-10

5.089522571307543e-13

L err

From above data, we would find errn errn + 2 pn ( x ) pn + 2 ( x ) , this proves our idea that
pair phenomenon occurs due to 3 reasons
n
n
(1) Re V2(k +)1 = 0 and Im V2(k ) = 0
10
14
18
22
(2) V ( ) = V ( ) = V ( ) = V ( ) = 0
5

11

8
10
12
14
16
18
20
22
(3) V4( ) 2V4( ) , V6( ) 2V6( ) , V8( ) 2V8( ) and V10( ) 2V10( )
(4) From chap3.doc, we have shown

Lemma 1: vk Vk 2 Vk + Np for k = 0,1, 2,

, N 1

p =1

1
Moreover from experimental result for V = exp ( sin ( x ) ) (see below), we found that Vk k ,
k
( n)
( n + 2)
for k = 0,1, 2, , n / 2 can
hence the error between discrete Fourier component vk vk

be neglected.
10

So far, we cannot interpret reason 3.


We try to interpret reason 3.
First note that pair occurs at n = 4k and n = 4k + 2
N
k 1

j
k 1
j
sin hj
sin hj
(4k )

(Eq. 5) v2 k = h ( 1) v j = 2h 1 + ( 1) ( e + 1/ e ) + ( 1) e ( ) + e ( )
2
j =1
j =1

i 2 kx j
ix
v2( 4kk + 2) = h e
v j = h ( 1) e j v j = h ( 1) cos ( x j ) v j

(Eq. 6)

j =1

j =1

j =1

( )(

j
sin ( hj )
sin ( hj )
= 2h 1 + ( 1) cos hj e
+e

j =1

2
where h =
, h=
, then h h =
=
=
2k ( 2k + 1)
4k + 2 2k + 1
4k 2k

4k
4k +2
From our experimental result, v2( k ) 2v2( k ) , this means that we only need to show
k 1

k 1
j
h 1 + ( 1) ( e + 1/ e ) + ( 1) esin ( hj ) + e sin ( hj )
2
j =1

(Eq. 7)

( )(

j
sin ( hj )
sin ( hj )
2h 1 + ( 1) cos hj e
+e

j =1

4k
4k +2
Table 6: List difference between v2( k ) and v2( k ) , define = v2( 4kk ) 2v2( 4kk + 2) , h = h h , we

compare h v2( 4kk ) and to determine if we can neglect difference of h and regard h h .
However result is negative, we CANNOT regard h h .

n = 4k = 8

n = 4k = 12

n = 4k = 16

n = 4k = 20

v2( 4kk )

0.03439566712026

-0.00028260085474

0.00000125168893

-0.00000000345946

v2( 4kk + 2 )

0.01705653312949

-0.00014067458291

0.00000062411474

-0.00000000172646

2.826008612799996e-4

1.251688920000005e-6

3.459450000000128e-9

6.539999999999855e-12

0.15707963267949

0.07479982508547

0.04363323129986

0.02855993321445

0.00540285875702

2.113849450355667e-5

5.461523259816207e-8

9.880194655807041e-11

(4k )
h v2k

Define t1 = ( 1)
k

( )(

s1 = ( 1) cos hj e
j =1

k 1
e k 1
j
k 1
j
+ ( 1) esin ( hj ) , t2 = ( 1)
+ ( 1) e sin ( hj ) ,
2 j =1
2e j =1

( )

sin hj

( )(

and s2 = ( 1) cos hj e
j

j =1

11

( )

sin hj

1 ( 4 k + 2)
v2 k
2k
and then

1 = 2h ( t1 s1 + t2 s2 ) and 2 = 2 h h (1 + s1 + s2 ) =
Then v2( 4kk ) = 2h (1 + t1 + t2 ) , v2( 4kk + 2) = 2h (1 + s1 + s2 )

v2( 4kk ) v2( 4kk + 2) = 1 + 2

n = 4k = 8

n = 4k = 12

n = 4k = 16

n = 4k = 20

v2( 4kk + 2 )

0.01705653312949

-1.4067458291e-4

6.2411474e-7

-1.72646e-9

t1

2.826008612799996e-4

1.251688920000005e-6

3.459450000000128e-9

6.539999999999855e-12

-0.66897406741795

-0.63041950969349

-0.59800207628710

-0.57848539389295

t2

-0.30912897080952

-0.36985035424424

-0.40199633001306

-0.42151461161294

s1

-0.65635567309515

-0.61768932891181

-0.58985808333448

-0.57283605860995

s2

-0.33007116910701

-0.38246739447485

-0.41014102268702

-0.42716394441257

ht1

-0.52541100391058

-0.33008688338879

-0.23483486621187

-0.18173654636631

ht2

-0.24278932592674

-0.19365319263688

-0.15786358964238

-0.13242272072240

-0.41240043214754

-0.27721832255859

-0.20589931347379

-0.16360159576731

-0.20738983200567

-0.17165096524569

-0.14316622486770

-0.12199773724045

0.01307500070840

-1.184805080196554e-4

5.495598519973221e-7

-1.560346593471024e-9

0.00426413328237

-2.344576381762684e-5

7.801434217854332e-8

-1.726463642529372e-10

hs1
hs2

h
, we can rewrite s1 and s2 as
2 2
k 1
j
k
sin ( hj )
cos( h / 2 )
s1 = ( 1) cos hj e
+ ( 1) sin h / 2 e
and

Because hk =

( )(

j =1

k 1

( )(

s2 = ( 1) cos hj e
j

j =1

k 1

( )

sin hj

) + ( 1) sin ( h / 2) e
k

( )(

cos h / 2

j
k e
sin ( hj )
cos( h / 2 )
+ ( 1) s in h / 2 e
t1 s1 = ( 1) esin ( hj ) cos hj e

j =1

( )(

k 1
j
k 1
sin ( hj )
cos( h / 2 )
t2 s2 = ( 1) e sin ( hj ) cos hj e
+ ( 1) sin h / 2 e

2e

j =1
1

4k
4k +2
Then if we want to show v2( k ) 2v2( k ) , it suffices to show 1 1 v2( 4kk + 2 ) .
2k

1 1
4k
+ , then we may regard summation in v2( k ) as sum of
2 2
( 4 k + 2)
Trapezoid rule, so is v2 k , then we rewrite them as

Another view: if we divide 1 =

k 1

k 1

v2( 4kk ) = h ( 1) esin ( hj ) esin ( hj + h ) + h ( 1) e sin ( hj ) e sin ( hj + h )


j =0

j =0

12

Possible solution
e

sin ( x )

=e

sin ( y )

+ cos ( t ) e
x

sin ( t )

Then esin ( hj ) esin ( hj + h ) = h

dt

hj + h

hj

k 1

v2( 4kk ) = h ( 1)
j =0

hj + h

hj

cos ( t ) e

sin ( t )

dt .

k 1

cos ( t ) esin ( t ) dt + h ( 1)

j =0

hj + h

hj

cos ( t ) e sin ( t ) dt

______________________________________________________________________
In this section, we try to find Fourier component of V = exp ( sin ( x ) ) , and decide the decay
rate of Vk numerically since this decay rate determine the accuracy of discrete Fourier
component.
From chapter 3 (see chap3.doc), we know
1 ikx
1 2
2
(Eq. 8) V ( x ) =
e Vk with V L2 =

Vk
2 k =
2 k =
2
Vk = V ( x ) eikx dx

(Eq. 9)

Because V is real, we have V k = Vk and


1 1
1 1
V0 + Re eikxVk =
V0 + cos ( kx ) Re Vk sin ( kx ) Im Vk
2
2
k =1
k =1
Now let V ( x ) = exp ( sin ( x ) ) , then V > 0 , V 1 = V0 and Vk V 1 for all k .

(Eq. 10) V ( x ) =

Re Vk = V ( x ) cos ( kx ) dx = cos ( kx ) esin x dx


2

2
Im Vk = V ( x ) sin ( kx ) dx = sin ( kx ) esin x dx
0

2
L2

= exp ( 2sin ( x ) ) dx = 14.32305687810046


2

2
V0 = exp ( sin ( x ) ) dx = 7.95492652101279
0

2
2
Re V1 = cos ( x ) esin x dx = esin x |02 = 0 and Im V1 = sin ( x ) esin x dx = -3.55099937842440
0

Re V2 = -0.85292776416409 and Im V2 = 0
Prop 1: for k > 2 , then
1
1
(Eq. 11) Re Vk =
Im Vk 1 + Im Vk +1 and Im Vk =
Re Vk 1 + Re Vk +1
2k
2k
<proof> We use integration by parts
2
1
1 2
Re Vk = cos ( kx ) esin x dx = sin ( kx ) esin x |02 sin ( kx ) cos xesin x dx
0
k
k 0
1 2
1 2
= sin ( kx ) cos xesin x dx = sin ( ( k + 1) x ) + sin ( ( k 1) x ) esin x dx
2k 0
k 0
1
Im Vk 1 + Im Vk +1
=
2k

13

2
1
1 2
Im Vk = sin ( kx ) esin x dx = cos ( kx ) esin x |02 cos ( kx ) cos xesin x dx
0
k
k 0
1 2
1 2
= cos ( kx ) cos xesin x dx = cos ( ( k + 1) x ) + cos ( ( k 1) x ) esin x dx
2k 0
k 0
1
Re Vk 1 + Re Vk +1
=
2k
___________________________________________________________________

We can rearrange (Eq. 11) to be


Re Vk +1
Re Vk 1
Im Vk
k
2
=

+
(Eq. 12)

or Vk +1 = Vk 1 + 2k 1Vk

V
V
V
Im
Im
Re

k +1
k 1
k

Remark 2: one can derive (Eq. 12) by


2
1 2
1 2 ikx ix ix sin x
1
Vk = V ( x ) e ikx dx = e ikx cos xesin x dx =
e ( e + e ) e dx =
Vk 1 + Vk +1

0
ik 0
2ik 0
2ik
for example:
V3 = V1 + 4 1V2 = ( 0, 0.13928832176804 ) , V4 = V2 + 6 1V3 = ( 0.01719783355585,0 )

Lemma 2: for V ( x ) = exp ( sin ( x ) ) , we have Im V2 k = 0 and Re V2 k +1 = 0


1 1
1
V0 + cos ( 2kx ) Re V2 k sin ( ( 2k + 1) x ) Im V2 k +1
2
k =1
k =0
<proof> we use induction
induction basis: k = 0 , we have V0 R and Re V1 = 0 , OK
k = 1 , we have Im V = 0 and Re V = 0 , OK

(Eq. 13) V ( x ) =

inductive hypothesis: Assume assertions holds for k = 1, 2, , m


Inductive step, for k = m + 1
From (Eq. 12) we have
Im V2 m = Im V2 m 2 + 2 ( 2m 1) Re V2 m 1 = Im V2( m 1) + 2 ( 2m 1) Re V2( m 1)+1 = 0
Re V2 m +1 = Re V2 m 1 2 2m Im V2 m = Re V2( m 1)+1 4m Im V2 m = 0

last equality comes from inductive hypothesis.


Moreover we use Matlab to verify these two condition, see Figure 10. Even when k 40 , we
still have O (1.E 15) accuracy.
Another proof: we use sin ( x ) = sin ( x ) to show the assertion

sin x

First we claim

sin x

sin ( 2kx ) dx = e sin x sin ( 2kx ) dx + esin x sin ( 2kx ) dx

esin x sin ( 2kx ) dx = 0

sin ( 2kx ) dx =

/ 2 sin x

sin x

/2

Hence

sin ( 2kx ) dx =

/2

sin ( 2kx ) dx +

/2

esin x sin ( 2kx ) dx

esin ( y ) sin ( 2k ( y ) ) dy =

/ 2 sin y

esin x sin ( 2kx ) dx = 0 , the same cancellation holds for

Similarly
14

sin ( 2ky ) dy

e sin x sin ( 2kx ) dx = 0

sin x

cos ( ( 2k + 1) x ) dx = e sin x cos ( ( 2k + 1) x ) dx + esin x cos ( ( 2k + 1) x ) dx

we claim

/2

esin x cos ( ( 2k + 1) x ) dx = 0

esin x cos ( ( 2k + 1) x ) dx =

/2

esin y cos ( ( 2k + 1) y ) dy =

/ 2 sin y

cos ( ( 2k + 1) y ) dy

Figure 10: we verify condition Im V2 k = 0 and Re V2 k +1 = 0 for k = 1:10 by using trapezoid rule
to do integration. It is clear that all data reach machine accuracy.

________________________________________________________________________
From Lemma 2, we can simplify (Eq. 10) as
(Eq. 14) V ( x ) =

1 1
1
V0 + cos ( 2kx ) Re V2 k sin ( ( 2k + 1) x ) Im V2 k +1
2
k =1
k =0

where
Re V2( k 1)
Re V2 k
( 2k 1) Im V2 k 1
+ 2
(Eq. 15)
=

Im V2 k 1 +1
2
Re
k
V
Im V2 k +1

2k

( )

Moreover we can simplify (Eq. 15) further


Re V2 k 1
(Eq. 16)
=
Im V2 k +1 4k

Re V2( k 1)

(1 + 8k ( 2k 1) ) Im V

2( k 1) +1

2 ( 2k 1)

Re V2 1 2 Re V0

=
,

Im V3 4 9 Im V1
Re V4 1 6 Re V2 25 56 Re V0

=
=
, .

Im V5 8 49 Im V3 204 457 Im V1

15

Re V8 351841
788192 Re V0

Im V9 5654440 12667041 Im V1
This recursive formulation is not numerically stable, means that if we want to use this formula
to find all Vk , then rounding error would be disastrous. So we need high precision package to
smooth accumulation error.
________________________________________________________________________
Next we use special technique to find V
0

1 3 5 ( n 1)
if n 2, n is even

246 n 2
n
n
Lemma 3: sin xdx = cos xdx =
0
0
2 4 6 ( n 1) if n 3, n is odd

35 n
<proof> see integral table inside of cover of [1]
/2

/2

/2
V0 = esin x dx = esin x dx = ( esin x + e sin x ) dx = 2 ( esin x + e sin x ) dx , the last equality
0

comes from sin ( x ) = sin ( x ) .

1
x 2 k , then we have
+ e x = 2 1 +
k =1 ( 2k ) !

/2
/2
1
2k
sin 2 k ( x ) dx = 4 +
sin
V0 = 4 1 +
x
dx
(
)

k =1 ( 2k )!

2 k =1 ( 2k )! 0
0

/2
1 3 5 ( 2k 1)
( 2k ) !
( 2k ) !
where sin 2 k ( x ) dx =
=
=
k
2
0
2 4 6 ( 2 k ) 2 2 ( 2 4 6 ( 2k ) )
2 2k k ! 2 2

Using power series

(e

k
1

= 2 1 +
2 1 + ak
Hence V0 = 2 1 +
2
k =1 ( 2k ) !
k
k =1 2 k !
k =1

Note that ak =

( 2 k !) ( 2k 2 ( k 1)!) ( 2k )
k

k 1

ak 1
N

Then we use following code to compute partial sum

a
k =1

ak := 1 , sum := 0
for k = 1: N
1
ak ak
; sum+ = ak
2
( 2k )
end

1
Prop 2: If V = esin x , then V0 = 2 1 + ak where ak =
and
2
k
k =1
k
2
!
( )

16

k=N

e
4 N ( N !)

ak =

<proof>

k=N

m=0

( 2 ( N + m )!)
N +m

4 N ( N !)

We use

( 2 ( N + 1)( N + 2 ) ( N + m ) )
m

m=0

( 2 ( N + 1)( N + 2) ( N + m ) )
m

1
1
and e =
.
m!
m =0 m !

<

N = 10

N = 15

N = 20

N = 25

N = 30

N = 40

N = 50

10 16

10 42

10 60

10 80

10 100

10 142

10 184

e
4

( N !)

N = 100

N = 200

N = 300

N = 400

N = 500

10 375

10 869

10 1409

10 1978

10 2568

e
4

( N !)

Prop 3: If V = esin x , then Im V1 = 2 ak where ak =


k =1

2
<proof> Im V1 = sin ( x ) esin x dx , it suffices to show

(1) check
(2)
(3)

k=N

2e

( N !)

sin ( x ) esin x dx = 2 ak .
k =1

sin ( x ) ( esin x e sin x ) dx

1
x 2 k +1
k =1 ( 2k + 1) !

2
1
1
( 2k ) !
2k
sin
4
=
x
dx
(
)

2
0
k
k =1 ( 2k 1) !
k =1 ( 2k 1) ! 2 2 k !

sin ( x ) esin x dx = 4
2k

( 2 k !)
k

ak =

k=N

sin ( x ) esin x dx = 2

/2

and

e x e x = x +

(4) ak =

( 2 k !)

2k

m=0

1
ak 1
4k ( k 1)

2 ( N + m)

( 2 ( N + m )!)
N +m

=
4

( N !)

m=0

( 2 ( N + 1)( N + 2 ) ( N + m 1) ) ( N + m )
2

Then we use following code to compute partial sum

a
k =1

ak := 0.5 , sum := 0.5


for k = 2 : N
1
; sum+ = ak
ak ak
4k ( k 1)
end
Next we use high precision package to compute V0 and ImV1 up to 128 digits, note that we

17

use N 42 to stabilize partial sum

a
k =1

V0 = 7.9549265210128452 7451321966532939 4328161342771816 6385734005959553


8336060816469466 6995137357228568 7741332170437587 4113888148503023e0
ImV1 = -3.5509993784243618 9375715307444414 5068885827761984
4655200625893475 7625209545877072 0368124285904632 7616425367512080
1404294198552668e0
Table 7: We use high precision package with 1000 digits to compute Vk and estimate
1
convergence order of Vk , defined by Vk = m( k ) .
k
Source code: F:\course\2008spring\spectral_method\cxx_example\chap1

m(k )

m(k )

ReV(0) = 7.9549265210128453e0

ImV(1) = -3.5509993784243619e0

ReV(2) = -8.5292776416412149e-1

ImV(3) = 1.3928832176787595e-1

ReV(4) = 1.7197833556865812e-2

ImV(5) = -1.7056533129494463e-3

ReV(6) = -1.4130042737134921e-4

4.94744

ImV(7) = 1.0048184493255820e-5

5.914

ReV(8) = 6.2584446576772422e-7

6.86923

ImV(9) = -3.4673040972232835e-8

7.81773

ReV(10) = -1.7297282675331887e-9

8.76202

ImV(11) = 7.8475621569060340e-11

9.70361

ReV(12) = 3.2645930138612418e-12

10.6434

ImV(13) = -1.2538923639053624e-13

11.582

ReV(14) = -4.4728677072995018e-15

12.5199

ImV(15) = 1.4894058615019287e-16

13.4573

ReV(16) = 4.6501227937157073e-18

14.3944

ImV(17) = -1.3665675129023628e-19

15.3313

ReV(18) = -3.7932498476738764e-21

16.2682

ImV(19) = 9.9756773976728090e-23

17.2051

ReV(20) = 2.4924365582089317e-24

18.1421

ImV(21) = -5.9311648370821361e-26

19.0792

ReV(22) = -1.3473266344345731e-27

20.0164

ImV(23) = 2.9276455700143845e-29

20.9539

ReV(24) = 6.0967222795625615e-31

21.8915

ImV(25) = -1.2188758243549561e-32

22.8293

ReV(26) = -2.3431577877807459e-34

23.7674

ImV(27) = 4.3377470896829986e-36

24.7056

ReV(28) = 7.7435935192659899e-38

25.6441

ImV(29) = -1.3347188940443096e-39

26.5828

ReV(30) = -2.2239338089943938e-41

27.5217

ImV(31) = 3.5860864767329276e-43

28.4608

ReV(32) = 5.6019341997869982e-45

29.4002

ImV(33) = -8.4858886924868411e-47

30.3397

ReV(34) = -1.2476627456831309e-48

31.2795

ImV(35) = 1.7820218415512617e-50

32.2195

ReV(36) = 2.4745659724766378e-52

33.1597

ImV(37) = -3.3434136808250048e-54

34.1001

ReV(38) = -4.3984866613426193e-56

35.0407

ImV(39) = 5.6381820461407180e-58

35.9815

ReV(40) = 7.0466535285927712e-60

36.9225

ImV(41) = -8.5922326650106772e-62

37.8637

ReV(42) = -1.0227432840158852e-63

38.805

ImV(43) = 1.1890792772412452e-65

39.7466

ReV(44) = 1.3510558841438762e-67

40.6883

ImV(45) = -1.5009919463409708e-69

41.6302

ReV(46) = -1.6313243700245210e-71

42.5723

ImV(47) = 1.7352591841154628e-73

43.5146

18

ReV(48) = 1.8073695598597204e-75

44.457

ImV(49) = -1.8440665013114252e-77

45.3996

ReV(50) = -1.8438857452372014e-79

46.3424

ImV(51) = 1.8075607422380681e-81

47.2853

ReV(52) = 1.7378815437191885e-83

48.2283

ImV(53) = -1.6393677011213502e-85

49.1716

ReV(54) = -1.5178053055730738e-87

50.1149

ImV(55) = 1.3797110243049970e-89

51.0584

ReV(56) = 1.2317883757703079e-91

52.0021

ImV(57) = -1.0804344225222833e-93

52.9459

ReV(58) = -9.3134094904861371e-96

53.8899

ImV(59) = 7.8921625891422459e-98

54.8339

ReV(60) = 6.5763529828695323e-100

55.7782

ImV(61) = -5.3900969880710571e-102

56.7225

ReV(62) = -4.3465742284267052e-104

57.667

ImV(63) = 3.4494482194268623e-106

58.6116

ReV(64) = 2.6947194885863902e-108

59.5563

ImV(65) = -2.0727403628291311e-110

60.5012

ReV(66) = -1.5701690851976058e-112

61.4462

ImV(67) = 1.1717036829142283e-114

62.3913

ReV(68) = 8.6150092539842003e-117

63.3365

ImV(69) = -6.2424372377078596e-119

64.2819

ReV(70) = -4.4586594735415350e-121

65.2273

ImV(71) = 3.1397474971062253e-123

66.1729

ReV(72) = 2.1802765069509171e-125

67.1186

ImV(73) = -1.4932709690467884e-127

68.0644

ReV(74) = -1.0089214260595890e-129

69.0102

ImV(75) = 6.7258478596712626e-132

69.9562

ReV(76) = 4.4247108899611723e-134

70.9024

ImV(77) = -2.8730693028074481e-136

71.8486

ReV(78) = -1.8416363770214422e-138

72.7949

ImV(79) = 1.1655465399828615e-140

73.7413

ReV(80) = 7.2843848521037795e-143

74.6878

ImV(81) = -4.4963646256784895e-145

75.6344

ReV(82) = -2.7415850462649380e-147

76.5811

ImV(83) = 1.6514980399108078e-149

77.5279

ReV(84) = 9.8300012997093223e-152

78.4748

ImV(85) = -5.7821559641664032e-154

79.4218

ReV(86) = -3.3616062643676250e-156

80.3689

ImV(87) = 1.9318945408827106e-158

81.316

ReV(88) = 1.0976323170853944e-160

82.2633

ImV(89) = -6.1662812416461892e-163

83.2106

ReV(90) = -3.4256072372713951e-165

84.1581

ImV(91) = 1.8821455767799992e-167

85.1056

ReV(92) = 1.0228753179651741e-169

86.0532

ImV(93) = -5.4991724078868826e-172

87.0009

ReV(94) = -2.9250098213943509e-174

87.9486

ImV(95) = 1.5394366550286099e-176

88.8965

ReV(96) = 8.0176839992052904e-179

89.8444

ImV(97) = -4.1327181194190573e-181

90.7924

ReV(98) = -2.1084753231915019e-183

91.7405

ImV(99) = 1.0648596371350890e-185

92.6886

ReV(100) = 5.3241664025762733e-188

93.6369

ImV(101) = -2.6356619834325278e-190

94.5852

ReV(102) = -1.2919604256718823e-192

95.5336

ImV(103) = 6.2715061887867499e-195

96.482

ReV(104) = 3.0150781811827308e-197

97.4306

ImV(105) = -1.4357192666992787e-199

98.3792

ReV(106) = -6.7721114245441988e-202

99.3278

ImV(107) = 3.1644695908567913e-204

100.277

ReV(108) = 1.4650011066538491e-206

101.225

ImV(109) = -6.7200484477269938e-209

102.174

ReV(110) = -3.0545049364460404e-211

103.123

ImV(111) = 1.3758754570485746e-213

104.072

ReV(112) = 6.1421798204873893e-216

105.021

ImV(113) = -2.7177259399354918e-218

105.971

ReV(114) = -1.1919623317795924e-220

106.92

ImV(115) = 5.1823478021086980e-223

107.869

ReV(116) = 2.2337294591867709e-225

108.818

ImV(117) = -9.5456795389410712e-228

109.768

ReV(118) = -4.0447074560274482e-230

110.717

ImV(119) = 1.6994271629333847e-232

111.667

ReV(120) = 7.0808245992629515e-235

112.616

ImV(121) = -2.9259110276340004e-237

113.566

ReV(122) = -1.1991238867047224e-239

114.516

ImV(123) = 4.8744074477763628e-242

115.466

19

ReV(124) = 1.9654551737166463e-244

116.415

ImV(125) = -7.8616959079921701e-247

117.365

ReV(126) = -3.1196718603786482e-249

118.315

ImV(127) = 1.2281983797660650e-251

119.265

ReV(128) = 4.7975772843065435e-254

120.215

ImV(129) = -1.8594983589878912e-256

121.165

ReV(130) = -7.1518117784269494e-259

122.116

ImV(131) = 2.7296596884347195e-261

123.066

ReV(132) = 1.0339472798414659e-263

124.016

ImV(133) = -3.8869653249621741e-266

124.967

ReV(134) = -1.4503401527580714e-268

125.917

ImV(135) = 5.3715570542648909e-271

126.867

ReV(136) = 1.9748106550868906e-273

127.818

ImV(137) = -7.2072428548484198e-276

128.768

ReV(138) = -2.6112858423585874e-278

129.719

ImV(139) = 9.3929938718587938e-281

130.67

ReV(140) = 3.3545981842720248e-283

131.62

ImV(141) = -1.1895589712441229e-285

132.571

ReV(142) = -4.1885363598235693e-288

133.522

ImV(143) = 1.4645054229194620e-290

134.473

ReV(144) = 5.0850273907962369e-293

135.424

ImV(145) = -1.7534370145803019e-295

136.375

ReV(146) = -6.0048513361321557e-298

137.326

ImV(147) = 2.0424429712458045e-300

138.277

ReV(148) = 6.9000669490463556e-303

139.228

ImV(149) = -2.3154328083236962e-305

140.179

ReV(150) = -7.7180241741020677e-308

141.13

ImV(151) = 2.5556093075861283e-310

142.082

From the experimental result, we found m ( k ) k , see Figure 11. Hence we expect that

1
1
1
Vk = m( k ) k .
k
k!
k

Figure 11: decay rate of Vk =

This is reasonable since we know from chap3.doc


If V (

k)

is periodic with period 2 for k = 0,1, 2,

2
(Eq. 17) Vk = V ( x ) e ikx dx =
0

( ik )
m

V ( m ) e ikx dx

Reference
[1] Finney, Weirm, Giordano, Thomass Calculus

20

, m , then

1
k

m( k )

You might also like