Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Department of Signals and Systems

ESS101- Modeling and Simulation


Lecture 15

Paolo Falcone
Department of Signals and Systems
Chalmers University of Technology
Gteborg, Sweden

Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

Today (Chapters 4, 5)

Department of Signals and Systems

Linear Multistep Methods


Trapezoidal rule
The Adams-Bashforth method
Two-step methods
Consistency
Convergence and Zero-stability

Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

Basics on simulation (IVP)

Department of Signals and Systems

We assume the mathematical model is in the form

x (t) = f (t, x(t),u(t))


By assuming that u(t) is a known function of the time

x (t) = f (t, x(t))

The problem of simulating the model x = f (t, x(t))


can be formulated as follows

the initial condition x(0), finding a sequence of


Given
points x1, x2,xtf approximating
the solution x at the

time instants 0<t1<t2<<tf, i.e., the x(t1), x(t2),, x(tf)


Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

Department of Signals and Systems

FE and TS(p) methods


For FE

xn+1 = xn + hx!n
En = O(h)

For TS(p)

1 i (i)
xn+1 = xn + h x n
i=1 i!
p

En = O(h )

But, TS(p) methods require high order derivative


of the rhs
Impratical for larger ODE and when an analytical
expression of x! is not available
Idea. Achieve accuracy of TS(p) methods by
exploiting previous solutions rather than higher
order derivatives
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

Trapezoidal rule

Department of Signals and Systems

Idea. Achieve accuracy of TS(p) methods by exploiting


previous solutions rather than higher order derivatives
Calculate the Taylor expansion

x! (t + h) = x! (t) + h!!
x(t) + O(h 2 )
Substitute h!!
x(t) = x! (t + h) x! (t) + O(h 2 ) in

1 2
x(t + h) = x(t) + hx! (t) + h !!
x(t) + O(h 3 )
2!

1
xn+1 = xn + hx!n + h ( x!n+1 x!n )
2
1
= xn + h ( fn+1 + fn )
2

Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

Trapezoidal rule

Department of Signals and Systems

1
Note that in xn+1 = xn + h ( fn+1 + fn )
2
We need to calculate fn+1 = f (tn+1, xn+1 )
That is, xn+1 is on both left and right hand sides
We may not have an explicit expression of xn+1 as function
of the previous samples (implicit method)

Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

Implicit and explicit methods

Department of Signals and Systems

In general, an algorithm for solving a differential equation


(or ODE solver) can be expressed as

x n +1 = G(t, x n k +1, x n k +2 ,, x n , x n +1 )
Implicit method

k-steps method

x n +1 = G(t, x n k +1, x n k +2 ,, x n , x n +1 )
This equation needs to be solved to find xn+1

Explicit method

x n +1 = G(t, x n k +1, x n k +2 ,, x n )
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

Department of Signals and Systems

2-step Adam-Bashforth method (AB(2))


Instead of

x! (t + h) = x! (t) + h!!
x(t) + O(h 2 )

calculate the Taylor expansion as

x! (t h) = x! (t) h!!
x(t) + O(h 2 )
The resulting iteration is

1
xn+1 = xn + hx!n + h ( x!n x!n1 )
2
1
= xn + h (3 fn fn1 )
2
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

Department of Signals and Systems

Example. Comparison of AB(2) and TS(2)


Simulate the system
x! (t) = (1 2t)x(t), x(0) = 1

over the time interval 0 t 0.9


Recall the exact solution x(t) = e

2
1 1
t
4 2

The iteration is

1
xn+2 = xn+1 + h (3 fn+1 fn )
2
1
= xn+1 + h 3 (1 2tn+1 ) xn+1 (1 2tn ) xn
2
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

Department of Signals and Systems

Example. Comparison of AB(2) and TS(2)


For n=0

1
x2 = 1+ h (1 2h ) x1 h
2

How do we calculate x1?


1. x1 = (1+ h ) x0

Euler (ABE)

1
2. x1 = x0 + h (1 2t1 ) x1 + (1 2t0 ) x0
2
1+ 1 (1 2t0 )
2
x1 =
x0 Trapezoidal rule (ABT)
1 1 (1 2t1 )
2
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

10

Department of Signals and Systems

Example. Comparison of AB(2) and TS(2)


h=0.2

103GE@ t=1.2

En h
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

11

Department of Signals and Systems

Two-step methods. Consistency

More in general

xn+2 + 1 xn+1 + 0 xn = h ( 2 fn+2 + 1 fn+1 + 0 fn )


that is consistent and of order p if
x(t + 2h) + 1 x(t + h) + 0 x(t) h [ 2 x! (t + 2h) + 1 x! (t + h) + 0 x! (t)] = O(h p+1 )
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

12

Department of Signals and Systems

Two-step methods. Consistency

Definition (Consistency). A two-step LMM method is


consistent if a p>0 exists such that
x(t + 2h) + 1 x(t + h) + 0 x(t) h [ 2 x! (t + 2h) + 1 x! (t + h) + 0 x! (t)] = O(h p+1 )

Otherwise, it is inconsistent.
Example. The Euler method
The n-th iteration xn+1 = xn + hfn stems from

x(t + h) = x(t) + hx! (t) + O(h 2 )


