You are on page 1of 9

Crank Nicolson Scheme for the Heat Equation

The goal of this section is to derive a 2-level scheme for the heat equation which has no stability requirement and is second order
in both space and time. From our previous work we expect the scheme to be implicit. This scheme is called the Crank-Nicolson
method and is one of the most popular methods in practice.

1 CN Scheme

1
We write the equation at the point (xi , tn+ 2 ). Then

1 u(xi , tn+1 ) − u(xi , tn )


ut (xi , tn+ 2 ) ≈
∆t
1

n+ 12
is a centered difference approximation for ut at (xi , t ) and therefore should be O(∆t2 ).
1
To approximate the term uxx (xi , tn+ 2 ) we use the average of the second centered differences for uxx (xi , tn+1 ) and uxx (xi , tn ); i.e.,
1 1 h u(xi+1 , tn+1 ) − 2u(xi , tn+1 ) + u(xi−1 , tn+1 ) u(xi+1 , tn ) − 2u(xi , tn ) + u(xi−1 , tn ) i
uxx (xi , tn+ 2 ) ≈ +
2 (∆x)2 (∆x)2

We now define the CN scheme for the IBVP


ut = νuxx (x, t) ∈ (0, 1) × (0, T ]
u(x, 0) = u0
u(0, t) = u(1, t) = 0
as

Set
Ui0 = u0 (xi ) i = 0, 1, . . . , M
For n = 0, 1, . . . ,
n+1
Uin+1 − Uin ν h Ui+1 − 2Uin+1 + Ui−1
n+1 n
Ui+1 − 2Uin + Ui−1
n i
= + for i = 1, . . . , M − 1
∆t 2 (∆x)2 (∆x)2
U0n+1 = UMn+1
=0

Remark: If the original PDE has a source term f (x, t) then we usually handle this by using
1
(f (xi , tn ) + f (xi , tn+1 ))
2

Our scheme can be rewritten as

Set
Ui0 = u0 (xi ) i = 0, 1, . . . , M
For n = 0, 1, . . . ,
2

n+1
−λUi+1 + (2 + 2λ)Uin+1 − λUi−1
n+1 n
= λUi+1 + (2 − 2λ)Uin + λUi−1
n
for i = 1, . . . , M − 1 (1)
U0n+1 = n+1
UM =0 (2)

For simplicity we will often write the difference equation as


Lh Uin+1 = Rh Uin
where
Lh Uin+1 = −λUi+1
n+1
+ (2 + 2λ)Uin+1 − λUi−1
n+1

and
Rh Uin = λUi+1
n
+ (2 − 2λ)Uin + λUi−1
n

Remark: Note that we can no longer solve for U1n+1 , then U2n+1 even if we know the solution at the previous time step.
Instead, we must solve for all values at a specific timestep at once, i.e., we must solve a system of linear equations. Such a
scheme is called an implicit scheme.
From (1)–(2) we set Ui0 = u0 (xi ) for i = 0, 1, . . . , M and for each value of n = 0, 1, . . . solve the system

  n+1  
λU0n + (2 − 2λ)U1n + λU2n + λU0n+1
 
2 + 2λ −λ 0 ··· 0 U1
 −λ 2 + 2λ −λ 0 0   n+1   λU1n + (2 − 2λ)U2n + λU3n
  U2.  


. .. . .. . ..  .   .
..

 0  .  =  (3)
 

. .. . .
..
−λ   ..  
     
 0 −λ 2 + 2λ 
n+1 n n n n+1
0 ··· 0 −λ 2 + 2λ UM −1 λUM −2 + (2 − 2λ)UM −1 + λUM + λUM

Of course, on the right hand side of the first and last equations, the terms involving
U0n , U0n+1 , n
UM , n+1
UM
are zero due to the homogeneous boundary conditions for our IBVP.

The system (3) can be written symbolically as


~ n+1 = ~bn
AU
3

Remark: The matrix A is tridiagonal, and symmetric positive definite and thus can be solve by the same method as the
standard implicit scheme which we discussed in the previous section.

Remark: The matrix A does not change at each timestep (as long as the timestep remains constant).

Exercise How do we know that this matrix is symmetric positive definite?

Exercise Why are we guaranteed that this system has a unique solution?

We now want to investigate the stability, consistency (and thus accuracy), and convergence of the CN scheme. Recall that we
wanted a scheme which was second order accurate in space and time and which was unconditionally stable.

2 Stability of Crank-Nicolson Scheme


We show stability in the norm k·k2,∆x where
M
X −1
1/2
kxk2,∆x = x2i ∆x
i=1

