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.

CN Scheme
1

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

u(xi , tn+1 ) u(xi , tn )
t
n+ 12
is a centered difference approximation for ut at (xi , t
) and therefore should be O(t2 ).
1

ut (xi , tn+ 2 )

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 h u(xi+1 , tn+1 ) 2u(xi , tn+1 ) + u(xi1 , tn+1 ) u(xi+1 , tn ) 2u(xi , tn ) + u(xi1 , tn ) i
1
+
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
n+1
n
n i
2Uin+1 + Ui1
Ui+1
2Uin + Ui1
Uin+1 Uin
h Ui+1
=
for i = 1, . . . , M 1
+
t
2
(x)2
(x)2
n+1
=0
U0n+1 = UM

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
2

For n = 0, 1, . . . ,
n+1
n+1
n
n
+ (2 + 2)Uin+1 Ui1
= Ui+1
+ (2 2)Uin + Ui1
Ui+1

U0n+1

n+1
UM

=0

for i = 1, . . . , M 1

(1)
(2)

## For simplicity we will often write the difference equation as

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

and
n
n
+ (2 2)Uin + Ui1
Rh Uin = Ui+1

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
U1
U0n + (2 2)U1n + U2n + U0n+1
2 + 2

0
n+1

## U1n + (2 2)U2n + U3n

2 + 2
0
0

U2.
.
.
.
.

.
..
..
..
..
0

. =

.
.
.
..
..
0

2 + 2
..
n+1
n+1
n
n
n
0

2 + 2
UM 2 + (2 2)UM 1 + UM + UM
UM 1

(3)

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
3

~ n+1 = ~bn
AU
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

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.

## We show stability in the norm kk2,x where

kxk2,x =

1
X
M

x2i x

i=1

1/2

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

Let U

u0 (x1 )
u0 (x2 )
u~0 =
..

u0 (xM 1 )

Then

## ~ n k2,x ku~0 k2,x

kU

(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
n+1
n
n
+ (2 + 2)Uin+1 Ui1
= Ui+1
+ (2 2)Uin + Ui1
Ui+1

so that
Uin+1 Uin =
for 1 i M 1 and

for i = 1, . . . , M 1


 2 n+1
i
h n+1
n
n+1
n
Ui + Uin
+ Ui1
Ui+1 + Ui+1
+ Ui1

2
2
U0n+1 = U0n = 0

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

n+1
n
UM
= UM
=0

h
i h

 2 n+1
i
n+1
n
n+1
n
x (Uin+1 )2 Uin )2 =
+ Ui+1
+ Ui1
+ Ui1

## Ui + Uin (Uin+1 + Uin )x

Ui+1
2
2
Now sum over i = 1, . . . , M 1
M
1
X
i=1

(Uin+1 )2 x

M
1
X
i=1

(Uin )2 x =

M 1

 2 n+1
i
x X h n+1
n
n+1
n
Ui + Uin (Uin+1 + Uin )
+ Ui1
+ Ui1

Ui+1 + Ui+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
1
X
i=1

and thus

(Uin+1 )2 x

M
1
X

(Uin )2 x

i=1

~n 2
~ n+1 k2,x kU
~ n k2,x
~ n+1 k2
kU
2,x kU k2,x = kU

If we show this then we can apply it repeatedly to get the desired result.
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
kU
x
=
[Bi+1 + Bi1 2Bi ] Bi
2,x
2,x
2
i=1
M 1

X


x
=
Bi+1 Bi + Bi1 Bi 2Bi2
2
i=1
h

x (B1 B2 + B2 B3 + + BM 1 BM )
=
2
+(B0 B1 + B1 B2 + + BM 2 BM 1 ) 2

M
1
X
i=1

=
=
=

M 2
M
1
i
X
h X
x 2
Bi Bi+1 2
Bi2
2
i=1
i=1
" M 1
#
M
1
M
1
X
X
X

2
2
2
x 2
Bi Bi+1
Bi
Bi+1 B1
2
i=1
i=1
i=1
" M 1
#
X

