« 芦屋で大楠公戦跡を見つけた。 | トップページ | 芦屋の稲荷神社の鳥居はなぜこんなところに。 »

2010年3月19日 (金)

14次の超高次ルンゲクッタ法でローレンツ方程式を計算(Excel VBA)

35段14次のRunge-Kutta法のExcel VBAへの移植がとりあえず完成した。元の係数はこちら↓

http://sce.uhcl.edu/rungekutta/

まず最初はローレンツ方程式をやってみよう。式はこちら。

dx/dt = -σ*(x-y)

dy/dt=-y-x*z+r*x

dz/dt=x*y-b*z

プログラムは簡単なんだけれど、係数が長い長い。。。35段だからね。ではソースリストを書いてみましょう。

Option Explicit

Dim sigma As Double, rr As Double, bb As Double

Private Sub CommandButton1_Click()
    Dim x As Double, y As Double, z As Double
   
    Dim kx(34) As Double
    Dim ky(34) As Double
    Dim kz(34) As Double
    Dim a(34) As Double
    Dim b(34, 34) As Double
    Dim c(34) As Double
       
    Dim t As Double, dt As Double
    Dim i As Long, j As Integer, k As Integer, jj As Integer
    Dim pi As Double

   
    Application.ScreenUpdating = False
   
    a(0) = 0
    a(1) = 0.111111111111111
    a(2) = 0.555555555555555
    a(3) = 0.833333333333333
    a(4) = 0.333333333333333
    a(5) = 1
    a(6) = 0.669986979272772
    a(7) = 0.297068384213818
    a(8) = 0.727272727272727
    a(9) = 0.140152799042188
    a(10) = 0.70070103977015
    a(11) = 0.363636363636363
    a(12) = 0.263157894736842
    a(13) = 0.039217224665027
    a(14) = 0.812917502928376
    a(15) = 0.166666666666666
    a(16) = 0.9
    a(17) = 6.41299257451966E-02
    a(18) = 0.204149909283428
    a(19) = 0.39535039104876
    a(20) = 0.604649608951239
    a(21) = 0.795850090716571
    a(22) = 0.935870074254803
    a(23) = 0.166666666666666
    a(24) = 0.812917502928376
    a(25) = 0.039217224665027
    a(26) = 0.363636363636363
    a(27) = 0.70070103977015
    a(28) = 0.140152799042188
    a(29) = 0.297068384213818
    a(30) = 0.669986979272772
    a(31) = 0.333333333333333
    a(32) = 0.555555555555555
    a(33) = 0.111111111111111
    a(34) = 1
   
   
   
    c(0) = 1.78571428571428E-02
    c(1) = 0.005859375
    c(2) = 0.01171875
    c(3) = 0
    c(4) = 0.017578125
    c(5) = 0
    c(6) = 0.0234375
    c(7) = 0.029296875
    c(8) = 0
    c(9) = 0.03515625
    c(10) = 0.041015625
    c(11) = 0.046875
    c(12) = 0
    c(13) = 0.052734375
    c(14) = 0.05859375
    c(15) = 0.064453125
    c(16) = 0
    c(17) = 0.105352113571753
    c(18) = 0.170561346241752
    c(19) = 0.206229397329351
    c(20) = 0.206229397329351
    c(21) = 0.170561346241752
    c(22) = 0.105352113571753
    c(23) = -0.064453125
    c(24) = -0.05859375
    c(25) = -0.052734375
    c(26) = -0.046875
    c(27) = -0.041015625
    c(28) = -0.03515625
    c(29) = -0.029296875
    c(30) = -0.0234375
    c(31) = -0.017578125
    c(32) = -0.01171875
    c(33) = -0.005859375
    c(34) = 1.78571428571428E-02
   
   
   
    b(1, 0) = 0.111111111111111
    b(2, 0) = -0.833333333333333
    b(2, 1) = 1.38888888888888
    b(3, 0) = 0.208333333333333
    b(3, 1) = 0
    b(3, 2) = 0.625
    b(4, 0) = 0.193333333333333
    b(4, 1) = 0
    b(4, 2) = 0.22
    b(4, 3) = -0.08
    b(5, 0) = 0.1
    b(5, 1) = 0

   b(5, 2) = 0
    b(5, 3) = 0.4
    b(5, 4) = 0.5
    b(6, 0) = 0.103484561636679
    b(6, 1) = 0
    b(6, 2) = 0
    b(6, 3) = 0.122068887306407
    b(6, 4) = 0.482574490331246
    b(6, 5) = -3.81409600015606E-02
    b(7, 0) = 0.124380526654094
    b(7, 1) = 0
    b(7, 2) = 0
    b(7, 3) = 0
    b(7, 4) = 0.226120282197584
    b(7, 5) = 0.013788588761808
    b(7, 6) = -6.72210133996684E-02
    b(8, 0) = 9.36919065659673E-02
    b(8, 1) = 0
    b(8, 2) = 0
    b(8, 3) = 0
    b(8, 4) = 0
    b(8, 5) = -6.1340684345051E-03
    b(8, 6) = 0.216019825625503
    b(8, 7) = 0.423695063515761
    b(9, 0) = 8.38479812409052E-02
    b(9, 1) = 0
    b(9, 2) = 0
    b(9, 3) = 0
    b(9, 4) = 0
    b(9, 5) = -1.17949367100973E-02
    b(9, 6) = -0.247299020568812
    b(9, 7) = 9.78080858367729E-02
    b(9, 8) = 0.21759068924342
    b(10, 0) = 6.15255359769428E-02
    b(10, 1) = 0
    b(10, 2) = 0
    b(10, 3) = 0
    b(10, 4) = 0
    b(10, 5) = 5.92232780324503E-03
    b(10, 6) = 0.470326159963841
    b(10, 7) = 0.299688863848679
    b(10, 8) = -0.247656877593994
    b(10, 9) = 0.110895029771437
    b(11, 0) = 4.19700073362782E-02
    b(11, 1) = 0
    b(11, 2) = 0
    b(11, 3) = 0
    b(11, 4) = 0
    b(11, 5) = -3.17987696266205E-03
    b(11, 6) = 0.806397714906192
    b(11, 7) = 9.75983126412388E-02
    b(11, 8) = 0.778575578158398
    b(11, 9) = 0.204890423831599
    b(11, 10) = -1.56261579627468
    b(12, 0) = 0.043772678223373
    b(12, 1) = 0
    b(12, 2) = 0
    b(12, 3) = 0
    b(12, 4) = 0
    b(12, 5) = 0
    b(12, 6) = 0
    b(12, 7) = 0
    b(12, 8) = 6.24365027520195E-03
    b(12, 9) = 0.200043097109577
    b(12, 10) = -8.05328367804983E-03
    b(12, 11) = 2.11517528067396E-02
    b(13, 0) = 2.83499250363514E-02
    b(13, 1) = 0
    b(13, 2) = 0
    b(13, 3) = 0
    b(13, 4) = 0
    b(13, 5) = 0
    b(13, 6) = 0
    b(13, 7) = 0
    b(13, 8) = 2.49163204855817E-03
    b(13, 9) = 2.30138787854593E-02
    b(13, 10) = -3.22155956692977E-03
    b(13, 11) = 9.88442549447664E-03
    b(13, 12) = -2.13010771328887E-02
    b(14, 0) = 0.343511894290243
    b(14, 1) = 0
    b(14, 2) = 0
    b(14, 3) = 0
    b(14, 4) = 0
    b(14, 5) = 0
    b(14, 6) = 0
    b(14, 7) = 0
    b(14, 8) = 0.210451912023627
    b(14, 9) = 1.0342745205723
    b(14, 10) = 6.00303645864422E-03
    b(14, 11) = 0.855938125099619
    b(14, 12) = -0.977235005036766
    b(14, 13) = -0.660026980479294
    b(15, 0) = -1.43574001672168E-02
    b(15, 1) = 0
    b(15, 2) = 0
    b(15, 3) = 0
    b(15, 4) = 0
    b(15, 5) = 0
    b(15, 6) = 0
    b(15, 7) = 0
    b(15, 8) = -3.66253270049039E-02
    b(15, 9) = 3.50254975636213E-02
    b(15, 10) = 3.60946016362113E-02
    b(15, 11) = -2.65219967553681E-02
    b(15, 12) = 4.45699011305698E-02
    b(15, 13) = 0.124343093331358
    b(15, 14) = 4.1382969323948E-03
    b(16, 0) = 0.35603240442512
    b(16, 1) = 0
    b(16, 2) = 0
    b(16, 3) = 0
    b(16, 4) = 0
    b(16, 5) = 0
    b(16, 6) = 0
    b(16, 7) = 0
    b(16, 8) = -0.450192758947562
    b(16, 9) = 0.43052790708371
    b(16, 10) = 0.511973029011022
    b(16, 11) = 0.908303638886404
    b(16, 12) = -1.23921093371933
    b(16, 13) = -0.649048661671761
    b(16, 14) = 0.251708904586819
    b(16, 15) = 0.779906470345586
    b(17, 0) = 1.30935687406513E-02
    b(17, 1) = 0
    b(17, 2) = 0
    b(17, 3) = 0
    b(17, 4) = 0
    b(17, 5) = 0
    b(17, 6) = 0
    b(17, 7) = 0
    b(17, 8) = 0
    b(17, 9) = 0
    b(17, 10) = 0
    b(17, 11) = 0
    b(17, 12) = -9.32053067985113E-05
    b(17, 13) = 5.05374334262299E-02
    b(17, 14) = 8.04470341944487E-07
    b(17, 15) = 5.91726029494171E-04
    b(17, 16) = -4.01614722154557E-07
    b(18, 0) = 2.07926484466053E-02
    b(18, 1) = 0
    b(18, 2) = 0
    b(18, 3) = 0
    b(18, 4) = 0
    b(18, 5) = 0
    b(18, 6) = 0
    b(18, 7) = 0
    b(18, 8) = 0
    b(18, 9) = 0
    b(18, 10) = 0
    b(18, 11) = 0
    b(18, 12) = 5.82695918800085E-04
    b(18, 13) = -8.01700732358815E-03
    b(18, 14) = 4.03847643847136E-06
    b(18, 15) = 8.54609998055506E-02
    b(18, 16) = -2.04486480935804E-06
    b(18, 17) = 0.105328578824431
    b(19, 0) = 1.40153449795736
    b(19, 1) = 0
    b(19, 2) = 0
    b(19, 3) = 0
    b(19, 4) = 0
    b(19, 5) = 0
    b(19, 6) = 0
    b(19, 7) = 0
    b(19, 8) = 0
    b(19, 9) = 0
    b(19, 10) = 0
    b(19, 11) = 0
    b(19, 12) = -0.230252000984221
    b(19, 13) = -7.21106840466912
    b(19, 14) = 3.72901560694836E-03
    b(19, 15) = -4.71415495727125
    b(19, 16) = -1.76367657545349E-03
    b(19, 17) = 7.64130548038698
    b(19, 18) = 3.50602043659751
    b(20, 0) = 11.951465069412
    b(20, 1) = 0
    b(20, 2) = 0
    b(20, 3) = 0
    b(20, 4) = 0
    b(20, 5) = 0
    b(20, 6) = 0
    b(20, 7) = 0
    b(20, 8) = 0
    b(20, 9) = 0
    b(20, 10) = 0
    b(20, 11) = 0
    b(20, 12) = 7.79480932108175
    b(20, 13) = -56.4501393867325
    b(20, 14) = 9.12376306930644E-02
    b(20, 15) = -12.7336279925434
    b(20, 16) = -3.96895921904719E-02
    b(20, 17) = 54.439214188357
    b(20, 18) = -3.64411637921569
    b(20, 19) = -0.804503249910509
    b(21, 0) = -148.8094265071
    b(21, 1) = 0
    b(21, 2) = 0
    b(21, 3) = 0
    b(21, 4) = 0
    b(21, 5) = 0
    b(21, 6) = 0
    b(21, 7) = 0
    b(21, 8) = 0
    b(21, 9) = 0
    b(21, 10) = 0
    b(21, 11) = 0
    b(21, 12) = -91.7295278291256
    b(21, 13) = 707.656144971598
    b(21, 14) = -1.10563611857482
    b(21, 15) = 176.134591883811
    b(21, 16) = 0.49138482421488
    b(21, 17) = -684.278000449814
    b(21, 18) = 27.9910604998398
    b(21, 19) = 13.1939710030282
    b(21, 20) = 1.2512878128398
    b(22, 0) = -9.67307946948196
    b(22, 1) = 0
    b(22, 2) = 0
    b(22, 3) = 0
    b(22, 4) = 0
    b(22, 5) = 0
    b(22, 6) = 0
    b(22, 7) = 0
    b(22, 8) = 0
    b(22, 9) = 0
    b(22, 10) = 0
    b(22, 11) = 0
    b(22, 12) = -4.46990150858505
    b(22, 13) = 45.5127128690952
    b(22, 14) = -7.13085086183826E-02
    b(22, 15) = 11.2273614068412
    b(22, 16) = 0.126244376717622
    b(22, 17) = -43.5439339549483
    b(22, 18) = 0.787174307543058
    b(22, 19) = 0.532264696744684
    b(22, 20) = 0.422422733996325
    b(22, 21) = 8.59131249503067E-02
    b(23, 0) = -10.0664032447054
    b(23, 1) = 0
    b(23, 2) = 0
    b(23, 3) = 0
    b(23, 4) = 0
    b(23, 5) = 0
    b(23, 6) = 0
    b(23, 7) = 0
    b(23, 8) = -3.66253270049039E-02
    b(23, 9) = 3.50254975636213E-02
    b(23, 10) = 3.60946016362113E-02
    b(23, 11) = -2.65219967553681E-02
    b(23, 12) = -6.27088972181464
    b(23, 13) = 48.2079237442562
    b(23, 14) = -6.94471689136165E-02
    b(23, 15) = 12.681069020485
    b(23, 16) = 1.19671168968323E-02
    b(23, 17) = -46.7249764992482
    b(23, 18) = 1.33029613326626
    b(23, 19) = 1.00766787503398
    b(23, 20) = 2.09512051933665E-02
    b(23, 21) = 2.10134706331264E-02
    b(23, 22) = 9.52196014417121E-03
    b(24, 0) = -409.478081677743
    b(24, 1) = 0
    b(24, 2) = 0
    b(24, 3) = 0
    b(24, 4) = 0
    b(24, 5) = 0
    b(24, 6) = 0
    b(24, 7) = 0
    b(24, 8) = 0.210451912023627
    b(24, 9) = 1.0342745205723
    b(24, 10) = 6.00303645864422E-03
    b(24, 11) = 0.855938125099619
    b(24, 12) = -250.516998547447
    b(24, 13) = 1946.42466652388
    b(24, 14) = -3.0450388210231
    b(24, 15) = 490.626379528281
    b(24, 16) = 1.5664758953127
    b(24, 17) = -1881.97428994011
    b(24, 18) = 75.2592224724847
    b(24, 19) = 34.5734356980331
    b(24, 20) = 3.21147679440968
    b(24, 21) = -0.460408041738414
    b(24, 22) = -0.087071833984181
    b(24, 23) = -7.39351814158303
    b(25, 0) = 3.4334747585355
    b(25, 1) = 0
    b(25, 2) = 0
    b(25, 3) = 0
    b(25, 4) = 0
    b(25, 5) = 0
    b(25, 6) = 0
    b(25, 7) = 0
    b(25, 8) = 2.49163204855817E-03
    b(25, 9) = 2.30138787854593E-02
    b(25, 10) = -3.22155956692977E-03
    b(25, 11) = 9.88442549447664E-03
    b(25, 12) = 2.16252799377922
    b(25, 13) = -16.2699864546457
    b(25, 14) = -0.128534502120524
    b(25, 15) = -8.98915042666504
    b(25, 16) = -3.48595363232025E-03
    b(25, 17) = 15.7936194113339
    b(25, 18) = -0.574403330914095
    b(25, 19) = -0.345602039021393
    b(25, 20) = -6.62241490206585E-03
    b(25, 21) = -7.77788129242204E-03
    b(25, 22) = -3.56084192402274E-03
    b(25, 23) = 4.7928250644993
    b(25, 24) = 0.153725464873068
    b(26, 0) = 32.3038520871985
    b(26, 1) = 0
    b(26, 2) = 0
    b(26, 3) = 0
    b(26, 4) = 0
    b(26, 5) = -3.17987696266205E-03
    b(26, 6) = 0.806397714906192
    b(26, 7) = 9.75983126412388E-02
    b(26, 8) = 0.778575578158398
    b(26, 9) = 0.204890423831599
    b(26, 10) = -1.56261579627468
    b(26, 11) = 0
    b(26, 12) = 16.342989188231
    b(26, 13) = -154.544555293543
    b(26, 14) = 1.56971088703334
    b(26, 15) = 3.27685545087248
    b(26, 16) = -5.03489245193653E-02
    b(26, 17) = 153.321151858041
    b(26, 18) = 7.1756818632772
    b(26, 19) = -2.940367486753
    b(26, 20) = -6.65845946076803E-02
    b(26, 21) = -4.62346054990843E-02
    b(26, 22) = -2.04198733585679E-02
    b(26, 23) = -53.3523106438735
    b(26, 24) = -1.35548714715078
    b(26, 25) = -1.57196275801232
    b(27, 0) = -16.6451467486341
    b(27, 1) = 0
    b(27, 2) = 0
    b(27, 3) = 0
    b(27, 4) = 0
    b(27, 5) = 5.92232780324503E-03
    b(27, 6) = 0.470326159963841
    b(27, 7) = 0.299688863848679
    b(27, 8) = -0.247656877593994
    b(27, 9) = 0.110895029771437
    b(27, 10) = 0
    b(27, 11) = -0.491719043846229
    b(27, 12) = -11.4743154427289
    b(27, 13) = 80.259316657623
    b(27, 14) = -0.384132303980042
    b(27, 15) = 7.28147667468107
    b(27, 16) = -0.132699384612248
    b(27, 17) = -81.079983252573
    b(27, 18) = -1.2503749283562
    b(27, 19) = 2.59263594969543
    b(27, 20) = -0.301440298346404
    b(27, 21) = 0.221384460789832
    b(27, 22) = 8.27577274771892E-02
    b(27, 23) = 18.9960662040611
    b(27, 24) = 0.269231946409639
    b(27, 25) = 1.62674827447066
    b(27, 26) = 0.491719043846229
    b(28, 0) = 8.38479812409052E-02
    b(28, 1) = 0
    b(28, 2) = 0
    b(28, 3) = 0
    b(28, 4) = 0
    b(28, 5) = -1.17949367100973E-02
    b(28, 6) = -0.247299020568812
    b(28, 7) = 9.78080858367729E-02
    b(28, 8) = 0.21759068924342
    b(28, 9) = 0
    b(28, 10) = 0.137585606763325
    b(28, 11) = 4.39870229715046E-02
    b(28, 12) = 0
    b(28, 13) = -0.513700813768193
    b(28, 14) = 0.826355691151315
    b(28, 15) = 25.7018139719811
    b(28, 16) = 0
    b(28, 17) = 0
    b(28, 18) = 0
    b(28, 19) = 0
    b(28, 20) = 0
    b(28, 21) = 0
    b(28, 22) = 0
    b(28, 23) = -25.7018139719811
    b(28, 24) = -0.826355691151315
    b(28, 25) = 0.513700813768193
    b(28, 26) = -4.39870229715046E-02
    b(28, 27) = -0.137585606763325
    b(29, 0) = 0.124380526654094
    b(29, 1) = 0
    b(29, 2) = 0
    b(29, 3) = 0
    b(29, 4) = 0.226120282197584
    b(29, 5) = 0.013788588761808
    b(29, 6) = -6.72210133996684E-02
    b(29, 7) = 0
    b(29, 8) = 0
    b(29, 9) = -0.856238975085428
    b(29, 10) = -1.96337522866858
    b(29, 11) = -0.232332822724119
    b(29, 12) = 0
    b(29, 13) = 4.30660719086453
    b(29, 14) = -2.92722963249465
    b(29, 15) = -82.3131666397858
    b(29, 16) = 0
    b(29, 17) = 0
    b(29, 18) = 0
    b(29, 19) = 0
    b(29, 20) = 0
    b(29, 21) = 0
    b(29, 22) = 0
    b(29, 23) = 82.3131666397858
    b(29, 24) = 2.92722963249465
    b(29, 25) = -4.30660719086453
    b(29, 26) = 0.232332822724119
    b(29, 27) = 1.96337522866858
    b(29, 28) = 0.856238975085428
    b(30, 0) = 0.103484561636679
    b(30, 1) = 0
    b(30, 2) = 0
    b(30, 3) = 0.122068887306407
    b(30, 4) = 0.482574490331246
    b(30, 5) = -3.81409600015606E-02
    b(30, 6) = 0
    b(30, 7) = -0.550499525310802
    b(30, 8) = 0
    b(30, 9) = -0.711915811585189
    b(30, 10) = -0.584129605671551
    b(30, 11) = 0
    b(30, 12) = 0
    b(30, 13) = 2.11046308125864
    b(30, 14) = -8.37494736739572E-02
    b(30, 15) = 5.1002149907232
    b(30, 16) = 0
    b(30, 17) = 0
    b(30, 18) = 0
    b(30, 19) = 0
    b(30, 20) = 0
    b(30, 21) = 0
    b(30, 22) = 0
    b(30, 23) = -5.1002149907232
    b(30, 24) = 8.37494736739572E-02
    b(30, 25) = -2.11046308125864
    b(30, 26) = 0
    b(30, 27) = 0.584129605671551
    b(30, 28) = 0.711915811585189
    b(30, 29) = 0.550499525310802
    b(31, 0) = 0.193333333333333
    b(31, 1) = 0
    b(31, 2) = 0.22
    b(31, 3) = -0.08
    b(31, 4) = 0
    b(31, 5) = 0
    b(31, 6) = 0.109993425580724
    b(31, 7) = -0.25429704807627
    b(31, 8) = 0
    b(31, 9) = 0.865570777116694
    b(31, 10) = 3.32416449114093
    b(31, 11) = 0
    b(31, 12) = 0
    b(31, 13) = -12.0102223315977
    b(31, 14) = 0.476601466242493
    b(31, 15) = -29.0243011221036
    b(31, 16) = 0
    b(31, 17) = 0
    b(31, 18) = 0
    b(31, 19) = 0
    b(31, 20) = 0
    b(31, 21) = 0
    b(31, 22) = 0
    b(31, 23) = 29.0243011221036
    b(31, 24) = -0.476601466242493
    b(31, 25) = 12.0102223315977
    b(31, 26) = 0
    b(31, 27) = -3.32416449114093
    b(31, 28) = -0.865570777116694
    b(31, 29) = 0.25429704807627
    b(31, 30) = -0.109993425580724
    b(32, 0) = -0.833333333333333
    b(32, 1) = 1.38888888888888
    b(32, 2) = 0
    b(32, 3) = 0
    b(32, 4) = -0.75
    b(32, 5) = 0
    b(32, 6) = -0.492529543718026
    b(32, 7) = 0
    b(32, 8) = 0
    b(32, 9) = 0
    b(32, 10) = 0
    b(32, 11) = 0
    b(32, 12) = 0
    b(32, 13) = 0
    b(32, 14) = 0
    b(32, 15) = 0
    b(32, 16) = 0
    b(32, 17) = 0
    b(32, 18) = 0
    b(32, 19) = 0
    b(32, 20) = 0
    b(32, 21) = 0
    b(32, 22) = 0
    b(32, 23) = 0
    b(32, 24) = 0
    b(32, 25) = 0
    b(32, 26) = 0
    b(32, 27) = 0
    b(32, 28) = 0
    b(32, 29) = 0
    b(32, 30) = 0.492529543718026
    b(32, 31) = 0.75
    b(33, 0) = 0.111111111111111
    b(33, 1) = 0
    b(33, 2) = -0.222222222222222
    b(33, 3) = 0
    b(33, 4) = 0
    b(33, 5) = 0
    b(33, 6) = 0
    b(33, 7) = 0
    b(33, 8) = 0
    b(33, 9) = 0
    b(33, 10) = 0
    b(33, 11) = 0
    b(33, 12) = 0
    b(33, 13) = 0
    b(33, 14) = 0
    b(33, 15) = 0
    b(33, 16) = 0
    b(33, 17) = 0
    b(33, 18) = 0
    b(33, 19) = 0
    b(33, 20) = 0
    b(33, 21) = 0
    b(33, 22) = 0
    b(33, 23) = 0
    b(33, 24) = 0
    b(33, 25) = 0
    b(33, 26) = 0
    b(33, 27) = 0
    b(33, 28) = 0
    b(33, 29) = 0
    b(33, 30) = 0
    b(33, 31) = 0
    b(33, 32) = 0.222222222222222
    b(34, 0) = 0.285835140388971
    b(34, 1) = 0.291666666666666
    b(34, 2) = 0.21875
    b(34, 3) = 0
    b(34, 4) = 0.1640625
    b(34, 5) = 0
    b(34, 6) = 0.218194354945556
    b(34, 7) = 0.180392898478697
    b(34, 8) = 0
    b(34, 9) = 0.205713839404845
    b(34, 10) = 0.24271579158177
    b(34, 11) = 0.246465780813629
    b(34, 12) = -3.4499194079089
    b(34, 13) = 0.228875562160036
    b(34, 14) = 0.283290599702151
    b(34, 15) = 3.21085125837766
    b(34, 16) = -0.223538777364845
    b(34, 17) = -0.707121157204419
    b(34, 18) = 3.21123345150287
    b(34, 19) = 1.40954348309669
    b(34, 20) = -0.151362053443742
    b(34, 21) = 0.372350574527014
    b(34, 22) = 0.252978746406361
    b(34, 23) = -3.21085125837766
    b(34, 24) = -0.283290599702151
    b(34, 25) = -0.228875562160036
    b(34, 26) = -0.246465780813629
    b(34, 27) = -0.24271579158177
    b(34, 28) = -0.205713839404845
    b(34, 29) = -0.180392898478697
    b(34, 30) = -0.218194354945556
    b(34, 31) = -0.1640625
    b(34, 32) = -0.21875
    b(34, 33) = -0.291666666666666

   
    pi = 3.14159265358979
    sigma = 10#
    rr = 26#
    bb = 8# / 3#
   
    x = 1#
    y = 1#
    z = 1#
   
    t = 0
    dt = 0.01
    jj = 2
   
    For i = 0 To 10000
        'If i Mod 1000 = 0 Then
            Worksheets("Sheet1").Cells(jj, 3) = t
            Worksheets("Sheet1").Cells(jj, 4) = x
            Worksheets("Sheet1").Cells(jj, 5) = y
            Worksheets("Sheet1").Cells(jj, 6) = z
            jj = jj + 1
        'End If
       
       
        kx(0) = x
        ky(0) = y
        kz(0) = z
       
        For k = 0 To 34
            kx(k) = x
            ky(k) = y
            kz(k) = z
            For j = 0 To k - 1
                kx(k) = kx(k) + b(k, j) * f1(t + a(j) * dt, kx(j), ky(j), kz(j)) * dt
                ky(k) = ky(k) + b(k, j) * f2(t + a(j) * dt, kx(j), ky(j), kz(j)) * dt
                kz(k) = kz(k) + b(k, j) * f3(t + a(j) * dt, kx(j), ky(j), kz(j)) * dt
            Next j
        Next k
       
       
        For k = 0 To 34
            x = x + c(k) * f1(t + a(k) * dt, kx(k), ky(k), kz(k)) * dt
            y = y + c(k) * f2(t + a(k) * dt, kx(k), ky(k), kz(k)) * dt
            z = z + c(k) * f3(t + a(k) * dt, kx(k), ky(k), kz(k)) * dt
        Next k

        t = t + dt
       
    Next i
    Application.ScreenUpdating = True