Note here that the sum begins at i = 1 and ends at i = M − 1 because we are imposing homogeneous Dirichlet boundary data.

Lemma. ~ n be the solution of (3). Let u~0 be defined by


Let U
u0 (x1 )
 
 u0 (x2 ) 
u~0 =  .. 
 . 
u0 (xM −1 )
Then
~ n k2,∆x ≤ ku~0 k2,∆x
kU (4)
4

Remark: This results says that the CN scheme is unconditionally stable i.e., there is no condition on λ required for stability.

proof

From the scheme we have


n+1
−λUi+1 + (2 + 2λ)Uin+1 − λUi−1
n+1 n
= λUi+1 + (2 − 2λ)Uin + λUi−1
n
for i = 1, . . . , M − 1
so that
λ h n+1  2λ n+1 i
Uin+1 − Uin = n n+1 n
Ui + Uin

Ui+1 + Ui+1 + Ui−1 + Ui−1 −
2 2
for 1 ≤ i ≤ M − 1 and
U0n+1 = U0n = 0 n+1
UM n
= UM =0

For each i multiply each equation by (Uin+1 + Uin )∆x to obtain


h i λh  2λ n+1 i
∆x (Uin+1 )2 − Uin )2 = n+1 n n+1 n
Ui + Uin (Uin+1 + Uin )∆x

Ui+1 + Ui+1 + Ui−1 + Ui−1 −
2 2

Now sum over i = 1, . . . , M − 1


M −1 M −1 M −1
X X λ∆x X h n+1  2λ n+1 i
(Uin+1 )2 ∆x − (Uin )2 ∆x = n n+1 n
Ui + Uin (Uin+1 + Uin )

Ui+1 + Ui+1 + Ui−1 + Ui−1 −
i=1 i=1
2 i=1 2

Our goal here is to show that the rhs of this expression is ≤ 0. If we do this, then
M
X −1 M
X −1
(Uin+1 )2 ∆x ≤ (Uin )2 ∆x
i=1 i=1

and thus
~ n+1 k2
kU ~n 2 ~ n+1 k2,∆x ≤ kU
~ n k2,∆x
2,∆x ≤ kU k2,∆x =⇒ kU

If we show this then we can apply it repeatedly to get the desired result.
5

To show this we simplify our equation by writing


Bi = Uin+1 + Uin
where we know B0 = BM = 0 from the homogenous boundary data.
We have
M −1
~ n+1 k2 − kU
~ n k2 λ X
kU 2,∆x 2,∆x = ∆x [Bi+1 + Bi−1 − 2Bi ] Bi
2 i=1
M −1
λ X
Bi+1 Bi + Bi−1 Bi − 2Bi2

= ∆x
2 i=1
λ h
= ∆x (B1 B2 + B2 B3 + · · · + BM −1 BM )
2
M
X −1 i
+(B0 B1 + B1 B2 + · · · + BM −2 BM −1 ) − 2 Bi2
i=1
M −2 M −1
λ h X X i
= ∆x 2 Bi Bi+1 − 2 Bi2
2 i=1 i=1
" M −1 M −1 M −1
#
λ X X
2
X
2 2
= ∆x 2 Bi Bi+1 − Bi − Bi+1 − B1
6

2 i=1 i=1 i=1


" M −1 #
λ X
= ∆x − (Bi − Bi+1 )2 − B12
2 i=1
"M −1 #
λ X
= − ∆x (Bi − Bi+1 )2 + B12
2 i=1
≤ 0

3 Consistency of Crank-Nicolson Scheme

In this section we show that the CN scheme is consistent and its order of accuracy is (2, 2).

Let u satisfy the homogeneous Dirichlet IBVP for the 1-D heat equation in Q = (0, 1) × (0, T ] where u ∈ C 6,3 (Q̄) and let Uin be
the solution to the CN equation Lh Uin+1 = Rh Uin . Then there exists constants, independent of h, k, u such that
 4
∂ u ∂6u
i 
h n+1 h n
 2 2
max L u(xi , t ) − R u(xi , t ) ≤ C∆t (∆x) + (∆t) max
+ (5)
1≤i≤M −1
0≤n≤N −1
(x,t)∈Q̄ ∂x4 ∂x6

Proof

As before we plug the exact solution into the difference equation and expand using Taylor series about the point (x i , tn ). We
have

Lh u(xi , tn+1 ) − Rh u(xi , tn ) = −λu(xi+1 , tn+1 ) + (2 + 2λ)u(xi , tn+1 ) − λu(xi−1 , tn+1 )


− λu(xi , tn ) + (2 − 2λ)u(xi , tn ) + λu(xi−1 , tn )
 

