Ȼ/13

Top / Ȼ / 13

βˤĤ

ž夲ϡͿ줿Ͽޤ֤Ǻûϩƻ̤ꤢ뤫ȤΤǤä
(ϿޤˤĤƤ web 򻲾ȤΤ)

ޤľǴñʷ򤷤ƤΤǡûϩθĿˤñʥ롼ǤǤ뤳ȤΥҥȤ狼äȻפ
Ūˤϡ


֤̤ûϩϡξ̤äƤäƤ


Τǡϸȡ


֤̤ûϩο = ξ̤ûϩο + α̤ûϩο


ȤȤˤʤ롥ȤϤŪˤƤФ褤
㤨Ͽޤľ x,y ɸǰʲΤ褦ħդȤơ

route-exp.png

Τ褦˹ͤȤ褦
ΤȤɸ (i,j) (0 ≤ i ≤ 6, 0 ≤ j ≤ 4)̤ûϩο f(i,j)ȤȡľаʲΤ褦ʴطΩĤȤʬ롥

map-eq-1.png

ȤʤΤǡȤФ褤Ȥϡδط˶ᤤȤȤǥץν㤦

ʤμޤǼŸ

map-eq-2.png

ȤäƤɤ褦ˡֿʹ֤ޤDz˷׻Ԥ뤳ȤפΤǡŪˤϤɤޤDz뤫ǺޤξϤޤְ㤨ʤ


ƵȤ

Ͽľ˻ȤФ褤Τǡ㤨аʲΤ褦ˤʤ

  1. include Math
  2.  
  3. # f Ƶ
  4. def f(i,j)
  5.   if ((i==6) && (j==4)) then
  6.       return 1
  7.     elsif (j==4) then
  8.       return f(i+1,4)
  9.     elsif (i==6) then
  10.       return f(6,j+1)
  11.     else
  12.       return f(i+1,j) + f(i, j+1)
  13.   end
  14. end
  15.  
  16. # ʲץ
  17.  
  18. # f(0,0) ͤϤ롥
  19. print(f(0,0),"\n")


ưŪײˡɤȤ

Start 顤ֲƥåܤפȤȤܤСƥå׿䤷Ƥ褦˷׻ʤФ褤Ȥ˵ŤĤޤꡤοޤ֤ʸν˷׻ʤ٤ȤȤ狼

route-exp-2.png

פ뤬ޤ㤨мΤ褦˥ץ񤱤

  1. include Math
  2.  
  3. # step ξۤ׻ƤäơGoal Ǥ֤ͤ. ϿޤΥ̤ˤƤ.
  4. def calc_top(nx,ny)
  5.  
  6.   # ̤ûϩϿƤѰդ褦
  7.   f = Array.new(nx+1){ Array.new(ny+1){ 0 } }
  8.  
  9.   # Start Ǥ f 1 ͡
  10.   f[nx][ny] = 1
  11.  
  12.   # ƥå׿
  13.   all_step = nx + ny
  14.  
  15.   # step 1 all_step ޤ
  16.   for step in 1..all_step do
  17.  
  18.     # Ʊ step x + y =  all_step - step ȤѤơ
  19.     for i in 0..(all_step - step) do
  20.       j = (all_step - step) - i
  21.       if ((0 <= i) && (i <= nx) && (0 <= j) && (j <= ny)) then # ϿޤȤθФ褤
  22.  
  23.         # Ȥ̤˷׻
  24.         if (i==nx) then
  25.             f[i][j] = f[i][j+1]
  26.           elsif (j==ny) then
  27.             f[i][j] = f[i+1][j]
  28.           else
  29.             f[i][j] = f[i+1][j] + f[i][j+1]
  30.         end
  31.  
  32.       end
  33.     end
  34.  
  35.   end
  36.  
  37.   # f(0,0) ֤
  38.   return f[0][0]
  39. end
  40.  
  41. # Goal Ǥ f ͤ׻
  42. ans = calc_top(6,4)
  43.  
  44. # Τꤿͤɽ
  45. print(ans,"\n")

ͤ

ûϩΰ¸طͤȡֱ夫麸˼ФפäʤळȤ狼롥
ȡ֤μФľפˤʤΤǡ˿ޤ򷹤ƹͤΤŪľȤȤˤʤ롥
ºݤ˷Ƥߤ褦
ȡ¸طΡڹ¤פΤȤǤääƱʤΤǡĤƱͤˡڹ¤פǹͤȤʬ䤹ȤȤ¬Ĥ
ǡȤΤ֤狼䤹ڹ¤פˤʤ褦ˤϿޤ򾯤­ΤΤĤĤޤ礦褦ˡաפ˿ĤȰʲΤ褦ʿޤˤʤ롥

route-tree.png

