Escolar Documentos
Profissional Documentos
Cultura Documentos
22 October 2012
()
22 October 2012
1 / 54
Outline
Review
Application of methods
Truncation error
()
22 October 2012
2 / 54
n
X
[Q(h)]j n+1j
j=0
()
22 October 2012
3 / 54
()
1
(k1 + 2(k2 + k3 ) + k4 )
6
22 October 2012
4 / 54
RK4:
Uses an average of different slopes (called predictors).
The amplification factor is
1
1
1
Q(h) = 1 + h + (h)2 + (h)3 + (h)4
2
6
24
The stability condition is
h<
2.8
||
()
22 October 2012
5 / 54
ODE Systems
where
y=
y1 (t)
y2 (t)
yk (t)
()
22 October 2012
6 / 54
ODE Systems
Euler Forward
(I + hA)
|
{z
wn + hg(tn )
Amplification matrix
()
22 October 2012
7 / 54
ODE Systems
Euler Backward
(I hA)1
|
{z
(wn + hg(tn+1 ))
Amplification matrix
()
22 October 2012
8 / 54
ODE Systems
Truncation Error
n+1 =
(j)
1 (j)
(j)
(y (tn+1 ) zn+1 )
h
(j)
(Local)
(Global)
for j = 1, . . . , k.
Note: This is the coupled global truncation error.
()
22 October 2012
9 / 54
ODE Systems
Truncation Error
(I + hA)
|
{z
en
Amplification matrix
()
22 October 2012
10 / 54
ODE Systems
Stability
()
22 October 2012
11 / 54
ODE Systems
Stability
()
2|(j) |
,
((j) )2 + ( (j) )2
j = 1, . . . , k
22 October 2012
12 / 54
()
{z
rapidly decays
F (t)
| {z }
quasi-stationary
22 October 2012
13 / 54
+ hQ(h)n1 + h
n
|{z}
because
lim [Q(h)]n = 0.
()
22 October 2012
14 / 54
lim en+1 = hn
()
22 October 2012
15 / 54
Forward Euler
RK4
()
1 = 10
h < 2/| 10|
h < 2.8/| 10|
2 = 1000.
h < 2/| 1000|
h < 2.8/| 1000|
22 October 2012
16 / 54
()
22 October 2012
17 / 54
()
22 October 2012
18 / 54
()
h
=(I + A)wn
2
h
=(I + SS 1 )wn
2
h
=S 1 (I + SS 1 )wn
2
h 1
1
=(S + S )wn
2
22 October 2012
19 / 54
n+1
()
1
h
I + n
2
22 October 2012
20 / 54
1 h2 j
1 + h2 j
or
h
2 j
h
2 j
< 1,
h
h
|1 j | < |1 + j |,
2
2
()
j = 1, . . . , k.
22 October 2012
21 / 54
j = 1, . . . , k,
2
2
h
< 1
2
2
2
()
22 October 2012
22 / 54
()
22 October 2012
23 / 54
Definition (Superstability)
A numerical method is called superstable if
lim
()
|Q(h)| < 1.
22 October 2012
24 / 54
1
2 h
1
2 h
lim
1/2
1/2
| {z }
=1
Lhospitals rule
NOT superstable
|Q(h)| =
1
=0
h 1 h
lim
()
Superstable
22 October 2012
25 / 54
1 12 h
1+ 12 h
1
1h
()
22 October 2012
26 / 54
0 < x < L,
T (L) = TL
Alternatively, we could give the heat flow at one end:
A
()
dT
(L) = AqL .
dx
22 October 2012
27 / 54
xL < x < xR
a0 y (xL ) + a1 y (xL ) = cL
b0 y (xR ) + b1 y 0 (xR ) = cR
where p(x ) > 0 and q(x ) > 0.
()
22 October 2012
28 / 54
(p(x )y 0 )0 + r (x )y 0 = f (x ),
xL < x < xR
a1 y (xL ) = cL
b1 y 0 (xR ) = cR
()
22 October 2012
29 / 54
Dirichlet: a0 y (xL ) = cL a1 = 0
Neumann: b1 y 0 (xR ) = cR b0 = 0
Robin: a0 6= 0, b0 6= 0 (linear combination of Dirichlet &
Neumann)
()
22 October 2012
30 / 54
xL < x < xR ,
y (xL ) = y (xR ) = 0
Take xL = 0 and xR = 1.
()
22 October 2012
31 / 54
()
xR xL
1
Domain length
=
=
=h
Number elements
N +1
N +1
22 October 2012
32 / 54
j = 0, . . . , N + 1
which gives
xj = jh,
j = 0, . . . , N + 1
()
22 October 2012
33 / 54
()
22 October 2012
34 / 54
()
1
(wj+1 2wj + wj1 ) + qj wj = fj
h2
w0 = wN+1 = 0
j = 1, . . . , N
22 October 2012
35 / 54
Plug in j = 1 :
1
(w2 2w1 + w0 ) + q1 w1 = f1
|{z}
h2
=0
()
1
2 (w2 2w1 ) + q1 w1 = f1
h
22 October 2012
36 / 54
Plug in j = N :
1
(wN+1 2wN + wN1 ) + qN wN = fN
h2 | {z }
=0
()
1
(2wN wN1 ) + qN wN = fN
h2
22 October 2012
37 / 54
Plug in j = 2, . . . , N 1 :
1
(wj+1 2wj + wj1 ) + qj wj = fj
h2
()
22 October 2012
38 / 54
1
(wj+1 2wj + wj1 ) + qj wj = fj ,
h2
1
2 (wN1 2wN ) + qN wN = fN ,
h
()
j =1
j = 2, . . . , N 1
j = N.
22 October 2012
39 / 54
Aw = f
with
A=
where
w=
()
w1
w2
wN1
wN
1
K +M
h2
f1
f2
f=
fN1
fN
22 October 2012
40 / 54
A=
1
K +M
h2
where
M = diag(q1 , q2 , . . . , qN )
and K is a tri-banded symmetric diagonal matrix
K =
()
2
1
0
0
0
1 0
0 0
2 1 0 0
1 2 1 0
0 1 2 1
0
0 1 2
22 October 2012
41 / 54
Example
Example
Consider the boundary value problem
y 00 (x ) = sin(x ),
y (0) = 0,
x [0, ],
y () = 0.
()
22 October 2012
42 / 54
Example
Exact solution
sin(x ) dx = cos(x ) + C1
y (x ) =
(cos(x ) + C1 ) dx = sin(x ) + C1 x + C2 .
22 October 2012
43 / 54
Example
Step 1: Subdivide the domain
xR xL
=
= .
N +1
3
3
So that
h=
()
22 October 2012
44 / 54
Example
Step 2: Nodal Points
j = 0, . . . , N + 1
xj = j ,
3
j = 0, . . . , 3
Or,
x0 = 0,
()
x1 =
,
3
x2 =
2
,
3
x3 = .
22 October 2012
45 / 54
Example
Step 3: Discretize Equation
()
1
(wj+1 2wj + wj1 )
h2
22 October 2012
46 / 54
Example
Step 3: Discretize Equation
1
(wj+1 2wj + wj1 ) = sin(xj ),
h2
j = 0, . . . , 3
()
w3 = 0.
22 October 2012
47 / 54
Example
Step 3: Discretize Equation
1
(w2 2w1 + w0 ) = sin(x1 ),
h2
h2 .
3
(2w1 w2 ) = sin
()
22 October 2012
48 / 54
Example
Step 3: Discretize Equation
For j = 2 we have
1
(w3 2w2 + w1 ) = sin(x2 ),
h2
2
3
2
(2w2 w1 ) = sin
h2
3
()
22 October 2012
49 / 54
Example
Step 4: Matrix Equation
"
w=
()
w1
w2
"
f=
sin 3
sin 2
3
#
22 October 2012
50 / 54
Example
Step 4: Matrix Equation
A is a 2 2 matrix:
"
A=
2 1
1 2
()
2 1
1 2
#"
w1
w2
"
sin 3 h2
2
sin 2
3 h
22 October 2012
51 / 54
Example
Step 5: The approximation
w1
w2
1
=
3
"
2 1
1 2
#"
sin 3 h2
2
sin 2
3 h
0.9497
0.9497
Plugging in h = 3 , we have
"
()
w1
w2
"
3
2
3
2
2
3
2
3
#
"
22 October 2012
52 / 54
Example
Step 6: The errors
Thus we have
y=
y0
y1
y2
y3
0
sin
3
=
sin 2
3
=
3
yw =
()
y0
y1
y2
y3
w0
w1
w2
w3
3
2
=
23
0
0
0.9497
0.0837
0.9497 0.0837
22 October 2012
53 / 54
Material addressed
Review
Application of methods
Truncation error
()
Material in book:
Chapter 6, Sections 9-10
Chapter 7, Sections 1-2
Useful exercises:
Ch 6: 1-11; Ch7: 2a, 3
22 October 2012
54 / 54