Professional Documents
Culture Documents
k
u
m
x
k
(x
0
) a
i
u(x
i
) (kl)
i=0
Vector of coecients a= (a
0
, a
1
, , a
m
) is called FD stencil.
How to get stencil?
Taylor expansion
In 1D: u(x) =u(x
0
) +u
x
(x
0
) (xx
0
) +
1
(x
0
) (xx
0
)
2
2
u
xx
+
1
6
u
xxx
(x
0
)(xx
0
)
3
+O(|xx
0
|
4
)
Name x
i
=x
i
x
0
= u(x
i
) =u(x
0
) +u
x
(x
0
)x
i
+
1
2
u
xx
(x
0
)x
2
i
+
1
6
u
xxx
(
x
0
)x
3
i
+O(|x
i
|
4
)
m m m
= a
i
u(x
i
) =u(x
0
) a
i
+u
x
(x
0
) a
i
x
i
i=0 i=0 i=0
m
+u
xx
(x
0
)
1
a
i
x
i
2
+O(h
3
) where x
i
hi.
2
i=0
Match coecients:
m
a
i
u(x
i
)u
x
(x
0
) a
i
= 0, a
i
x
i
= 1 a
i
x
i
2
small
i=0 i i
m
a
i
u(x
i
)u
xx
(x
0
) a
i
= 0, a
i
x
i
= 0, a
i
x
i
2
= 2 a
i
x
i
3
small
i=0 i i i
etc.
1
Image by MIT OpenCourseWare.
1
Vandermonde matrix
_ _
_ _
1 1
1 1
0 x
1
x
m
x
0
x
m
2 2
x
0
x
m
= V =V(x
0
, x
1
, , x
m
) =
_
. . . .
. . . .
. . .
. .
. .
. . .
0 x
k
x
k
k k
1
m
x
0
x
m
Constraints for stencil:
V a=b
linear system
_ _
a
0
1 1 0
1
_
.
.
.
k= 1 : a
i
u(x
i
)u
x
(x
0
) : =
x
0
x
m
a
m
_ _
_ _
_ _
1 1
a
0 0
_
.
.
.
_
=
_
0
_ _ _
x
0
k= 2 : a
i
u(x
i
)u
xx
(x
0
) : x
m
x
2
0
x
2
m a
m
2
If m=k= In general one unique stencil a
If m > k= Multiple stencils
Can add additional criteria, e.g. require higher order.
Ex.: k= 1, m= 1
=
x
0
x
1
a
1
1
x
0
= 0, x
1
=h= a
0
1
, a
1
=
1
1 1 0 a
0
=
h h
x
0
= 0, x
1
=h= a
0
=
h
1
, a
1
=
h
1
Ex.: k= 1, m= 2
_
x= (x
0
, x
0
+h, x
0
h)
a
0
_
1
1 1 1 0 =
=
a
1
a
2
h
_ _
= a
1
0 h h 1
a
0
=a
1
a
2 a
2
One-parameter family of stencils
Additional criterion: second order accuracy
2
_
Image by MIT OpenCourseWare.
Image by MIT OpenCourseWare.
_ _ _ _ _ _
1 1 1 a
0
0
_ _ _
a
1
_
=
_
1
_
1 1
0 h h
h
2
a
0
= 0, a
1
= = = , a
2
2h
2h
h
2
0 a
2
0
Ex.: k= 2, m= 2
a
0
=a
1
a
2
_ _ _ _ _ _
1 1 1 a
0
0
a
1
=
x
2
1
( x
1
x
2
)
_
0 x
1
x
2
_ _
a
1
_
=
_
0
_
=
0 x
2
1
x
2
2
a
2
2
a
2
=
x
2
2
( x
2
x
1
)
Equidistant: x= (x
0
, x
0
+h, x
0
h)
2 1
= a
0
=
h
2
, a
1
=a
2
h
2
Higher space dimensions
2D
x
i
= (x
i
, y
i
)
_ _
_ _
a
0
1 1 1 0
_
a
1
.
.
.
.
.
.
.
.
.
_
stencila for u
xx
(x
0
)
0 x
1
x
m
0
0
2
0 y
1
y
m
=
2 2
x 0 x
1
m
0 x
1
y
1
x
m
y
m
0
0 y
2
y
2
0
1
m
a
m
3
_
_
_ _
_
Image by MIT OpenCourseWare.
Image by MIT OpenCourseWare.
Image by MIT OpenCourseWare.
0
0
3D
_ _
a
0
1 1 1 0
a
1
0 x
i
0
_ _
_ _
_
.
.
0 y
i
0 z
i
0
.
.
.
.
0
2
0 x 2 stencil for .
i
.
. =
y
2
2 u
xx
+u
yy
+u
zz
i
.
.
z
2
i
2
.
.
.
0 x
i
y
i
0 x
i
z
i
0 y
i
z
i
0
.
0 .
.
.
0
a
m
2
Ex.: u(x
0
)
2D
1 1 2 1 1
h
2
,0,
h
2
,0
h
2
,0,
h
2
,0,
4
,
2
h
1 1 1 1 2
a= + =
h
2
,
h
2
,
h
2
,
h
2
,
h
2
h
2
a=( exercise )
2
( ) = u x
0
_
4
Image by MIT OpenCourseWare.
Image by MIT OpenCourseWare.
1
Poisson Equation
_ _
_ u
xx
=f(x) in ]0,1[ _
1D
_
u(0)=a
_
Dirichlet boundary condition
u
x
(1)=c Neumann boundary condition
Discretize on regular gridx=(0, h,2h, , nh,1), where h=
n+1
(x
i
) =
u(x
i1
) + 2u(x
i
)u(x
i+1
)
Interior: f(x
i
) =u
xx
+O(h
2
)
h
2
_ _
u
i1
=
h
1
2
,
h
2
2
,
h
1
2
_
u
i
_
+O(h
2
)
u
i+1
Dirichlet boundary condition: u
0
=u(x
0
) =a (exact)
Neumann boundary condition:
Naive choice: c=u
x
(1)
u
n+1
u
n
1 1 u
n
= +O(h) = , +O(h)
h
h h
u
n+1
O(h) on a single cell = Could preserve O(h
2
) globally, or drop
accuracy to O(h). Here the bad event happens.
Second order approximation:
c=u
x
(1)=
u(x
n+2
)u(x
n
)
+O(h
2
)
2h
Obtain u
n+2
by
u
n
+ 2u
n+1
u
n+2
=f(1)
h
2
1 1 u
n
h
=
h
,
h
u
n+1
=c+
2
f
(1)
2
1
h
,
h
2
,
2
3
h
_
u
n
_
=c
u
n+1
2
nd
order one-sided stencil (check by V a=b).
5
Image by MIT OpenCourseWare.
Discretization generates linear system:
1 u
0
a
_ _
1 2 1
f(x
1
) u
1
h
2
h
2
h
2
. .
_ _ _ _
_
=
_
.
.
.
.
.
f(x
n
)
_
. . .
. . . .
.
.
.
.
. . .
()
. . .
. . .
. . .
1 2 1
h
2
h
2
h
2
u
n
1 1 h
f(1) c+
h h
u
n+1
2
A u
b
Second order approximation (try it yourself!)
Big Question:
How to solve sparse linear systems A u=
b?
lecture 11.
Rem.: () ()
_
_ _
_
1
h
2
a
2 1
h
2
f(x
1
) +
h
2
u
1
=
_
1
h
2
h
2
2 1
_
f(x
2
)
.
.
.
_
h
2 .
.
.
.
.
.
.
.
. . .
. . .
. . .
()
.
. . .
.
.
. . .
. . .
1 2
h
2
h
2
1
h
2
.
f(x
n1
)
f(1) 1 1 u
n
f(x
n
)+
h
c
+
h
_
6
MIT OpenCourseWare
http://ocw.mit.edu
18.336 Numerical Methods for Partial Differential Equations
Spring 2009
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.