Ȥϡο­ȼʬοˤʤ롤ȤȤߤƱ褦˥ץह
ǹͤȡưŪײˡɤΥץߥ󥰤Ȱäƿʬñ˽񤱤Ϥ
׻̤뤬ľʥץˤϥߥΨʰ㤤㤯ʤ롥
ְäƤа̵̣Τ顤ޤϤľʡסֳμ¤ʡץץܻؤ


Τ褦ˡ

¸طʤɤ褯ͤơ
ꤽΤΤ䤹ľȤ
ץߥ󥰤ˤϽפǤ롥

: ʬ򤤤, 򸫤Ƥߤ褦

ޤǤǥץߥ󥰤ˤĤμϿȤˤĤΤǡѤظƼ½ԤäƤߤ褦
ब뤬ޤϤñʾʬФơ׻򤷤ƶƤͻҤߤȤϢήäƤߤ褦


ͳ򥷥ߥ졼ȤƤߤ

Ǥ褯ΤäƤʬǤ롤Newton ϳؤ˴Ťư˼夲褦
ޤäȤñʡֿʪΤͳƤͻҡפͤ褦

֤ t sec, Ͼ夫ʪΤι⤵ u(t) mϲ® g = 9.8 m/(s^2) Ȥȡ
Newton αư F = ma ꡤ

newton.png
ʪΤι⤵ˤĤƤξʬ

Ȥʬ롥
󳬾ʬǾˤΤǡ® v = du/dt Ȥ°ѿƳơ

newton-2.png
ʪΤι⤵ˤĤƤξʬ(ѷ)

ȤΤѷơˤĤƹͤ褦
ϼDz򤱤ƤޤǸ̩򤬵ޤʤˤѤͤȤƺϥץǶƤߤ褦ˤ͡ʼˡ뤬ϺǤñ Eulerˡ ȤΤȤäƤߤ褦


Euler ˡ

Euler ˡȤΤϴñǡȯŸʺʬǶ뤳ȤǡŤ֤ѿͤȿ֤ѿͤФƤطѷΤǤ롥

ޤ긫ۤᤤ
ξ硤ѿ t t ǡֹפȤˤơξʬ

euler.png
ξʬ Euler ˡǡֶפ

ȤΤ Euler ˡǤ롥Ƥμ򤭤줤˽ľȡ

euler-2.png
ξʬ Euler ˡǡֶפ(դֿ͡סդֵ͡)

ȤʤΤǡߤȡֱդΤäƤͤǡ֤Ǥͤ׷ˤʤäƤ롥
ʬ򤳤Τ褦˶֤Τ Euler ˡǤ롥
ʤץब񤱤Ȥ

warning.png Euler ˡǺäֶפ򤤤ΤϡֶפǤꡤȤξʬβǤϤʤʤ˰ʤ󤸤ʤ ȤԤ򤹤ȤȤ͡

ơߥ졼Ȥˤ϶ŪʾͤʤȤʤ
ǡʲΤ褦˽ʤɤꤷ褦

[]
⤵ u(0) = 1000.0 (m)
® v(0) = 0.0 (m/s)

[λ]
⤵ 0 mʲȤʤä饷ߥ졼λ.

[]
ֹ t = 0.1 sec


ץ

notes.png ʲʬϼ½ʤ򤷤褦

ץϾξ˽äƷ׻ , ⤵ οڥϤΤȤ褦
ȡʲΤ褦ʴˤʤ

  1. include Math
  2.  
  3. # Euler ˡ˴Ťơλ֥ƥåפ u,v ׻
  4. def euler(u,v, dt)
  5.   g = 9.8
  6.  
  7.   u_new = u + v*dt
  8.   v_new = v - g*dt
  9.  
  10.   return u_new, v_new
  11. end
  12.  
  13. # ֤ȹ⤵Ϥ
  14. def output(u, time)
  15.   print(time,", ",u,"\n")
  16. end
  17.  
  18. # ʲץ
  19.  
  20. # 
  21. u = 1000.0
  22. v = 0.0
  23. time = 0.0
  24.  
  25. # ֹ
  26. dt = 0.1
  27.  
  28. # ⤵ u ΤϷ׻򷫤֤
  29. while (u > 0) do
  30.  
  31.   # ⤵Ȼ֤
  32.   output(u, time)
  33.  
  34.   # Euler ˡǼλ֥ƥåפ u,v ׻
  35.   u,v = euler(u,v,dt)
  36.  
  37.   # ֤򹹿
  38.   time += dt
  39. end


ץưƥǡ

Υץ¹Ԥơǡ褦줿ǡ̤ɽǤϤޤΩʤΤǡե¸褦
ˤ㤨СΥץե̾ euler.rb Ȥơ

 ruby -w euler.rb > euler.dat

ʤɤȤƼ¹ԤФ褤ĤΤϳФƤ͡ ξ硤ǡ euler.dat Ȥե¸롥


줿ǡưŪ˸Ƥߤ褦

