Integration
Integration
Lecture 8:
Numerical Integration
Outline
One-step Method for ODE (IVP)
Forward Euler
Backward Euler
Trapezoidal Rule
Equivalent Circuit Model
Linear MultiStep Method
Convergence Analysis
Consistence
Stability
Time Step Control (next lecture)
Stability Region
Stiff System
Dynamic Time Step Control
Over-Relaxation Method & ADI
dy
We shall assume that F ( , y, t ) 0 has a unique solution
dt
Also, for sake of simplicity only consider dx ( t )
linear case: Ax (t )
dt
x (t0 ) x0
September 18, 2023 5 courtesy Alessandra Nardi UCB
Finite Difference Methods
Basic Concepts
First - Discretize Time t t t
0 t1 t2 t L 1 t L T
Second - Represent x(t) using values at ti
x̂ 2 x̂ 3
4 ˆ
x l
x (t )
x̂1 x̂ l
Approx. Exact
sol’n sol’n
0 t1 t2 t3 tL
d ˆ l
Third - Approximate x(tl ) using the discrete x 's
dt
dx(tl ) x l x l 1 x l 1 x l
For example : or
dt tl tl
September 18, 2023 6 courtesy Alessandra Nardi UCB
Forward Euler Approximation
d
slope x(tl )
x dt
d x(tl 1 ) x(tl )
x(tl ) A x(tl )
dt t
x(tl 1 ) x(tl ) or
slope
t x(tl 1 ) x(tl ) t A x(tl )
tl tl 1 t
1
x (t1 ) xˆ x (0) tAx (0) x
x (t2 ) xˆ 2 x1 tAx1
tAxˆ1
L L 1 L 1 tAx (0)
ˆ
x (tL ) x x tAx
t1 t2 t3 t
d
slope x(tl 1 )
x dt
d x(tl 1 ) x(tl )
x(tl 1 ) A x(tl 1 )
dt t
x(tl 1 ) x(tl ) or
slope
t x(tl 1 ) x(tl ) t A x(tl 1 )
tl tl 1 t
tAxˆ1
L 1 L 1 t1 t2 t
x (tL ) xˆ [ I tA] x
d
slope x(tl )
dt d
1 d d slope x(tl 1 )
( x (tl 1 ) x (tl )) x dt
2 dt dt
1
( Ax(tl 1 ) Ax (tl ))
2
x (tl 1 ) x (tl )
x (tl 1 ) x (tl ) slope
t
t
1
x (tl 1 ) x (tl ) tA( x (tl 1 ) x (tl )) t
2
1 1
( x(tl 1 ) tAx(tl )) ( x(tl ) tAx(tl 1 ))
2 2
September 18, 2023 11 courtesy Alessandra Nardi UCB
Trapezoidal Rule Approximation
d tl 1
x (t ) A x (t ) x (tl 1 ) x (tl ) Ax ( )d
dt tl
tl 1 t
tl Ax( )d 2 Ax(tl ) Ax(tl ) Trap
tAx (tl 1 ) BE
tAx (tl ) FE
tl tl 1
September 18, 2023 13 courtesy Alessandra Nardi UCB
Equivalent Circuit Model-BE
Capacitor
v (t t ) v (t ) Ct i (t t )
i (t t ) v (t t ) Ct v (t ) Ct
+
+ i ( t t )
+
i (t t )
C v (t t )
I eq C
t v (t )
v ( t t ) Geq C
t -
-
-
v (t t ) i (t t ) Lt i (t ) Lt
+
i ( t t )
+
-
Veq L
i (t )
i (t t ) + t
L v (t t )
v ( t t )
Req L
t
-
-
i (t t ) v (t t ) 2Ct v (t ) 2Ct i (t )
+
+ i ( t t )
+
i (t t )
C v (t t )
v ( t t ) Geq 2C
t - I eq 2C
t v (t ) i (t )
-
-
L v (t t )
v ( t t )
Req 2L
t
-
-
tl k tl 3 tl 2 tl 1 tl Time discretization
Multistep Equation: a x t f ( x j
l j
j
l j
, u(tl j ))
j 0 j 0
0 =0
The first order Adams-Bashforth formula (forward Euler)
x n x n 1 hx n 1
The second order Adams-Bashforth formula
3 1
x n x n 1 h( x n 1 x n 2 )
2 2
0 0
The first order Adams-Moulton formula (backward Euler)
x n x n 1 hx n
The second order Adams-Moulton formula (trapezoidal)
1 1
x n x n 1 h( x n x n 1 )
2 2
xˆ x l t C t
l p
max T
l0,
t
for all t less than a given t0
Forward- and Backward-Euler are order 1 convergent
Trapezoidal Rule is order 2 convergent
September 18, 2023 26 courtesy Alessandra Nardi UCB
Convergence Analysis (1)
C1 t
l p0 1
max T
e for t t0
l0,
t
2) Global Condition: The single step errors do not
grow too quickly (stability)
xˆ x t
1
0 as t 0
t
Noting that d
dt x (0) Ax (0) and subtractin g
1 ( t ) 2 d 2 x ( ) Proves the theorem if
xˆ x ( t ) 2 dt 2 derivatives of x are
bounded
September 18, 2023 31 courtesy Alessandra Nardi UCB
One-step Methods – Convergence
Analysis
Convergence Analysis for Forward Euler
Forward-Euler definition
ˆx11 x l tAx l
Expanding in t about lt yields
x ((l 1) t ) x (lt ) tAx (lt ) el
where e1 is the " one - step" error bounded by
l 2 d 2 x ( )
e C ( t ) , where C 0.5 max [ 0 ,T ] dt 2
l
To prove, first write u as a power series and sum
l 1
u (1 ) b
l j 1-(1 )l
1-(1 ) b
j 0
E l 1 t A E l 1 C ( t ) 2
E 1 t A E
l l 1 2 lt A
C ( t ) e
t A
C ( t ) 2
l AT C
max l[ 0,T ] E e A
t
k k
1
Decoupled j
a y l j
t j yl j
Equations j 0 j 0
n
September 18, 2023 40 courtesy Alessandra Nardi UCB
Linear Multistep Methods
Simplified Problem for Analysis
d
Scalar ODE: dt v t v(t ), v 0 kv0 k
Scalar Multistep formula: ja v l j
j 0
t j
v l j
j 0
Must Consider ALL
Im
O
s
c
i
l
Decaying l Growing Re
Solutions a Solutions
t
i
o
n
s
September 18, 2023 41 courtesy Alessandra Nardi UCB
Multistep Methods – Convergence Analysis
Global Error Equation
k k
Multistep formula: j
a v l j
t j
v l j
0
j 0 j 0
k
d k
Exact solution Almost
satisfies Multistep Formula: j 0
j v t l j
t j
dt
v t l j e
l
j 0
Local Truncation
Error (LTE)
Global Error: E l
v l
t ˆ
v l
Exactness Constraints
d
Suppose v t t v t pt
p p 1
dt
k k
p p 1
Then k j t
j 0
j t j p k j t
j 0
v t k j
d
v tk j
dt
September 18, 2023 43 courtesy Alessandra Nardi UCB
Multistep Methods – Making LTE small
Exactness Constraints
k k
p p 1
Then k j t
j 0
j t j p k j t
j 0
p p 1
k k
p
t j k j j p k j e k
j 0 j 0
k k
p 1
If
p
j k j j p k j 0 then ek 0 for v(t ) t p
j 0 j 0
j 0 j 0
September 18, 2023 44 courtesy Alessandra Nardi UCB
Multistep Methods – Making LTE small
Exactness Constraints – k=2 Example
k p
k
p 1
Exactness Constraints: j k j j p k j 0
j 0 j 0
Backward-Euler 0 1, 1 1, 2 0, 0 1, 1 0, 2 0,
BE satisfies p 0 and p 1 but not p 2 LTE C t
2
-15
10 -4 -3 -2 -1 0
10 10 10 10 10
September 18, 2023 Timestep48 courtesy Alessandra Nardi UCB
Multistep Methods – Making LTE small
0
10
M d
a -2 d v (t ) v (t ) t 0,1
10
x
E -4 FE
r 10
r Where’s BESTE?
-6
o 10
Trap
r
-8
10 -4 -3 -2 -1 0
10 10 10 10 10
Timestep
September 18, 2023 49 courtesy Alessandra Nardi UCB
Multistep Methods – Making LTE small
200
worrysome
M 10
d Best Explicit Method has
a v (t ) v (t ) lowest one-step error but
x 100 d global errror increases
as timestep decreases
E 10 Beste
r
r 0
o 10
r FE Trap
-100
10 -4 -3 -2 -1 0
10 10 10 10 10
Timestep
September 18, 2023 50 courtesy Alessandra Nardi UCB
LMS: Stability
v l t vˆ l
LTE
Global Error
We made the LTE so small, how come the Global
error is so large?
September 18, 2023 51 courtesy Alessandra Nardi UCB
Convergence
Convergence for one-step methods
Consistency for FE
Stability for FE
Convergence for multistep methods
Consistency (Exactness Constraints)
Selecting coefficients
Stability
Region of Absolute Stability
Dahlquist’s Stability Barriers
a0
Most important difference equation result
l
x can be related to u by x h u l l j j
j 0
September 18, 2023 53 courtesy Alessandra Nardi UCB
An Aside on Solving Difference Equations
k k 1
If a0 z a1 z ak 0 has distinct roots
1 , 2 , , k
l k
Then x h u where h j j
l l j j l l
j 0 j 1
To understand how h is derived, first a simple case
l l 1 l 0
Suppose x = x u and x 0
1 0 1 1 2 1 2 1 2
x = x u =u , l x x u u u
x = u
l l j j
C1 t
l p0 1
max T
e for t t0
l0,
t
2) Global Condition: One step errors grow slowly (stability)
k
roots of j z k j
0 must be inside the unit circle
j 0
T
max T E C2 max T el
l
l0,
t
t l0,
t
t
September 18, 2023 56 courtesy Alessandra Nardi UCB
Multistep Methods – Stability
Difference Equation
Multistep Method Difference Equation
0
t 0 E l
1
t 1 E l 1
k
t k E l k
e l
0
t 0 E l
1
t 1 E l 1
k
t k E l k
e l
Re
-1 1
k
roots of j
j 0
t j z k j
0 for a nonzero t
September 18, 2023 59 courtesy Alessandra Nardi UCB
Multistep Methods – Stability
A more formal approach
k k
j 0
j j t x
ˆ l j
0 j j q xˆ l j 0 ( 1 )
j 0
Def: A method is stable if all the solutions of
the associated difference equation obtained
from (1) setting q=0 remain bounded if l
The region of absolute stability of a method
is the set of q such that all the solutions of
(1) remain bounded if l
Note that a method is stable if its region of
absolute stability contains the origin (q=0)
Froward Euler j
x n x n 1 hx n 1 h unstable
x n 1 x n 1 -1 0
stable
x n x n 1 hx n 1
n
x n (1 h ) x n 1 (1 h ) x0
Region of
Difference Eqn
Stability region
Re(z) 2
Absolute Re
-1 1 Stability
t
Backward Euler j
x n x n 1 hx n stable h
1-h
x n x n 0 1
unstable
x n x n 1 hx n
1 1 n
xn x n 1 ( ) x0
1 h 1 h
Difference Eqn
Stability region
Re(z)
-1 1
Region of
Absolute
Stability
Trapezoidal stable
j
h
x n x n
-1 0 1
x n x n 1 hx n unstable
1 1 n
xn x n 1 ( ) x0
1 h 1 h