tma4212numericalsolutionofdifferentialequationsbydifferencem ... ·...

12
TMA4212 Numerical Solution of Differential Equations by Difference Methods NONLINEAR SCHRÖDINGER EQUATION Group 6 — Candidates 10028, 10037 and 10055 Department of Mathematical Sciences Norwegian University of Science and Technology April 26, 2013 Abstract In this project we consider four finite difference schemes for the periodic one-dimensional cubic nonlinear Schrödinger equation: The Crank Nicolson method, a linearized Crank-Nicolson method, an explicit Dufort-Frankel type method, and at last a relaxation scheme by Besse. Results from several numerical experiments are given, and we investigate a conserved quantity. Contents 1. Introduction 2 2. Discretization 3 2.1. Crank–Nicolson method ............................ 3 2.2. Linearized Crank–Nicolson method ....................... 4 2.3. Du Fort-Frankel type method .......................... 5 2.4. Besse relaxation scheme ............................ 5 3. Stability analysis for the Crank-Nicolson method 6 4. Implementation and optimization in MATLAB 7 5. Numerical experiments 8 5.1. Example 1 ................................... 8 5.2. Example 2 ................................... 10 5.3. Example 3 ................................... 10 5.4. A conserved quantity .............................. 11 6. Conclusion 12 References 12 1 of 12

Upload: others

Post on 17-Mar-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

TMA4212 Numerical Solution of Differential Equations by Difference Methods

NONLINEAR SCHRÖDINGER EQUATION

Group 6 — Candidates 10028, 10037 and 10055

Department of Mathematical SciencesNorwegian University of Science and Technology

April 26, 2013

AbstractIn this project we consider four finite difference schemes for the periodicone-dimensional cubic nonlinear Schrödinger equation: The Crank Nicolsonmethod, a linearized Crank-Nicolson method, an explicit Dufort-Frankel typemethod, and at last a relaxation scheme by Besse. Results from severalnumerical experiments are given, and we investigate a conserved quantity.

Contents

1. Introduction 2

2. Discretization 32.1. Crank–Nicolson method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2. Linearized Crank–Nicolson method . . . . . . . . . . . . . . . . . . . . . . . 42.3. Du Fort-Frankel type method . . . . . . . . . . . . . . . . . . . . . . . . . . 52.4. Besse relaxation scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3. Stability analysis for the Crank-Nicolson method 6

4. Implementation and optimization in MATLAB 7

5. Numerical experiments 85.1. Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85.2. Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105.3. Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105.4. A conserved quantity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

6. Conclusion 12

References 12

1 of 12

Page 2: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

2 of 12 Nonlinear Schrödinger Equation

1. Introduction