End Sub

Function f1(t As Double, x As Double, y As Double, z As Double) As Double
    f1 = -sigma * (x - y)
End Function

Function f2(t As Double, x As Double, y As Double, z As Double) As Double
    f2 = -y - x * z + rr * x
End Function

Function f3(t As Double, x As Double, y As Double, z As Double) As Double
    f3 = x * y - bb * z
End Function

お帰りなさい。VBAは4倍精度や拡張精度が使えないので、実用性はないですが。。。8次の公式のほうが精度がいいという逆転現象が。

このテキストファイルはこれ。

「Lorenz-eq-RK14th.txt」をダウンロード

計算結果はこちら。

Lorenz

« 芦屋で大楠公戦跡を見つけた。 | トップページ | 芦屋の稲荷神社の鳥居はなぜこんなところに。 »

学問・資格」カテゴリの記事

コメント

コメントを書く

(ウェブ上には掲載しません)

トラックバック

この記事のトラックバックURL:
http://app.cocolog-nifty.com/t/trackback/512682/47837262

この記事へのトラックバック一覧です: 14次の超高次ルンゲクッタ法でローレンツ方程式を計算(Excel VBA):

« 芦屋で大楠公戦跡を見つけた。 | トップページ | 芦屋の稲荷神社の鳥居はなぜこんなところに。 »

最近のコメント

2018年11月
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
フォト
無料ブログはココログ