(Numerical methods for differential equations) 8egmu.net/civil/wonsiri/ เป นฟ งก ชน…

  • View
    212

  • Download
    0

Embed Size (px)

Transcript

  • .9-11.. 282 .. 8 (Numerical methods for differential equations)

    8.1

    1

    xydx

    dy (8.1)

    ?)( xy y x

    )()(

    xxydx

    xdy (8.2)

    (separation of variable) y

    0y x

    dxxdxdx

    dy

    y

    1 (8.3)

    (chain rule)

    dxxdyy

    1 (8.4)

    1

    2

    2ln c

    xy (8.5)

  • .9-11.. 282 ..

    1c

    1

    2

    2c

    x

    ey

    (8.6)

    1)0( y

    2

    2x

    ey (8.7)

    8.1

    8.1 xydx

    dy

    1 ),( yxfy 00

    )( yxy

    f (unique solution) 0x y

  • .9-11.. 282 .. ),(

    00yx

    3 (Euler Method)

    (Huens or Improved Euler Method) (Runge-Kutta

    Method)

    8.2 (Eulers Method)

    (Taylor Series)

    )(xf n 0

    xx

    )(xf 0xx

    n

    n

    xxn

    xfxx

    xfxxxfxfxf )(

    !

    )(...)(

    !2

    )())(()()(

    0

    02

    0

    0

    000

    (8.8)

    1 ),( yxfy 2 3 yy ,

    yyyyxxyxx

    yxyx

    fyfyfyfyfyxfy

    ffffyfyxfy

    )(),(

    ),( (8.9)

    yy , yx, h 32 ,hh 0

    xx

    )(xy hxx 0

    )(0

    hxy

    k

    k

    hk

    xyh

    xfyhxyxyhxy )(

    !

    )(...)(

    !2

    )())(()()( 020

    000

    (8.10)

    1k 8.10

    ))(()()(000

    hxyxyhxy (8.11)

    8.11 (Eulers method)

  • .9-11.. 282 ..

    8.1

    8.1 1i

    y ii

    yx ,

    ),(1 nnnn

    yxfhyy

    ,..2,1,0n (8.12)

    h

    (first order method) h 8.11 2h n

  • .9-11.. 282 .. 8.1 yxy 0)0( y

    521

    ,..,, yyy

    1 xey x

    yxy 0)0( y

    yxyxf ),( 2.0h

    n =0 0)0( y

    n =1 0)00(*2.00),(0001

    yxfhyy

    n =2 04.0)02.0(*2.00),(1112

    yxfhyy

    n =3 128.0)04.04.0(*2.004.0),(2223

    yxfhyy

    n =4 274.0)128.06.0(*2.0128.0),(3334

    yxfhyy

    n =5 489.0)274.08.0(*2.0274.0),(4445

    yxfhyy

    8.1

    8.1 yxy 0)0( y

    n nx ny 1 xey x 0 0 0 0.000 0.000 1 0.2 0 0.021 0.021 2 0.4 0.04 0.092 0.052 3 0.6 0.128 0.222 0.094 4 0.8 0.274 0.426 0.152 5 1 0.489 0.718 0.229

    n

  • .9-11.. 282 .. 8.2 xyy cos 1)0( y

    0.1,5.0,25.0h

    Cxy

    dxxy

    dy

    sinln

    cos

    1)0( y C = 0 xexy sin)(

    xyyxf cos),( 0.1,5.0,25.0h

    8.2 8.2 8.2 xyy cos 1)0( y

    nx ny (h=0.25) ny (h=0.50) ny (h=1.00) xey sin 0.00 1.00000 1.00000 1.00000 1.00000 0.25 1.25000 1.28070 0.50 1.55279 1.50000 1.61515 0.75 1.89346 1.97712 1.00 2.23982 2.15819 2.00000 2.31978 1.25 2.54236 2.58309 1.50 2.74278 2.74122 2.71148 1.75 2.79128 2.67510 2.00 2.66690 2.83818 3.08060 2.48258 2.25 2.38944 2.17727 2.50 2.01419 2.24763 1.81934 2.75 1.61078 1.46472 3.00 1.23857 1.34729 1.79862 1.15156

  • .9-11.. 282 ..

    8.2 xyy cos 1)0( y 0.1,5.0,25.0h

    n h

    8.3 yty 2 1)0( y

    )512(4

    1 2tety 2.0h

    8.3 yty 2 1)0( y

    it ),(

    11 iiytf )(Eulery

    i )(Exacty

    i

    0 - 1.00 1.00 0.000 0.2 -2.0 0.60 0.6879 0.0879 0.4 -1.0 0.4 0.5117 0.1117 0.6 -0.4 0.32 0.4265 0.1065

  • .9-11.. 282 .. Matlab odeEuler.m 8.3

    8.3 odeEuler.m yty 2

  • .9-11.. 282 .. 8.3 (Huens Method or Improved Euler Method)

    h

    ),( yxf (Huens method)

    (Improved Euler or Predictor Corrector Approach)

    ),( yxfy ),( ii yx

    1i

    x 01i

    y

    8.13 8.4

    ),(01 iiii

    yxfhyy

    (8.13)

    8.4 01i

    y 1i

    x

  • .9-11.. 282 ..

    1i

    y

    ),( 011 ii

    yx

    ),( 0111

    iii

    yxfy (8.14)

    y 8.13 8.14

    ),(),(2

    1

    2

    1 011

    iiiiii

    yxfyxfyyyy (8.15)

    8.16 1i

    y

    8.5

    ),(),(2

    0

    11

    iiiiiiyxfyxf

    hyy (8.16)

    8.5 1i

    y

  • .9-11.. 282 ..

    (Predictor and Corrector Method)

    1) (predictor)

    11111

    0 ),( khyytfhyyiiiii

    (8.17)

    2)

    )(),(

    ),(

    0

    11112

    111

    iiii

    ii

    yhtfhkyhtfk

    ytfk

    (8.18)

    3) 8.18 (Corrector)

    8.6

    2112

    kkh

    yyii

    (8.19)

    8.6

  • .9-11.. 282 .. 8.4 yxy 0)0( y

    521

    ,..,, yyy

    1 xey x

    yxyxfy ),( 0,000 yx 2.0h

    1) (predictor) 00*2.00),(000

    0

    2.0 yxfhyy

    2)

    2.002.0)0*2.00,2.00(),(),(

    000),(

    0

    2.001002

    001

    fyhxfhkyhxfk

    yxfk

    3) (Corrector)

    02.02.002

    2.00

    22102.0

    kkh

    yy

    8.4

    8.4 yxy 0)0( y

    n nx ny 1 xey x 0 0 0 0.000 0.0000 1 0.2 0.0200 0.021 0.0014 2 0.4 0.0884 0.092 0.0034 3 0.6 0.2158 0.222 0.0063 4 0.8 0.4153 0.426 0.0102 5 1 0.7027 0.718 0.0156

    8.1

  • .9-11.. 282 .. 8.5 xyy cos 1)0( y

    0.1h

    xexy sin)(

    xyyxf cos),( 0.1h

    1) (predictor) 2)0cos(*11),(000

    0

    1 yxfhyy

    2)

    08060.1)1cos(*2)2,1(),(),(

    1)0cos(*1)1,0(),(

    0

    101002

    001

    fyhxfhkyhxfk

    fyxfk

    3) (Corrector)

    04030.208060.112

    11

    22101

    kkh

    yy

    2

    4) (predictor) 14268.3)1cos(*04030.2*104030.2)04030.2,1(*104030.2),(

    111

    0

    2 fyxfhyy

    5)

    30782.1)2cos(*14268.3)14268.3,2(),(),(

    10238.1)1cos(*04030.2)04030.2,1(),(

    0

    211112

    111

    fyhxfhkyhxfk

    fyxfk

    6) (Corrector)

    93758.130782.110238.12

    104030.2

    22112

    kkh

    yy

    8.7

    8.5 8.2

  • .9-11.. 282 .. 8.5 xyy cos 1)0( y

    nx ny (h=1.00) ny (h=1.00) xey sin

    0.00 1.00000 1.00000 1.00000 1.00 2.04030 2.00000 2.31978 2.00 1.93758 3.08060 2.48258 3.00 0.97445 1.79862 1.15156

    8.7 xyy cos 1)0( y 0.1h

  • .9-11.. 282 .. 8.6 yey x 5.04 8.0 2)0( y

    Matlab

    xxx eeey 5.05.08.0 2)(3.1

    4 1h

    Matlab odeHuen.m 8.8

    8.8 odeHuen.m yey x 5.04 8.0

  • .9-11.. 282 .. Matlab odeEuler.m

    8.9

    8.9 odeEuler.m yey x 5.04 8.0

  • .9-11.. 282 .. 8.4 (Runge-Kutta Method)

    ( 8.10)

    8.10

    weighted average

    l

    m

    l liikhyy 11 (8.20)

    m

    11

    m

    l l (8.21)

    m=2

    )(22111

    kakahyyii

    (8.22)

    ),(

    ),(

    11112

    1

    hkqyhpxfk

    yxfk

    ii

    ii

    (8.23)

  • .9-11.. 282 ..

    11121,,, qpaa

    ...2

    )(),())(,(

    ),(),(

    ...2

    )(),())(,(

    2

    1

    2

    1

    h

    y

    fyxf

    x

    fhyxfyy

    y

    fyxf

    x

    f

    dx

    dy

    y

    f

    x

    fyxf

    hyxfhyxfyy

    iiiiii

    iiii

    iiiiii

    (8.24)

    2

    ...),(),(

    y

    gs

    x

    gryxgsyrxg

    (8.25)

    ...),(11112

    y

    fhkq

    x

    fhpyxfk

    ii

    (8.26)

    8.26 8.22

    ...,,)( 211212211

    h

    y

    fyxfqa

    x

    fpayxfaahyy

    iiiiii

    (8.27)

    8.24

    2

    1

    2

    1

    1

    112

    12

    21

    qa

    pa

    aa

    (8.28)

    2

    12a

    1

    1

    2

    1

    11

    1

    1

    q

    p

    a

    (8.28)

    m=2

    )(2

    211kk

    hyy

    ii

    (8.29)

  • .9-11.. 282 .. m=2

    2hO

    m=3

    )4(6

    3211kkk

    hyy

    ii

    (8.30)

    )2,(

    )2

    ,2

    (

    ),(

    2113

    112

    1

    hkhkyhxfk

    kh

    yh

    xfk

    yxfk

    i

    i

    ii

    (8.31)

    3hO

    m=4

    )22(6

    43211kkkk

    hyy

    ii

    (8.32)

    ),(

    )2

    ,(

    )2

    ,2

    (

    ),(

    34

    213

    112

    1

    hkyhxfk

    kh

    yhxfk

    kh

    yh

    xfk

    yxfk

    ii

    i

    i

    ii

    (8.33)

    4hO

  • .9-11.. 282 .. 8.7 yxy 0)0( y

    4 h = 0.2 521

    ,..,, yyy

    1 xey x

    yxy 0)0( y h = 0.2

    044.0)(244.0022.0)(222.0}2.0{[2.0),(

    022.0)(222.02

    02.0)(

    2

    22.0)}2.0(

    2

    1{[2.0)

    2,(

    02.0)(22.0)(2

    2.0)}2.0(

    2

    1{[2.0)

    2,

    2(

    )(2.0),(

    ),(

    34

    213

    112

    1

    nnnnnnii

    nnnnnni

    nnnnnni

    nnii

    yxyxyxhkyhxfhk

    yxyxyxkh

    yhxfhk

    yxyxyxkh

    yh

    xhfhk

    yxyxhfhk

    yxyxf

    0214.0)(2214.0

    )22(6

    1

    1

    43211

    nnnn

    nn

    yxyy

    hkhkhkhkyy

    8.6 8.7

  • .9-11.. 282 .. 8.6 yxy 0)0( y 4

    n nx ny 1 xey x 0 0 0 0.000 0.0000 1 0.2 0.021400 0.021403 0.000003 2 0.4 0.091818 0.091825 0.000007 3 0.