Υǡե򸫤Ƥߤȡ 144Ԥ롥ǡ 144Ԥ 1Ԥ gnuplot ʤɤǸƤߤưŪ˾뤳Ȥˤʤ롥
ǡʲΤ褦˺ȤƤߤ褦

1) gnuplot ưե: euler.plt Ȥ̾ΥեꡤȤ񤭹ࡥ

  1. set xrange[0:15]
  2. set yrange[0:1000]
  3. set xlabel "Time"
  4. set ylabel "Height"
  5. unset key
  6.  
  7. line=0
  8. load "euler.loop"


2) gnuplot ưե(1Ԥɽʬ): euler.loop Ȥ̾ΥեꡤȤ񤭹ࡥ

  1. plot "euler.dat" every ::line::line w p pt 6 ps 3
  2. line=line+1
  3. pause 0.2
  4. if(line<144) reread


3a) gnuplot (˥塼 Math gnuplot) ư
3b) Υǡե euler.dat, gnuplot ưե euler.plt, euler.loop 3ĤΥե뤬֤Ƥǥ쥯ȥ gnuplot ưǥ쥯ȥְưפ(ְưפȤChDirפȤ񤤤Ƥܥ󤬤)
3c) gnuplot ̤̿

 load "euler.plt"

Ϥ롥꤬ʤСʲοޤΤ褦ɽưŪˤι⤵򼨤 ưƤϤ(˻֤ȤäƤ)

gnuplot-movie.png

warning.png gnuplot 1Ԥɽ򷫤֤Τ˻ȤäƤƥ˥åϼ˰ʲĤǤ롥

  • reread : ϡ̿᤬äեɤľȤ̣Ǥ롥if Ȥ߹碌 Ruby while ߤ˻ȤäƤ롥
  • plot ̿θˤĤƤ every ::line::line : ϥǡ line+1 ܤΤߤɤ plot ȤȤ̣롥

warning.png ٤Ƥνִ֤βѰդĤʤưȤˡ⤢롥;͵ΤΤϤ˥󥸤Τ褤ʤߤˡĤʤưˤ륽եȥȤWindows Ϥʤ

  • ɥࡼӡ᡼
    (ؤPC ξ: ˥塼 ץ ե̾ꤷƼ¹ moviemk.exe ǵư): Windows °̵ե
  • TMPGEnc ̵

ʤɤUnix (ޤ Mac)ʤ

  • ffmpeg

ʤɤΤ(ǥ󥹥ȡ뤬ɬפʤΤϥ󥹥ȡ뤷)ȤäƤߤ褦

ž夲

Ʊͤˡ٤Ͻϲ Newton αư˱äưֿҤαưפ򥷥ߥ졼󤷤Ƥߤ褦

pendulum.png

ޤϳƾʲΤ褦ˤƤߤ褦

[]
ҤɳĹ L = 1.0 m

[]
θ(0) = π/3 (rad) = 60.0 ()
® dθ/dt(0) = 0.0 (rad/s)

[λ]
t = 0 sec 鳫ϤơƼʬǷ᤿ t = T_limit (5.0餤?)ޤǥߥ졼Ԥ.

[]
ֹ t = 0.01 sec (Ƥ)

[ˡ]
Euler ˡ

warning.png ٤϶֤󼡸ȯŸѿϡֳ١װĤ˵Ǥ롥
ǡޤ Newton αư٤Фʬѷ褦
줫顤Τ褦ˡ°ѿ򿷤˲ä뤳Ȥ 1ξʬѷ褦
Euler ˡǶŪ˲򤱤
ȡץΥǡϻ x, y 󼡸κɸѴʤư褬ʤΤǡϵĤ褦

Ը(1)

ſҡ(ĤοҤˤ˿Ҥ֤鲼äƤ)ˤĤƱͤ˥ߥ졼󤷤Ƥߤ褦.


Ը(2)

Euler ˡǤϤʤŵ Runge-Kutta ˡȤФˡˤĤĴ١ȤƻȤäƤߤ褦


ݡ

ֵӹԤä½ˤĤơñˤޤȤ᤿򤻤.
ޤž夲ʬǼʬǽ񤤤ץ𤻤.

Ƽ

  1. °(ز)
  2. ֹ
  3. ǯ
  4. ̾
  5. οΥݡ(θȤˤĤƵŤ)

񤯤Τ˺ʤ褦.

about Icons, ClipArts

Some icons in this page are downloadable at ICONFINDER.

The "note" icon notes.png designed by Marco Martin is distributed with the LGPL licence,
the "warning" icon warning.png designed by Alexandre Moore with the GPL licence
and the "triangle" icon JNorth_arrow-right-sm.png designed by Joseph North is distributed with the Creative Commons (Attribution-Noncommercial-Share Alike 3.0 Unported) licence.

Some clip arts used in this page are downloadable at Open Clip Art Library.
We deeply appreciate their superb works. With licence, they describe that "the actual clipart content on open clipart library is Public domain" in the web.