x(t + h) x(t) hx! (t) = O(h 2 )
Hence, the method is consistent of order p=1
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

13

Example. Consistency

Department of Signals and Systems

Determine the consistency order of the integration method


(last in the table)

xn+2 + 4xn+1 5xn = h ( 4 fn+1 + 2 fn )


We have to find the p in

x(t + 2h) + 4x(t + h) 5x(t) h [ 4 x! (t + h) + 2 x! (t)] = O(h p )


Lets expand in Taylor series the terms on the lhs
4 3
2 4 (4)
2
!
!!
!!!
x(t + 2h) = x(t) + 2hx + 2h x(t) + h x (t) + h x (t) + O(h 5 )
3
3
1 2
1 3
1 4 (4)
x(t + h) = x(t) + hx! + h !!
x(t) + h !!!
x (t) + h x (t) + O(h 5 )
2
6
24
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

14

Example. Consistency

Department of Signals and Systems

1 2
1 3 (4)
x! (t + h) = x! (t) + h!!
x(t) + h !!!
x (t) + h x (t) + O(h 4 )
2
6

By summing up the and collecting the terms


x(t + 2h) + 4x(t + h) 5x(t) h [ 4 x! (t + h) + 2 x! (t)] =

(1+ 4 5) x(t) + h 2 + 4 ( 4 + 2) x! (t)


4
1
1
+h [ 2 + 2 4] !!
x(t) + h + 4 4 !!!
x (t)
3
6
2
1
1 (4)
4 2
+h + 4 4 x (t)
3
24
6
2

Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

15

Example. Consistency

Department of Signals and Systems

After simplification
x(t + 2h) + 4x(t + h) 5x(t) h [ 4 x! (t + h) + 2 x! (t)] =
1 4 (4)
h x (t) + O(h 5 )
6

1 4 (4)
h x (t) is dominating and O(h 5 ) can be neglected
6
1 4 (4)
h x (t) = O(h 4 ) and the method is of order 3
6

Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

16

Department of Signals and Systems

Two-step methods. Consistency conditions

Theorem (consistency conditions for two-step LMMs).


Given the two-step LMM

xn+2 + 1 xn+1 + 0 xn = h ( 2 fn+2 + 1 fn+1 + 0 fn )


define the two polynomials

(r) = r 2 + 1r + 0
(r) = 2 r 2 + 1r + 0

The method is consistent if and only if

(1) = 0, '(1) = (1)


Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

17

Two-step methods. Necessary condition for


convergence

Department of Signals and Systems

Theorem (necessary condition for convergence). A


convergent LMM is consistent.
A consistent LMM is not guaranteed to be convergent

Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

18

Department of Signals and Systems

Example

Solve the IVP x! (t) = x(t), x(0) = 1 with the LMM

xn+2 + 4xn+1 5xn = h ( 4 fn+1 + 2 fn )


with h=0.1, 0.01, 0.001
The LMM can be rewritten as

xn+2 + 4xn+1 5xn = h ( 4xn+1 + 2xn )


and rearranged as

xn+2 = 4(1+ h)xn+1 + ( 5 2h ) xn


Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

19

Department of Signals and Systems

Example

No matter how small is h, the solution oscillates

Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

20

Department of Signals and Systems

k-step methods
The two-step LMM

xn+2 + 1 xn+1 + 0 xn = h ( 2 fn+2 + 1 fn+1 + 0 fn )


can be generalized to k-step LMM

xn+k + k1 xn+k1 +!+ 0 xn = h ( k fn+k + k1 fn+k1 +!+ 0 fn )


Given the starting values x0 , x1,, xk1
Any method is required to converge as h0
That is, the approximated solution should be equal to the
actual as h0
Convergence is required also for x1,, xk1, since they are
calculated with a numerical method as well
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

21

k-step methods. Consistency

Department of Signals and Systems

In order to have convergence, we must have consistency


Define the polynomials
k

(r) = i r i , k = 1 and (r) = i r i


i=0

i=0

The consistency conditions become


k

k
i

i=0

Paolo Falcone (CHALMERS)

= 0, k = 1, and i i = i
i=0

ESS101 Modeling and Simulation

i=0

October 3, 2015

22

Department of Signals and Systems

Example

Solve the IVP x! (t) = 0, x(0) = 1 with the LMM

xn+2 + 4xn+1 5xn = h ( 4 fn+1 + 2 fn )


Use x1 = 1+ h
The LMM becomes xn+2 + 4xn+1 5xn = 0
Note that the polynomial (r) = r 2 + 4r 5 has two roots
r=1 and r=5
The solution of the equation is xn = A + B(5)n where A, B
are determined from the initial condition and x1
xn diverges while it should be constant and equal to 1
Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

23

Department of Signals and Systems

Convergence and Zero-stability

Definition (Zero-stability). A LMM is zero stable if all the


roots of
k

(r) = i r i , k = 1
i=0

satisfy the condition r 1 (root condition)


and the ones satisfying r = 1 have multiplicity 1
Theorem (necessary and sufficient condition for
convergence). A LMM is convergent if and only if is
consistent and zero-stable

Paolo Falcone (CHALMERS)

ESS101 Modeling and Simulation

October 3, 2015

24

You might also like