Expanding in terms of Taylor series we obtain

h n+1
h
n+1 n+1 (∆x)2 n+1 (∆x)3 n+1 (∆x)4 n+1
i
L u(xi , t ) = −λ u(xi , t ) + ∆xux (xi , t ) + uxxx (xi , t ) + uxxx (xi , t ) + uxxxx(Θ1 , t )
2! 3! 4!
7

+2u(xi , tn+1 ) + 2λu(xi , tn+1 )


h (∆x)2 (∆x)3 (∆x)4 i
−λ u(xi , tn+1 ) − ∆xux (xi , tn+1 ) + uxxx (xi , tn+1 ) − uxxx (xi , tn+1 ) + uxxxx(Θ2 tn+1 )
2! 3! 4!
4
(∆x)
= 2u(xi , tn+1 ) − λ(∆x)2 uxx (xi , tn+1 ) − λ uxxxx(Θ1 , tn+1 ) + uxxxx (Θ2 , tn+1 )

4!
and similarly
Rh u(xi , tn ) = λu(xi , tn ) + (2 − 2λ)u(xi , tn ) + λu(xi−1 , tn )
(∆x)4
= 2u(xi , tn ) + λ(∆x)2 uxx (xi , tn ) + λ (uxxxx (Θ3 , tn ) + uxxxx(Θ4 , tn ))
4!
Expanding Lh u(xi , tn+1 ) in time about tn gives us
λ (∆x)4
Lh u(xi , tn+1 ) = 2u(xi , tn+1 ) − (∆x)2 ut (xi , tn+1 ) − λ uxxxx (Θ1 , tn+1 ) + uxxxx (Θ2 , tn+1 )

ν 4!
2
h (∆t) (∆t)3 i
= 2 u(xi , tn ) + ∆tut (xi , tn ) + utt (xi , tn ) + uttt (xi , τ1 )
2! 3!
2
λ 2
h
n n (∆t) i
− (∆x) ut (xi , t ) + ∆tutt (xi , t ) + uttt (xi , τ2 )
ν 2!
(∆x)4
−λ (uxxxx (Θ1 , τ3 ) + uxxxx(Θ2 , τ4 ))
4!
(∆t)2 (∆t)3
= 2u(xi , tn ) + 2∆tut + 2 utt + 2 uttt (xi , τ1 )
2! 3!
(∆t)3
−∆tut − (∆t)2 utt − uttt (xi , τ2 )
2
(∆x)4
−λ (uxxxx (Θ1 , tn ) + uxxxx (Θ2 , tn ))
4!
(∆t)3 (∆t)3
8

= 2u(xi , tn ) + ∆tut + 2 uttt (xi , τ1 ) − uttt (xi , τ2 )


3! 2
(∆x)4
−λ (uxxxx (Θ1 , τ3 ) + uxxxx(Θ2 , τ4 ))
4!
where we have used the fact that ut = νuxx and λ = ν∆t/(∆x)2
Combining we arrive at
(∆t)3 (∆t)3
Lh u(xi , tn+1 ) − Rh u(xi , tn ) = 2u(xi , tn ) + ∆tut + 2 uttt (xi , τ1 ) − uttt (xi , τ2 )
3! 2
(∆x)4
−λ (uxxxx (Θ1 , τ3 ) + uxxxx (Θ2 , τ4 ))
4!
n 2 (∆x)4
−2u(xi , t ) − λ(∆x) uxx − λ (uxxxx (Θ3 , tn ) + uxxxx (Θ4 , tn ))
4!
(∆t)2 2 (∆t) 3h 6
∂ u ∂6u i
= ∆tut − ν uxxxx(xi , tn ) + 2 (x i , τ 1 ) + (x i , τ 2 )
2! 3! ∂x6 ∂x6
4
(∆x)
−λ (uxxxx (Θ1 , tn ) + uxxxx(Θ2 , tn ))
4!
ν∆t 21 (∆x)4
− (∆x) u t − λ (uxxxx (Θ3 , tn ) + uxxxx (Θ4 , tn ))
(∆x)2 ν 4!
where again we have used the equations ut = νuxx , utt = νuxxt = ν(ut )xx = ν 2 uxxxx and uttt = ν 2 ∂ 6 u/∂x6 . Thus we have that
9

 4 6 
h n+1 h n

2 2
 ∂ u ∂ u
L u(xi , t ) − R u(xi , t ) ≤ ∆t (∆t) (∆x) C max 4 , 6
∂x ∂x

Remark: We have illustrated that the CN scheme is a 2 time level scheme which is accurate of order (2, 2) so we say it is
second order in space and time.

4 Convergence of CN

You might also like