x
(Bi Bi+1 )2 B12
2
i=1
"M 1
#
X

x
2
i=1

Bi2

## Consistency of Crank-Nicolson Scheme

In this section we show that the CN scheme is consistent and its order of accuracy is (2, 2).
and let U n be
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)
i

the solution to the CN equation Lh Uin+1 = Rh Uin . Then there exists constants, independent of h, k, u such that
 4

i

h

u 6u
n+1
h
n
2
2

max L u(xi , t ) R u(xi , t ) Ct (x) + (t) max
+
1iM 1

x4 x6
(x,t)Q
0nN 1

(5)

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(xi1 , tn+1 )


u(xi , tn ) + (2 2)u(xi , tn ) + u(xi1 , tn )

## Expanding in terms of Taylor series we obtain

h
i
(x)2
(x)3
(x)4
h
n+1
n+1
n+1
n+1
n+1
n+1
uxxx (xi , t ) +
uxxx (xi , t ) +
uxxxx(1 , t )
L u(xi , t ) = u(xi , t ) + xux (xi , t ) +
2!
3!
4!
+2u(xi , tn+1 ) + 2u(xi , tn+1 )
i
h
(x)2
(x)3
(x)4
uxxx (xi , tn+1 )
uxxx (xi , tn+1 ) +
uxxxx(2 tn+1 )
u(xi , tn+1 ) xux (xi , tn+1 ) +
2!
3!
4!
4

(x)
uxxxx(1 , tn+1 ) + uxxxx (2 , tn+1 )
= 2u(xi , tn+1 ) (x)2 uxx (xi , tn+1 )
4!
and similarly

## Rh u(xi , tn ) = u(xi , tn ) + (2 2)u(xi , tn ) + u(xi1 , tn )

(x)4
(uxxxx (3 , tn ) + uxxxx(4 , tn ))
= 2u(xi , tn ) + (x)2 uxx (xi , tn ) +
4!

## Expanding Lh u(xi , tn+1 ) in time about tn gives us

(x)4
uxxxx (1 , tn+1 ) + uxxxx (2 , tn+1 )
Lh u(xi , tn+1 ) = 2u(xi , tn+1 ) (x)2 ut (xi , tn+1 )

4!
i
h
2
(t)
(t)3
utt (xi , tn ) +
uttt (xi , 1 )
= 2 u(xi , tn ) + tut (xi , tn ) +
2!
3!
i
h
2
(t)

2
n
n
uttt (xi , 2 )
(x) ut (xi , t ) + tutt (xi , t ) +

2!
(x)4
(uxxxx (1 , 3 ) + uxxxx(2 , 4 ))

4!
(t)2
(t)3
utt + 2
uttt (xi , 1 )
= 2u(xi , tn ) + 2tut + 2
2!
3!
(t)3
uttt (xi , 2 )
tut (t)2 utt
2
(x)4
(uxxxx (1 , tn ) + uxxxx (2 , tn ))

4!
(t)3
(t)3
uttt (xi , 1 )
uttt (xi , 2 )
= 2u(xi , tn ) + tut + 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
Lh u(xi , tn+1 ) Rh u(xi , tn ) = 2u(xi , tn ) + tut + 2

(t)3
(t)3
uttt (xi , 1 )
uttt (xi , 2 )
3!
2

(x)4
(uxxxx (1 , 3 ) + uxxxx (2 , 4 ))
4!
(x)4
n
2
(uxxxx (3 , tn ) + uxxxx (4 , tn ))
2u(xi , t ) (x) uxx
4!
i
3h 6
(t)2 2
(t)
6u
u
uxxxx(xi , tn ) + 2
(x
,

)
+
(x
,

)
= tut
i
1
i
2
2!
3! x6
x6
4
(x)
(uxxxx (1 , tn ) + uxxxx(2 , tn ))

4!
(x)4
t
21
u
(uxxxx (3 , tn ) + uxxxx (4 , tn ))
(x)

t
(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
 4 6 


u u
h
n+1
h
n
2
2
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.

Convergence of CN