The one-dimensional cubic nonlinear Schrödinger equation reads{i∂tu+ ∂2xu = λ|u|2u,

u(x, t0) = f(x),(x, t) ∈ T× R, (1)

where u is a complex-valued function and λ ∈ R is a constant. The circle group T, which isisomorphic to R/pZ, defines periodic boundary conditions with period p 6= 0, and mainly wechoose to use p = 2 and work on the interval [−π, π].

−3

−2

−1

0

1

2

3

−1

−0.5

0

0.5

1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

x

Re u

t

Figure 1: The real part of a plane wavesolution with parameters λ = 1, A = 1,B = 1 and C = 2 on the time intervalt ∈ [−1, 1].

Equation (1) arises frequently in mathematicalphysics, and occurs for example in the modeling ofdeep water waves in hydrodynamics and the propaga-tion of pulses in nonlinear optics. The parameter λ de-scribes either a focusing (λ < 0) or defocusing (λ > 0)effect of the nonlinearity.

It is shown in [3] that there exists an infinite num-ber of solutions of (1), and in fact this result holds forany given period. Furthermore, one can establish that(1) has analytic plane wave solutions of the form

u(x, t) = A exp[i(Bx− (A2λ+B2)t+ C

)], (2)

where A,C ∈ R and B ∈ Z are arbitrary constants,and Figure 1 shows an example of these.

−8−6

−4−2

02

46

8

−5

0

5

0

0.5

1

1.5

x

|u|

t

Figure 2: The absolute value of (3) on the intervals x ∈ [−3π, 3π] and t ∈ [−5, 5].

Page 3: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

Group 6 — Candidates 10028, 10037 and 10055 3 of 12

More interestingly are the well-known soliton solutions of the nonlinear cubic Schrödingerequation, but we have not been able to find any literature on explicit solutions for the generalperiodic case. However, [6] mentions the bi-soliton solution

u(x, t) = 4eit(1 + 2it) coshx− x sinhx1 + 2x2 + 8t2 + cosh(2x)

(3)

for the case λ = −2, which might be combined to give a spatial periodic solution. To obtainthis, one has to glue together many copies of the solution shown in Figure 2.

Furthermore, it is known that (1) has an infinite number of invariants, and especially onecan show that the mass

M [u] =

∫T|u(x, t)|2 dx (4)

is a conserved quantity.

2. Discretization

To begin discretization, we introduce a rectangular mesh with nodes (xm, tn) = (−π +mh, nk)

for m = 0, . . . ,M + 1 and n ∈ Z, where the spatial and temporal stepsizes are h = 2π/(M + 1)

and k, respectively. We denote by unm the exact solution of (1) at the mesh point (xm, tn), withUnm correspondingly the numerical approximation to unm, and U n = (Un0 , U

n1 , . . . , U

nM ). Note

that by the periodicity of the problem Un0 = UnM+1, and hence we skip this component in U n.

Many finite difference schemes of (1) have been developed, and we thought it interestinglyto implement and compare some of them. First we will start by looking at the Crank-Nicolsonscheme, and next obtain a linearized version by treating the nonlinear term as in [2]. Afterwards,the so-called Du Fort-Frankel type explicit method is presented, and at last we consider the Besserelaxation scheme.

2.1. Crank–Nicolson method

Let un+ 1

2m = u(xm, tn +

12k). By writing (1) in the form ∂tu = i∂2xu− iλ|u|2u, we obtain by using

the trapezoidal rule in time and central differences in space that

un+1m = unm +

1

2k(∂tu

nm + ∂tu

n+1m

)− 1

12k3∂3t u

n+ 12

m +O(k4)

= unm +1

2k[(i∂2xu

nm − iλ|unm|2unm

)+(i∂2xu

n+1m − iλ|un+1

m |2un+1m

)]− 1

12k3∂3t u

n+ 12

m +O(k4)

= unm +1

2ik

[(1

h2δ2xu

nm +

1

h2δ2xu

n+1m

)−(

1

12h2∂4xu

nm +

1

12h2∂4xu

n+1m +O(h4)

)]− 1

2ikλ(|unm|2unm + |un+1

m |2un+1m

)− 1

12k3∂3t u

n+ 12

m +O(k4).

Setting r = k/h2 we end up with

un+1m = unm +

ir

2

(δ2xu

nm + δ2xu

n+1m

)− ikλ

2

(|unm|2unm + |un+1

m |2un+1m

)+ τ̃nm, (5)

τ̃nm = − 1

12k3∂3t u

n+ 12

m − 1

12ikh2∂4xu

n+ 12

m +O(k4 + k3h2 + kh4),

Page 4: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

4 of 12 Nonlinear Schrödinger Equation

where it is used that 12

(∂4xu

nm + ∂4xu

n+1m

)= ∂4xu

n+ 12

m +O(k2). Disregarding τ̃nm in (5) gives thegeneral Crank-Nicolson method:

Un+1m = Unm +

ir

2

(δ2xU

nm + δ2xU

n+1m

)− ikλ

2

(|Unm|2Unm + |Un+1

m |2Un+1m

),

or written out:

rUn+1m−1 + 2(i− r)Un+1

m + rUn+1m+1 = −rU

nm−1 + 2(i + r)Unm − rUnm+1

+ kλ(|Unm|2Unm + |Un+1

m |2Un+1m

).

(6)

This results in a nonlinear system

A+Un+1 = A−U

n + kλ(|U n+1|.2 ?U n+1 + |U n|.2 ?U n), (7)

where

A± = ±r

2(± ir − 1) 1 1

1 2(± ir − 1) 1. . . . . . . . .

1

1 1 2(± ir − 1)

is a symmetric cyclic tridiagonal matrix of dimension (M + 1)× (M + 1). Moreover, we let ? de-note componentwise vector multiplication, and similarly define |U n+1|.2 = (|Un+1

0 |2, . . . , |Un+1M |2).

The local truncation error is

τnm =1

kτ̃nm = − 1

12k2∂3t u

n+ 12

m − 1

12ih2∂4xu

n+ 12

m +O(k3 + k2h2 + h4) = O(k2 + h2),

and thus the method is consistent. Its stability is shown in Section 3.

2.2. Linearized Crank–Nicolson method

As suggested in [2], a linearized version of the Crank-Nicolson scheme can be found by expandingthe last nonlinear term in (5) as follows:

|un+1m |2un+1

m = |unm|2unm + k∂t(|unm|2unm

)+O(k2)

= |unm|2unm + 2k|unm|unm∂t|unm|+ k|unm|2∂tunm +O(k2).

In order to avoid any (n+ 1)th time-level terms on the right-hand side, it is natural to approx-imate the temporal derivative using a backward difference:

∂t|unm| =1

k

(|unm| − |un−1m |

)+O(k) and ∂tu

nm =

1

k

(unm − un−1m

)+O(k).

Hence we end up with

|un+1m |2un+1

m = 4|unm|2unm − 2unm|unm||un−1m | − |unm|2un−1m +O(k2).

Page 5: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

Group 6 — Candidates 10028, 10037 and 10055 5 of 12

Inserting this into (5), writing out the spatial central difference operators and neglecting thelocal truncation error gives a linearized version of the Crank-Nicolson method:

rUn+1m−1 + 2(i− r)Un+1

m + rUn+1m+1 = −rU

nm−1 + 2(i + r)Unm − rUnm+1

+ kλ(5|Unm|2Unm − 2|Unm|Unm|Un−1m | − |Unm|2Un−1m

),

or

A+Un+1 = A−U

n + kλ(5|U n|.2 ?U n − 2|U n| ?U n ? |U n−1| − |U n|.2 ?U n−1) , (8)

similarly as in (7). The solution of the first time-layer is found via the ordinary Crank-Nicolsonscheme. Furthermore, after summing up the terms we have τnm = O(k2 + h2) as before.

2.3. Du Fort-Frankel type method

Another scheme is the so-called three-level explicit DuFort-Frankel method. As explained in[10], the discretization of (1) reads

iUn+1m − Un−1m

2k= −

Unm+1 − Un+1m − Un−1m + Unm−1

h2+ λ|Unm|2

Un+1m + Un−1m

2,

which leads to

Un+1m =

(1 + i(r + kλ|Unm|2)

)−1 [Un−1m

(1− i(r + kλ|Unm|2)

)+ ir

(Unm+1 + Unm−1

)], (9)

where r = 2k/h2. Similarly as for the linearized Crank-Nicolson scheme, the solution of the initialtemporal step is found via the ordinary Crank-Nicolson scheme. One can show [5] that the localtruncation error is of order O(k2 + h2 + (k/h)2), and hence we need k/h→ 0 for consistency.

2.4. Besse relaxation scheme

The last method we have studied is known as the Besse relaxation scheme [1]. Its key idea is toreplace (1) with a system of two equations{

v = |u|2,

i∂tu+ ∂2xu = λvu,(x, t) ∈ T× R≥0, (10)

with u(x, 0) = f(x) as before. Now define tn+ 12= tn +

12k and let V

n+ 12

m be an approximation ofv at the point (xm, tn+ 1

2). Then Besse suggests the following finite difference scheme for (10):

Vn+ 1

2m + V

n− 12

m

2= |Unm|2,

iUn+1m − Unm

k+

1

h2δ2x

(Un+1m + Unm

2

)= λ

(Un+1m + Unm

2

)Vn+ 1

2m ,

which can written as the coupled system{V n+ 1

2 = −V n− 12 + 2|U n|.2,

A+nU

n+1 = A−nUn,

(11)

Page 6: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

6 of 12 Nonlinear Schrödinger Equation

with V n± 12 = (V

n± 12

0 , . . . , Vn± 1

2M+1). Here

A±n = ±r

α±0 1 1

1 α±1 1. . . . . . . . .

1

1 1 α±M

(12)

is a symmetric cyclic tridiagonal matrix, α±m = ±(i/r)− 2− λh2V n+ 12

m and r = k/2h2. Further-more, Besse proposes to setU 0 = (f(x0), . . . , f(xM+1)) andV −

12 = |U 0|.2 for the first temporal

step.

Our discretization gives order two in space, and the scheme is proven to be convergent in[1], with indications that the order of convergence equals two in time. An advantage with theBesse relaxation method is that we do not have to solve a nonlinear system.

3. Stability analysis for the Crank-Nicolson method

We now show stability for the Crank-Nicolson scheme using a von Neumann analysis technique.First, for notation, define

U (n)max = max

m=0,...,M+1

{|Unm|2, |Un+1

m |2}. (13)

Furthermore, let Unm = ξneimhβ , with ξ > 0. From (6) we then have∣∣∣ξn+1eimhβ(re−ihβ + 2(i− r) + reihβ

)∣∣∣≤∣∣∣∣−ξneimhβ (re−ihβ − 2(i + r) + reihβ

)+ kλ

∣∣∣ξneimhβ∣∣∣2 ξneimhβ∣∣∣∣+

∣∣∣∣kλ ∣∣∣ξn+1eimhβ∣∣∣2 ξn+1eimhβ

∣∣∣∣≤∣∣∣ξneimhβ (re−ihβ − 2(i + r) + reihβ

)− kλU (n)

maxξneimhβ

∣∣∣+ ∣∣∣kλU (n)maxξ

n+1eimhβ∣∣∣ .

(14)

After dividing by ξneimhβ and rearranging the terms we obtain

|ξ|(|2i− 2r + 2r cos(βh)| −

∣∣∣kU (n)maxλ

∣∣∣) ≤ ∣∣∣−2i− 2r + 2r cos(βh)− kU (n)maxλ

∣∣∣ . (15)

By a triangle inequality |a| − |b| ≤ |a− b|, we also have that(|2i− 2r + 2r cos(βh)| −

∣∣∣kU (n)maxλ

∣∣∣) ≤ ∣∣∣2i− 2r + 2r cos(βh)− kU (n)maxλ

∣∣∣ . (16)

Combining (15) and (16) we see that in order for them both to hold we need |ξ| ≤ 1. Thus, fromthe von Neumann’s stability criterion we have proven that the Crank-Nicolson scheme is uncon-ditionally stable for the nonlinear Schrödinger equation. Since the method also is consistent,Lax’ equivalence theorem states that the method is convergent. Hence, we have proven that theCrank-Nicolson scheme is both convergent and stable for the nonlinear Schrödinger equation.

Page 7: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

Group 6 — Candidates 10028, 10037 and 10055 7 of 12

4. Implementation and optimization in MATLAB

The four difference schemes are divided into separate functions in MATLAB, and then called froma main script. The implementations can handle different equation parameters and grid sizeseffectively, and thus can be applied on similar problems as well.

In general, the numerical solution is stored as a matrix, with rows corresponding to temporalsolutions. When the system of equations is big, the values of the solutions are preferably writtento a file as they are computed. In this way one does not have to store the values at each step,and will therefore be able to save a lot of memory. We have not done this in our case. Since oursystem is not that big, we do not consider it to be appropriate. To store all the values of thesolutions as they are computed also makes the plotting much easier.

Moreover, by the periodicity of the problem, we drop the last spatial component to avoidunnecessary computations. When it comes to the Besse relaxation scheme, the Crank-Nicolsonmethod and its linearized version, the matrices A± and A±n are implemented in sparse tridiagonalform using the efficient command gallery('tridiag') with suitable parameters. For the Besserelaxation scheme (11), we update only the diagonals of the matrices A±n once every time stepin order to use less resources.

To solve the nonlinear system (7) for the Crank-Nicolson scheme, we first implemented asimple version using MATLABs fsolve function. However, this is slow and restricts the grid sizeheavily, and we instead develop a Newton-Raphson method as follows: From (7) define

F (U n+1) = A+Un+1 −A−U n − kλ(|U n+1|.2 ?U n+1 + |U n|.2 ?U n).

We then want to solve F (U n+1) = 0 . The Jacobian of F equals

DF (U n+1) = A+ − kλ diag(2|U n+1| ?U n+1 + |U n+1|.2

),

and the Newton-Raphson iteration scheme takes the form

DF (U n+1(j) )

(U n+1

(j+1) −U n+1(j)

)= −F (U n+1

(j) ). (17)

Since both the Jacobian of F and the matrices A±n in the Besse relaxation scheme aresymmetric cyclic tridiagonal, we could have used a factorization technique, called Temperton’salgorithm 4, as described in [8]. The idea is to obtain the first unknown value U0, and then geta simplified tridiagonal system which can be solved efficiently with methods like the Thomasalgorithm [9] or an LU factorization. By using this method, the number of operations areexpected to decrease from O(M3) to O(M). The last part of DF is implemented with spdiags.

As a stopping criterion for (17) , we check whether ‖U n+1(j+1) −U n+1

(j) ‖∞ is less than a giventolerance, and the starting point is chosen to be the solution of the previous temporal step.We use a tolerance equal to 1× 10−15. This is very close to the machine epsilon, and fromnumerical experiments, we observe that avoiding a tolerance equal to the machine precisiongives convergence in normally less than 20 iterations.

At last, with the exception of the linearized Crank-Nicolson scheme which need no updatein its matrices, no inverses are computed, and we use the fast mrdivide function for increasedspeed. Furthermore, we precompute constants and avoid repeated evaluations where possible.

Page 8: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

8 of 12 Nonlinear Schrödinger Equation

5. Numerical experiments

In this section we present three numerical examples for the nonlinear Schrödinger equation (1)with estimation of runtimes and some error analysis. Moreover, the conservation of a discreteanalog of (4) is considered.

5.1. Example 1

Scheme M ×N Runtime

Crank-Nicolson 400× 400 20

Linearized Crank-Nicolson 400× 400 0.33

Du Fort-Frankel 400× 25000 2.3

Besse relaxation 400× 400 0.33

Table 1: Comparison of runtime for four schemes for exam-ple 1. Runtimes are given in seconds.

We now look at the interval t ∈ [0, 5]

and x ∈ [−π, π]. The initial func-tion f(x) = exp (ix) is chosen, whichcorresponds to the analytical solu-tion given in (2) with λ = 1, A = 1,B = 1 and C = 0. A comparisonof the runtime for our four differentschemes is given Table 1. In order toanalyze the runtimes for the differ-ent schemes we choose equal grid sizes for three of our methods. The Du Fort-Frankel methodrequires k � h, and hence we need a finer grid to ensure a similar error.

As expected, the Crank-Nicolson scheme is by far the slowest method, since it requires solvinga nonlinear system at each stage. Moreover we observe that the linearized Crank-Nicolson versionand the Besse relaxation scheme run at almost equal speed. At last we note that although theDu Fort-Frankel method is only conditionally stable, our implementation is quite efficient andcan handle large values for N without problems.

−2

0

2

0

2

4

6

0

2

4

6

8

x 10−4

x

Crank-Nicolson

t −2

0

2

0

2

4

6

0

0.5

1

1.5

x 10−3

x

Linearized Crank-Nicolson

t −2

0

2

0

2

4

6

0

1

2

3

4

x 10−3

x

Du Fort-Frankel

t −2

0

2

0

2

4

6

0

2

4

6

8

x 10−4

x

Besse relaxation

t

Figure 3: Plots showing the absolute error between the analytic -and numerical solution in Example 1for the four difference schemes.

Let the absolute error be defined as enm = |u(xm, tn)− Unm| at each point in the grid. Chang-ing M and N , we can see how enm evolves. In Figure 3 is shown the absolute error betweenthe analytic -and numerical solution for the four difference schemes with grid sizes as in Table1. All methods display a very similar behaviour, but the Crank-Nicolson -and Besse relaxationschemes give the lowest global error. For speed then, the Besse relaxation scheme may be thepreferred one.

Page 9: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

Group 6 — Candidates 10028, 10037 and 10055 9 of 12

h−1

log(

‖u(·,tN)−

UN‖ ∞

‖u(·,tN)‖

)

100 101 102 103 10410−6

10−5

10−4

10−3

10−2

10−1

100

101

102

k−1

log(

‖u(0,·)−

U0‖ ∞

‖u(0,·)‖

)

100 101 102 103 10410−6

10−5

10−4

10−3

10−2

10−1

100

101

102

Crank-NicolsonLin. Crank-NicolsonBesse relaxationO(k2)

Crank-NicolsonLin. Crank-NicolsonDu Fort-FrankelBesse relaxationO(h2)

Figure 4: Verification of order of the error for the four difference schemes using log-log plots.

Furthermore, we also want to verify the order of the local truncation error τnm for the differentschemes. For verification of spatial order, we use a fine grid in time with N = 5000 for boththe Crank-Nicolson schemes and the Besse relaxation method, but N = 100 000 for the DuFort-Frankel type algorithm. We plot the relative error

log

(‖u(·, tN )−UN‖∞‖u(·, tN )‖∞

)against h−1 for the last time step tN , where u(·, tN ) denotes a vector containing the exactsolution in space evaluated in the grid points at time tN . Similarly we check the temporal orderwithM = 5000 for all the difference schemes, with the exception of the Du Fort-Frankel method.It is possible to verify this also for this one by eliminating spatial order. However, this is beyondthe scope of this project. The relative error

log

(‖u(0, ·)−U 0‖∞‖|u(0, ·)‖∞

)is plotted against k−1, where U 0 denotes the numerical solution in time at x = 0.

In Figure 4 the results are shown using the analytic solution mentioned earlier in Example1. The different lines are shifted somewhat in order to get a better feeling for the slopes. As wecan see, all methods seem to achieve second order in both space and time, with the exception ofthe Du Fort-Frankel type method. In space the order is 2, but even though we use a very smalltemporal step size, the spatial step size eventually catches up. Thus, since it is only conditionallystable, we see the curvature at the end.

Numerical tests have shown that if |λ| is too big, the waves will be too close and our numericalroutine will require an extremely fine grid. We experienced that the Besse relaxation schemeperformed sligthly better than the other schemes, but it will also "fail" if |λ| is big enough. Theother schemes will eventually have waves shifted from the analytical solution.

We experienced that the focusing case λ < 0 in general resulted in larger run times.

Page 10: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

10 of 12 Nonlinear Schrödinger Equation

5.2. Example 2

We now choose the initial function f(x) = sin(x) with t ∈ [0, 5], x ∈ [−π, π] and λ = −2.In figure 5 is shown both the real and imaginary part of the numerical solution using Besserelaxation scheme using M = 500 and N = 1000. Interestingly, the solution is also periodic intime, and moreover, the real and imaginary part of the solution are equal except for a temporaltranslation.

−2

0

2

0

1

2

3

4

5

−1

−0.5

0

0.5

1

x

Re u

t−2

0

2

0

1

2

3

4

5

−1

−0.5

0

0.5

1

x

Im u

t

Figure 5: Real and imaginary part of the numerical solution with f(x) = sin(x) and λ = −2.

5.3. Example 3

−10

−5

0

5

10

−5

0

5

0

2

4

6

x 10−4

xt

Figure 6: The absolute error for the bi-soliton for t ∈ [−5, 5]and x ∈ [−4π, 4π] using Besse relaxation scheme.

At last we consider the bi-solitonsolution given in (3). For simplic-ity, we have only looked at theisolated case, that is, spatial peri-odic gluing of the solution is omit-ted. In order to include all of thebi-soliton, it is necessary to use alarger spatial grid.

In Figure 6 is plotted the nu-merical error using the Besse relax-ation scheme with M = 2000 andN = 2000. We observe that the er-ror is largest at the position of thebi-soliton.

Page 11: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

Group 6 — Candidates 10028, 10037 and 10055 11 of 12

5.4. A conserved quantity

It can be shown [1, 11] that both the Crank-Nicolson -and the Besse relaxation scheme conservesthe discrete variant

M [U n] = hM+1∑m=0

|Unm|2 (18)

of the quantity in (4). Let the spatial -and temporal interval be [−π, π] and [0, 5], respectively.ThenM [u] = 2π for the analytic plane wave solution (2) with parameters λ = −2, A = 1, B = 1

and C = 0. In Figure 7 is plotted the difference between the analytic and discrete version (18)for the four different methods.

t

M[u]−

M[U

n]

Crank-Nicolson

0 1 2 3 4 5

×10−14

−1

0

1

2

t

M[u]−

M[U

n]

Lin. Crank-Nicolson

0 1 2 3 4 5

×10−5

−7

−6

−5

−4

−3

−2

−1

0

t

M[u]−

M[U

n]

Du Fort-Frankel

0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018

×10−7

−8

−6

−4

−2

0

2

t

M[u]−

M[U

n]

Besse relaxation

0 1 2 3 4 5

×10−13

−7

−6

−5

−4

−3

−2

−1

0

Figure 7: Comparison of the conserved quantity for the four difference schemes.

As we can see, both the Crank-Nicolson method and the Besse relaxation scheme seem topreserve the mass correctly. The error is close to machine epsilon. Moreover, it looks like thelinearized Crank-Nicolson method very slowly increases M [U n] as time goes. The Du Fort-Frankel type method is restricted to a short time interval in order to display its oscillatorybehaviour. However the oscillations are almost constant in time, so the mass may be consideredto be preserved also for the Du Fort-Frankel method.

Page 12: TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceM ... · TMA4212NumericalSolutionofDifferentialEquationsbyDifferenceMethods NONLINEAR SCHRÖDINGER EQUATION Group6—Candidates10028,10037and10055

12 of 12 Nonlinear Schrödinger Equation

6. Conclusion

We have proved the unconditional stability of the Crank-Nicolson scheme and its convergencefor the periodic nonlinear cubic Schödinger equation. Moreover, numerical tests verify that thefour finite difference schemes are of second order in time and space with the exception of DuFort-Frankel type method, which we have only shown to have order two in space.

Moreover, both the Crank-Nicolson scheme and the Besse relaxation method are numericallyverified to preserve the conserved quantity mass.

Our numerical experiments indicates that the Besse relaxation scheme may be considered asthe best method since it is both fast and accurate, while the Crank-Nicolson scheme seem toprovide better stability for large time intervals.

In practice, if |λ| is big enough, the waves will be so close and our numerical methods willrequire a very fine grid to approximate the solution well.

References

[1] Christophe Besse, A relaxation scheme for the nonlinear schrödinger equation, SIAM J. Numer. Anal. 42(2004), no. 3, 934–952.

[2] A.G. Bratsos, A linearized finite-difference method for the solution of the nonlinear cubic schrödinger equa-tion, Korean Journal of Computational and Applied Mathematics 8 (2001), 459–467 (English).

[3] L. Brüll and H.-J. Kapellen, Periodic solutions of one-dimensional nonlinear schrödinger equations, ActaMathematica Hungarica 54 (1989), no. 3-4, 191–195 (English).

[4] Morten Dahlby and Brynjulf Owren, Plane wave stability of some conservative schemes for the cubicschrödinger equation, ESAIM: Mathematical Modelling and Numerical Analysis 43 (2009), 677–687.

[5] F. Ivanauskas and M. Radziunas, Stability and convergence of dufort-frankel-type difference schemes for anonlinear schrödinger-type equation, Lithuanian Mathematical Journal 37 (1997), 249–263 (English).

[6] D. H. Peregrine, Water waves, nonlinear schrödinger equations and their solutions, The ANZIAM Journal25 (1983), 16–43.

[7] Andrei D. Polyanin, Schrodinger equation with a cubic nonlinearity, http://eqworld.ipmnet.ru/en/solutions/npde/npde1401.pdf, 2004, [Online; accessed 16-March-2013].

[8] Clive Temperton, Algorithms for the solution of cyclic tridiagonal systems, Journal of Computational Physics19 (1975), no. 3, 317 – 323.

[9] Wikipedia, the free encyclopedia, Tridiagonal matrix algorithm, http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm, 2013, [Online; accessed 24-April-2013].

[10] Lixin Wu, Dufort–frankel-type methods for linear and nonlinear schrödinger equations, SIAM J. Numer.Anal. 33 (1996), no. 4, 1526–1533.

[11] Andrea Zisowsky and Matthias Ehrhardt, Discrete artificial boundary conditions for nonlinear schrödingerequations, Math. Comput. Model. 47 (2008), no. 11-12, 1264–1283.