60
System Identification and Simulation Prof.Ing.Petr Noskievič, CSc.

IaSS 10-A 2013-4-11

Embed Size (px)

DESCRIPTION

S

Citation preview

  • System Identification and Simulation

    Prof.Ing.Petr Noskievi, CSc.

  • Modeling of the functions relationship between the variables

    Static characteristics of the systems, Input signals (desired value) , Initial funtions for the delayed variables.

    (x)

    y = f(x) (x) = ?

    (x) [xn, fn]

    [xi+1, fi+1][xi, fi]

    [x1, f1][x0, f0]

    y = f(x)

    xb

    x

    xx

    xx

    a

    Set of points [xi, f(xi)], i = 0, 1, 2, ..., n

  • Approximation Aproximac funkce f(x)

    Weighted criterion

    ( ) ( ) ( )E x f x x= pro x a, bError of the approximation

    ( ) ( ) ( ) 22

    1

    12n

    i i ii

    nf f x x, =

    =

    ( ) x a b x= + Linear regression

    ( ) ( ) ( ) 2 21

    12n

    i ii

    nf f x a b x, = +

    =

    ( ) ( )[ ]S f x a b xi ii

    n= +

    =

    2

    1

    Sa

    Sb

    = =0 0, .Conditions for the minimum:

  • Linear regression

    ( )[ ]( )Sa

    y a bx y n a b xi ii

    n

    i ii

    n

    i

    n= + = +

    = ==

    2 1 21 11

    ( )[ ]( )Sb

    y a bx x x y a x b xi i ii

    n

    i i ii

    n

    ii

    n

    i

    n= + =

    = = ==

    2 21 1

    2

    11

    ( )n a b x f xii

    n

    ii

    n + =

    = = 1 1

    ( )a x b x x f xii

    n

    ii

    n

    i ii

    n

    = = = + = 1

    2

    1 1

    System of linear equations

    ( ) ( )b

    x f xn

    x f x

    xn

    x

    i ii

    n

    ii

    n

    ii

    n

    ii

    n

    ii

    n=

    = = =

    = =

    1 1 1

    2

    1 1

    2

    1

    1a y b x= ( )x n x y n f xii

    n

    ii

    n= =

    = = 1 1

    1 1,

  • Linear regression

    ( ) ( )

    ( ) ( )

    rn x f x x f x

    n x x n f x f x

    xy

    i ii

    n

    ii

    n

    ii

    n

    ii

    n

    ii

    n

    ii

    n

    ii

    n=

    = = =

    = = = =

    1 1 1

    2

    1 1

    22

    1

    2

    1

    Correlation coefficient: A measure for the quality of the approximation

    y

    x

    y

    x

  • Linear Regression ( ) x a a x a x xn= + + +0 1 1 2 2 ... +anMultiple regression:

    ( ) x a a x a x xn= + + +0 1 22 ... + an

    Criterion:

    Polynomial regression:

    ( ) ( )[ ]S a y a a x xi nni

    n

    0 0 1 12

    1, , a ..., a ... + a1 n n= + +

    =

    Conditions for the minimum of the criterion S are expressed as follows:

    ( )[ ]S

    ay a a x x x

    ki i

    n

    i

    n

    ik= + + =

    =2 00 1 1

    0 ... + an

    System of n+1 equations for the coeficients a0, ..., an

    a x a x a x y xik

    i

    n

    ik

    i

    n

    n ik n

    i

    n

    i ik

    i

    n

    00

    11

    0 0 0=

    +

    =

    +

    = = + + = ... +

    pro k = 0, 1, ..., n:

  • Interpolation of the funtions

    ( ) ( ) n ..., 2, 1, 0,=i , forxfx ii =Interpolation condition:

    Interpolationg Lagrange Curve ( ) ( ) ( )

    =

    =n

    iiin xlxfxL

    0

    where li(x) are the polynomials degree n , for which is valid:

    ( )( )

    l x pro k

    l x pro ki k

    i k

    =

    = =

    0

    1

    i,

    i.

    ( )( )( ) ( )( ) ( )

    ( )( ) ( )( ) ( )l xx x x x

    x x x xi i i=

    0 1

    0 1

    ... x - x x - x ... x - x ... x - x x - x ... x - x

    i-1 i+1 n

    i i-1 i i+1 i n

    The interpolationg curves are designed to run through all given points.

  • Interpolation of the funtions Newton Interpolating Polynomial

    ( ) ( ) ( )( ) ( )( ) ( )N x a a x x a x x x x x x x x= + + + 0 1 0 2 0 1 0 1 ... + a ... x - xn n-1( ) ( )N x f x ii i= =, 0, 1, 2, ..., n

    ( )( ) ( )( ) ( )( ) ( )

    ( ) ( )( ) ( ) ( )

    a

    a a x x f x

    a a x x a x x x x f x

    a a x x a x x x x x f xn n n n n n

    0

    0 1 1 0 1

    0 1 2 0 2 2 0 2 1 2

    0 1 0 0 1 1

    = f x

    ... + ... x

    0

    n

    + =

    + + =

    + + =

    .

    .

    .

    ( )a

    f x ax x11 0

    1 0=

  • Spline function y = f(x) {(x)}i = 0, 1, ..., n-1

    i(x) = ai+bi(x-xi)+ci(x-xi)2+di(x-xi)3

    (x)y = f(x)

    x

    fn-2

    xn-2

    fn-1

    xn-1

    fi+1

    xi+1

    fn

    xn

    fi

    xi

    f2

    x2

    f1

    x1

    f0

    x0

    ( ) ( ) ( ) ( )i i i i i i i ix a b x x c x x d x x= + + + 2 3

    Cubis spline-function

    The given set of points is interpolated using the series of the of the unique cubic polynomials. Between each of two given points the cubic polynomial has another set of coefficients. The whole interpolation is done using the set of the interpolating functions called spline function.

    Each cubic polynomial has degree 3 and is described by the set of four coefficients: ai, bi, ci, di. For n intervals it is to design 4n coefficients.

  • Spline function The set of n+1 inperpolation conditions will be used for the derivation of the coefficients.

    ( ) ( ) x f x ii i= =, 0, 1, ..., nThe spline function fullfils 3(n-1) conditions of the continuity of the cubic polynomials in form:

    ( ) ( ) i i i ix x i = =1 , 1, 2, ...n -1( ) ( ) 1-...n 2, 1,,1 == ixx iiii ( ) ( ) 1-...n 2, 1,,1 == ixx iiii

    Now we have 4n-2 conditions for 4n coefficients, which values should be derived. The last two conditions can be set as following condition in the end points :

    ( ) ( )a x f x fn n) = = 0 0

    ( ) ( ) nn fxfxb == 00)

    ( ) ( ) 00) 0 == nxxc ... So called natural spline

    First derivative: Second derivative:

  • Spline function

    The derivatives of the polynomials i(x) are continuos functions.

    ( ) ( ) ( ) = + + i i i i i ix b c x x d x x2 3 2

    ( ) ( ) = + i i i ix c d x x2 6

    ( ) = = x M ii i , 0, 1, ..., n

    h x x ii i i= =+1 0, 1, ..., n

    ( ) = =i i i ix c resp M2 , . 2ci( ) = + + =+ +i i i i i i i ix c d h resp d h M1 12 6 6, . 2ci

    The coeficients ci, di can be derived from these equations:

    cM

    ii=2

    dM M

    hii i

    i=

    +16 ii fa =

  • Spline function ( )i i i i i i i i ix a b h c h d h+ = + + +1 2 3Next for x=xi+1:

    f a b h c h d hi i i i i i i i+ = + + +12 3

    bf fh

    M Mhi

    i i

    i

    i ii=

    ++ +1 126

    After substitution for the coefficients ai, ci, di we obtain the expression for the coefficient bi:

    ( )a f xi i=The equations for the coefficient of the polynomials expressed using Mi for the second derivative:

    ( ) ( )b

    f x f xh

    M Mhi

    i i

    i

    i ii=

    ++ +1 126

    cM

    ii=2

    dM M

    ii i

    i=

    +16h

    pro i = 0, 1, ..., n-1.

  • Spline function The calculation of the second derivatives Mi is based on the use of the condition for the continuity of the first derivative :

    ( ) = + +

    i ii i

    ii i i ix

    f fh

    M h M h11

    11 1 1

    16

    13

    ( ) = + ++ +1 1 12

    6x

    f fh

    M Mhi

    i i

    i

    i ii

    The equation must be fullfiled in the inner given points: for i = 1, 2, ..., n-1 :

    ( )16

    13

    161 1 1 1

    1 1

    1M h h h M M h

    f fh

    f fhi i i i i i i

    i i

    i

    i i

    i +

    +

    + + + =

    ( )( )

    ( )

    ( )

    2 02

    2

    0 2

    0 1 1

    1 1 2 2

    1 1

    2 2 1

    1

    2

    1

    h h hh h h h

    h h h h

    h h h

    MM

    M

    M

    i i i i

    n n n

    i

    n

    +

    +

    +

    +

    . . . . . ..

    . . . . .

    . . . . .

    . .

    . . . . .

    . . . . .

    . . . .. . . . . .

    .

    .

    .

    .

    .

    =

    +

    6

    6

    6

    6

    2 1

    1

    1 0

    00 0

    3 2

    2

    2 1

    1

    1 1

    1

    1

    1

    1 2

    2

    f fh

    f fh

    M h

    f fh

    f fh

    f fh

    f fh

    f fh

    f fh

    i i

    i

    i i

    i

    n n

    n

    n n

    n

    .

    .

    .

    .

    .

  • If also the values of the first derivative fi(xi) are given, the spline function is called Hermits spline function and in the given points should be also fulfilled the condition:

    Spline function

    The calculation of the spline function can be described in the next steps: 1. Input data: n, x0, x1, ..., xn, f(x0), f(x1), ..., f(xn). 2. calculation hi = xi+1 - xi, pro i = 0, 1, ..., n-1. 3. Creating of the systm of the linear algebraic equations, settinf of M0, Mn. 4. Calculation Mi, i = 1, 2, ..., n-1 solution of the equations. 5. Calculation of the coefficients in the for each interval. The calculation of the value of the spline function in the given point is realized in

    two steps: 1. The interval (index i) in which the value x is located. 2. Calculation of the of the cubic function i (x) for given value x.

    = fi i

  • Next applications

    y = f(x)

    x

    uzaven kivkasmykaperiodick kivka

    y = f(x)

    x

    y = f(x)

    x

    Periodic function General curve in 2D Closed figure

  • Periodic spline function

    y

    xx1

    ynyn = y0

    y0

    x0 x2

    ( ) ( ) 0 0 1x xn n= ( ) ( ) = 0 0 1x xn n( ) ( ) = 0 0 1x xn n

  • Periodic spline function We have now a system of n-linear algebraic equations for n second derivatives variables M0, M1, ..., Mn-1 (periodic spline-function).

    ( )

    ( )

    ( )

    2

    20

    2

    60 1 0 1

    0

    0 1 1

    1 2 2 1

    0

    1

    1

    1h h h h

    hh h h

    h h h h

    M

    M

    M

    yn n

    n n n n n

    +

    +

    +

    =

    . . . . . .. . .. . .. . .

    .. .. . . .. . . .

    . . . . . .

    .

    .

    .

    .

    .

    .

    yh

    y yh

    y yh

    y yh

    y yh

    y yh

    n n

    n

    n n

    n

    n n

    n

    0

    0

    1

    1

    2 1

    1

    1 0

    0

    1

    1

    1 2

    2

    6

    6

    .

    .

  • Curve parameterization Let we have a set of given points [xi, yi] and the variable x is not monotonously growing up for growing index i, that means, it is not valid:

    x x x x x xn n n> > > > > > 1 2 2 1 0 ...

    For the derivation of the spline we divide th set of points into the two sets:

    [ ] [ ] [ ] [ ]t t t tn0 1 2, , , , , , , x x x ..., x0 1 2 n[ ] [ ] [ ] [ ]t t t tn0 1 2, , , , , , , y y y ..., y0 1 2 n

    t t t tn0 1 2< < < < ...

    The curve is described in 2-dimensional space. The new two sets of points [ti, xi] and [ti, yi] we can now interpolate by two spline functions.

  • Curve parameterization t0 0=

    t t di i i+ = +1 , i = 0, 1, 2, ..., n -1

    The parameterization can be done using one of the following formulas for the difference (distance) between two points di:

    ( ) ( )d x x y yi i i i i= + + +12

    12

    ( ) ( )d x x y yi i i i i= + + +12

    12

    d x x y yi i i i i= + + +1 1

    ( )d x x y yi i i i i= + +max , ,1 1 i = 0, 1, 2, ..., n -1

  • Interpolation using the parametric spline

    The use of the parametric spline function can be summarized in the following steps:

    1. Curve parameterization seting t0, t1, ..., ti, ..., tn for each point . 2. Calculation of Mxi, Myi - using two created systems of linear equations. 3. Calculation of the coefficients of the spline function of x and spline

    function of y. 4. Calculation of x and y for growing t.

  • Interpolation using the parametric spline

    109

    7

    6

    t5

    43 = 8

    2

    1

    0

    y

    x

    [x3, y3] = [x8, y8][x1, y1]

    [x0, y0]x

    x

    x

    x

    x

    xx

    x

    x

    x

  • Interpolation of the closed figures (cyclic splines)

    10

    9

    8

    7

    6

    t5

    4

    3

    2

    1

    0 = 11

    x

    x

    x

    x

    x

    x

    x

    x

    x

    x

    x

    y

    x

    [ ] [ ] [ ] [ ]t t t tn0 1 2, , , , , , , x x x ..., x0 1 2 n

    [ ] [ ] [ ] [ ]t t t tn0 1 2, , , , , , , y y y ..., y0 1 2 nx x yn n0 = = , y0It is valid :

  • Numerical Integration Methods

    ( ) ( )f x dx x dx Ra

    b

    a

    b

    +

    The numerical methods of integration are used if: it is not possible to calculate the integral analytically , analytical approach is to complicated, the function is given using the table or graph.

    If the function (x) is a good approximation of the function f(x) , then the integral calculated from the function (x) is a good approximation of the integral of f(x).

    The numerical methods of integration are based on the use of approximation methods. The given function which should be integrated f(x) is substituted by their approximation (x). The integration is calculated for this function:

  • Numerical integration methods Quadrature rule

    ( ) ( )f x dx Ra

    b

    i

    n

    +=

    h f xi0

    1

    ( ) ( )R b anf x f xn=

    0

    ( )f x dxh

    Ra

    b

    i

    n

    +

    +

    =

    h f xi 20

    1

    If the function is given analytically, the more precise formula can be used:

    ( )Rb a

    h f xa

    24

    2 max, b

    y = f(x)

    (x) = f(xi)

    y

    x

    ynyn-1yn-2

    xn-2 xn-1xi+1 xn=bxi

    yi+1yi-1 yi

    xi-1x1

    y1y0

    x0=a

    We suppose that the function f(x) is given in n+1points with constant step h. In each interval we replace the function with their interpolationg function (x) = f(xi):

  • Numerical integration methods Trapezoidal method

    The given function is replaced in the partial intervals by the polynomial function first order. For the Newton's polynomial we obtain:

    ( ) ( ) ( ) ( ) ( )i i i ii i

    ix f xf x f xx x

    x x= +

    +

    +

    1

    1

    ( ) ( ) ( )[ ]f x dx f x f xx

    x

    i ii

    i+

    + +1

    1 h2

    After integration:

    y = f(x)

    i(x)

    y

    x

    ynyn-1yn-2

    xn-2 xn-1 xn=b

    yi-1

    xi+1xi

    yiy0

    x0=a

    ( ) ( ) ( ) ( ) Rxfxfxfdxxf nn

    ii

    b

    a

    +

    ++

    =

    1

    10 2

    121h

    ( )Rb a

    h f xa

    12

    2 max, b

    For the whole interval a, b, respectively :

  • Numerical integration methods Quadratic function

    The Simpson's method is base on the use of quadratic function for the interpolation of the given function in the partial intervals xi, xi+2.

    ( )( )( )

    f x dx fx x

    hf x x x x

    hdx

    x

    x

    ii i i i

    i

    i+

    +

    +

    +2 2

    122

    fix

    x

    i

    i+2

    ( ) [ ]f x dx f f fx

    x

    i i ii

    i+

    + ++ +1

    4 1 2 h3

    ( ) [ ]f x dx f f f f f f Ra

    b

    n n + + + + + + + h3

    ... + 2fn-20 1 2 3 14 2 4 4

    Starting from the Newtons polynomial we obtain:

    y

    x

    yi yi+2yi+1

    xnxi xi+2xi+1xi-1

    i(x) y = f(x)

    ( )( )Rb a

    h f xa

    1804 4max

    , b

    By this method the number n must be even number, that means, that the function f(x) must be given in odd number of points, in n+1points .

  • Numerical methods for computing of the derivation

    The calculated numerical derivation (x) of the good approximation function (x) of the given function f(x) can be good approximation of the derivation f(x), but this is not guaranteed in general. The influence of the noise must be taken into the account. .

  • Numerical methods for computing of the derivation

    Computation of the derivation using the polynomial functions

    The given function xi , f(xi) is replaced by the interpolation polynomial, for ex. By the Newton's polynomial, by the numerical calculation of the derivation. The approximately values of the derivation we obtain from the derivation of the interpolation polynomial. The degree of the interpolation polynomial must be higher than the order of the calculated derivation.

    For the derivation order k of the Newton's polynomial expressed using the differences we obtain:

    ( ) [ ]( ) [ ]( )( )[ ]( )( ) ( )

    N x f f x x x f x x x x x

    f x x x x x

    = + + +

    +

    0 0 0 0 0 1

    0 0 1

    , , ,

    , , .

    x x x ... +

    x ..., x ... x x1 1 2

    1 n n-1

    ( ) ( ) [ ] ( )( ) ( ){ }

    [ ] ( )( ) ( ){ }

    N x f xddx

    x x x x

    f xddx

    x x x x

    kk

    k

    k

    k

    = +

    +

    0 0 1

    0 0 1

    , ,

    , , .

    x ..., x ... x x ... +

    x ..., x ... x x

    1 k k

    1 k n-1

    The difference order k is expressed by:

  • Formulas for numerical derivation

    The next formulas for computing of the numerical derivation from two or three points of the given function were derived in the described way:

    ( )( ) ( )

    f xf x

    hhM

    f x + h 12 2

    ( )( ) ( )

    +f xf x hh

    hM f x 1

    2 2

    ( )( ) ( )

    +f xf x h

    hh M

    f x + h2

    16

    23

    ( )( ) ( ) ( )

    + + +

    +f xf x h f x h

    hh M

    - 3f x 4 22

    13

    23

    ( )( ) ( ) ( )

    +

    +f xf x h f x h

    hh M

    3f x 4 22

    13

    23

  • Formulas for numerical derivation

    ( )( ) ( ) ( )

    +

    +f xf x f x hh

    h M

    f x + h 21222

    4

    ( )( ) ( ) ( )

    +

    +f xf x h f x h

    hhM

    f x 2 22 3

    ( )( ) ( ) ( ) ( ) ( )

    + +

    + + +

    f xf x h f x h f x h

    hh

    12f x 30 24 2 6 3

    602

    2

    ( )( ) ( ) ( ) ( ) ( ) ( ) + + + + +f x f x h f x f x h f x h

    hh

    - f x - 2h 16 30 16 212

    024

    ( ) ( )M f xia

    i= max, b

    The computation of the derivation second order can be calculated using the formulas:

    ( )( ) ( ) ( )

    + +

    f xf x h f xh

    hM f x + 2h 2

    2 3

  • Formulas for numerical derivation Numerical calculation of the derivation using the spline-function

    The spline function can be used for the computing of the derivation and also derivation higher order. The first and second derivative of the cubic spline function cubic polynomial are the continuous functions, which are also the approximation polynomials of the derivations.

    ( ) ( ) ( ) ( )F x a b x x c x x d x xi i i i i i i: i = 0, 1, 2, ..., n -1

    i = + + + 2 3

    ( ) ( ) ( ) = + + F x b c x x d x xi i i i i: i = 0, 1, 2, ..., n -1

    i 2 32

    Derivation:

  • Numerical Methods for Solving Differential Equations

    The numerical solution of the differential equations with the initial conditions (so called Cauchy task) is one of the very important tasks for the realization of the mathematical model using the digital computer and simulation programme. Let we have to solve a differential equation

    ( )y ,tfy =! with initial condition y0 = y(t) for time t from the interval .

    The numerical solution is a sequence of the values ( ){ } ( ) ( )y t y ti = 0 , , y t ...1Where ti is from the mentioned interval. The value hi is a step of the numerical solution: h t t ii i i= =+1 , 0, 1, 2, ...

    The values of the independent variable ti, at which the numerical solution of the differential equation is calculated, define so called node points of the solution.

  • Numerical Solution of the Differential Equation

    hi=ti+1-ti

    t

    y yi yi+1

  • Errors of the numerical solution

    Local error EL(ti) has two parts:

    ET(ti) - error of the method - trunsaction error, ER(ti) - rounding error - this error is caused by the limited length of the word in the computer (given by the number of the decimals used by the numerical computation).

    ( ) ( ) ( )E t E t E tL i T i R i= +

    The value of the transaction error is proportional to the power of the step h, for example h2 , like 0(h2). That means, that the error ET is order hi. The error in one step of the solution influences the solution in the next steps. The inaccuracy of result in the next i steps is characterized by the accumulative error global error.

    ( ) ( )i i iY t y t=

    where Y(ti) is the exact accurate solution at the point ti.

    ,

  • Classification of the Numerical Methods for Solution of the Differential Equations

    Numerical methods for the solution of the differential equations

    One-step Methods multi steps methods (k-steps methods )

    Predictor methods (explicit methods)

    Corrector methods (implicit methods)

    Combined methods

  • One-Step Methods

    ( )y y h ti i i+ = + 1 , , y hiThe expression h(ti, yi, h) defines the increment of the solution between the nodes i a i+1

    One step method can be expressed in the form:

    We express the increment of the solution using the Taylor series in dependence on the step h and its power h = ti+1 - ti (fixed step h) as follows:

    ( ) ( ) ( ) ( ) ( )y y h f t h f t hn f t hi i i in

    ni

    n+

    + = + + +12

    1 12

    0,!

    ,!

    , y y ... + yi i i

    The computation of the increment using the Taylor series needs the calculation of the derivatives higher order of the function f(t, y) what is difficult to express or calculate. It is also assumed that the function f(t, y) is differentiable. The method which calculated the increment of the solution from the Taylor series is called Taylor series method. Because of the need of the calculation of the derivatives higher order this approach is practically not used. This approach is the basis for the derivation of the One Step Methods like Eulers method or Runge -Kutta method.

  • Eulers method

    The Eulers method uses only the fist term of the Taylor series:

    ( )y y h f ti i i+ = + 1 , yi

    The numerical solution using the Eulers method represents the polynomial approximation first order. The transaction error of the Eulers method is given by the neglected terms of the series.

    ( ) ( ) ... y ,!3

    y ,!2 i

    3

    i

    2

    ++= iiT tfhtfhE

    ti ti+1 hi

    yi

    yi+1

    yi

  • Runge Kutta Methods

    The basic idea of the Runge - Kutta methods consists in finding an expression for the increment of the solution, which doesnt need the computation of the derivatives of the function f(ti, yi) and which is with the computational accuracy equal to the value given by the r terms of the Taylor series. This method is called Runge - Kutta methods order r.

    y y h w ki i j jj

    r

    +=

    = + 11

    The Runge - Kutta methods can be expressed in the form:

    The increments kj are calculated between the nodes ti a ti+1 using the expressions:

    ( )( )

    k f t

    k f t h hk j

    i

    j i j j j

    1

    1

    =

    = + + =

    ,

    ,

    y

    y 2, 3, ..., r.

    i

    i

    The variables wj, j, j are the constant parameters. Their values assure that the numerical solution of the differential equation in the node ti+1 is equal to the value which can be calculated from the r-terms of the Taylor series in the node ti .

  • Runge Kutta Methods The transaction error of the Runge Kutta methods can be expressed using the neglected terms of the Taylor series in the following form:

    ( )( )( ) htf

    rhE i

    rr

    T ++=

    +

    i

    1

    t,,y ,!1

    This expression is not possible to use for the practical calculation of the estimated value of the transaction error. For that reason the following approach based on the half step is very frequently used. Half-step method for the estimation of the occurring error:

    1. The solution y(ti+h) in the next node ti+1 is computed using the chosen one-step method with the step length h.

    2. We repeat the calculation with the half step h = h/2 and calculate the solutions y(ti+h) and y(ti+2h), (two times use of the method).

    3. If the difference between the values of the solutions y(ti+h) and y(ti+2h) is less than the accepted maximal error we continue in the solution with the step h. Otherwise with the half step.

  • Half-step method for the estimation of the occurring error

    ti ti+h/2

    ti+2*h/2 t

    y

    y(ti)

    y(ti+h/2)

    y(ti+2*h/2)

    y(ti+h)

  • Runge-Kutta methods 2nd order

    Modified Eulers method y y h ki i i+ = + 1 2

    ( )k f ti1 = , yi

    k f th h

    kii i

    2 12 2= + +

    , yi

    Heuns method y y h k ki i i+ = + +1 1 22

    ( )k f ti1 = , yi

    ( )k f t h ki i2 1 1= + + , yi

  • Runge - Kutta Method 4th order y y h

    k k k ki i i+ = +

    + + +1

    1 2 3 42 26

    ( )k f ti1 = , yi

    k f th h

    kii i

    2 12 2= + +

    , yi

    k f th h

    kii i

    3 22 2= + +

    , yi

    ( )3i14 y , khtfk ii += +

    Runge - Kutta Method 4th order (clasical method, very frequently used method):

    The simple change of the step of the solution is the advantage of the Runge-Kutta Methods. It is possible to change the step in dependence on the estimated value of the error of the solution. The disadvantage is the multiple calculation of the function f(t, y) in dependence on the order of the method. If this calculation is enough fast, it is suitable to do the whole solution using the Runge-Kutta method. If the function f(t, y) is more difficult and the computation of their value takes more time, it is recommendable to start the solution with the Runge-Kutta method and continue with the multi-step method.

  • Multi-step Methods Let we assume that we know the solution of the differential equation

    ( ) ( ) = =y f t y y t, , y 0 0

    in k+1 nodes

    ( ) ( ) ( )y y t y t y ti i i i k= = = , , y ..., yi 1 i k1

    After integration of the equation at the interval ti, ti+1 we obtain:

    ( ) ( ) ( )y t y t f t dti it

    t

    i

    i

    + = ++

    11

    , y

    It is impossible to calculate the integral at the interval ti, ti+1 , because we dont know the the solution y. but we know the solution in the previous nodes. The multistep methods are based on the approximation of the function f(t, y) using the interpolation polynomial p(t), which is defined by the values f(ti, yi), f(ti-1, yi-1), ..., f(ti-k, yi-k), and on the approximation of the integral from f(t,y) by the integral from the p(t,y). Then we can write:

    ( ) ( ) ( )y t y t p t dt Ei it

    t

    Ti

    i

    + = + ++

    11

    , y

  • Multi-step methods

    Because of the use the polynomial p(t, y) for the computation of the integral at the interval ti, ti+1 outside the given values, we will use the polynomial for the extrapolation of the function f(t, y). The formulas of the methods for the numerical solution of the differential equations derived in this way are called explicit methods and are expressed in explicit forms. If we use by the derivation of the interpolation polynomial p(t, y) the values f(ti+1, yi+1), f(ti, yi), f(ti-1, yi-1), f(tik, yi-k) we obtain for the computation of the solution y the interpolation formula and so called implicit formula. Because of the computation of the value of the solution yi+1 from the value f(ti+1, yi+1) the derived formula is implicit. The order of the multistep methods is given by the order of the polynomial p(t).

  • Multi-step methods The explicit methods Adams-Bashforth methods (A-B), predictor formulas Derivation of the two steps method A-B Let we replace the function f(t, y) in the equation for the integral increment of the solution by the Newton interpolation:

    ( ) ( ) ( ) ( ) ( )f t f h t ti, , ,,

    y p t y f t yt y

    i i i ii-1 i-1 = +

    ( )y y f fh

    t t dti i ii

    it

    t

    i

    i

    += + +

    +

    1 11

    After substitution into the formula for the numerical solution of the differential equation we obtain:

    ( ) ( )y y f t t fh t ti i i i ii

    i i+ +

    += + + 1 11

    12

    2

    The final expression of the explicit method 2nd order we obtain after the substitution h = ti+1 - ti and fi-1 = fi - fi-1 and transformation:

    ( )y y h f fi i i i+ = + 1 12 3

  • Multi-step methods The explicit multistep method A-B order k+1 can be expressed by the formula:

    y y h b fi i kj i jj

    k

    + =

    = + 10

    The values bkj for k = 0, 1, 2, 3 are summarized in the table:

    12

    2312

    1612

    512

    5524

    5924

    3724

    924

    j 0 1 2 3 b0j 1

    b1j

    b2j

    b3j

    32

  • Multi-step methods Implicit methods (corrector methods) The implicit methods are described using the implicit formulas and are also called Adams - Moulton methods or A-M methods. The implicit A-M method order k can be expressed using the formula:

    y y h b fi i kj i jj

    k

    + + =

    = + 1 10

    The values of the coefficients bkj of the implicit methods A-M for k = 0, 1, 2, 3 are summarized in the table:

    12

    12

    512

    812

    924

    1924

    524

    124

    j 0 1 2 3 b0j 1

    b1j

    b2j

    b3j

    112

  • Multi-step methods Predictor corrector methods

    The introduced multistep methods are not mostly used stand-alone but in combination as the predictor-corrector methods. Using the predictor method the next value of the solution is calculated. The result is used for the evaluation of the corrector formula which gives the value of the solution. It is important to use the predictor and corrector formulas same order. The local errors of both formulas are same order).

    The estimation of the local error of the predictor-corrector methods can be done using the formula: ( )E tT i+ 1 y yi+1P i+1CIf the value of the error is less than the maximal error, we use the value as the solution at the point ti+1 . If not, the value of the corrector formula is used as a prediction of the solution and is used for the second evaluation of the corrector formula and computation of the new value of the solution in the point ti+1 . The error is estimated in the mentioned way and the described procedure can be repeted again.

  • Numerical solution of the system of the ordinary differential equations system of the state equations

    ( ) ( )! , ,x f x x t x= = t 0 0

    Eulers method ( )x x h f ti i i i+ = + 1 , x

    ( )k f ti1 = , xi k f t h h ki i i2 12 2= + +

    , xi

    Heuns method ( )x x h k ki i i+ = + +1 1 22( )k f ti1 = , xi ( )k f t h ki i2 1 1= + + , xi

    Runge-Kutta Method 4th order ( )[ ]x x h k k k ki i i+ = + + + +1 1 2 3 46 2

    ( )k f ti1 = , xi

    k f th h

    kii i

    2 12 2= + +

    , xi

    k f th h

    kii i

    3 22 2= + +

    , xi

    ( )k f t h ki i4 1 3= + + , xi

  • Numerical solution of the system of the ordinary differential equations

    The estimation of the transaction error of the method can be realized at the similar way like by the solution of only one differential equation using the half step method. The following condition must be full field:

    ( ) ( )x t h x t h jj i j i+ + 2 , = 1, 2, ..., n

    The accuracy of each equation must be tested and full field!

  • Numerical solution of the system of the ordinary differential equations

    The multi step methods can be used in the same way for the solution of the system of the ordinary differential equations.

    ( )x x h b f ti i kj i j i jj

    k

    + =

    = + 10

    , x

    ( )x x h k f ti i kj i j i jj

    k

    + + + =

    = + 1 1 10

    , x

    General formula of the explicit method:

    General formula of the implicit method:

    The accuracy is estimated in the same way like by the solution of one equation. The solution of each equation must full fill the condition.

  • Stability of the numerical solution of the differential equation

    Test differential equation !y y=

    Stability area for the Eulers method ( )y y h f yi i i+ = + 1 , ti

    y y h yi i i+ = + 1

    ( )y h yi i+ = + 1 1

    y yi i+ 1

    1 1+ h

    -2 -1 Re (h)

    Im (h)

    -1

    1

    Stability area for the Eulers method The method is stable for the real number < 0 only for the lenght of the step of the solution:

    h