next up previous
Next: 4 少し難しい (単に積分だけでは解けない) 微分方程式 Up: 微分方程式 少し背伸びして挑戦 Previous: 2.2 放物運動 (projectile motion,

3 Mathematica の DSolve[]

前節の例 2.2 を Mathematica を使って解いてみよう。

Mathematica には、 微分方程式 (differential equation) を解くための DSolve[ ] という関数がある。 微分方程式 (1) と初期条件 (3) を与えれば解を求めてくれる。

以下では念のため最初に Remove[] で掃除している (Mathematica 起動直後ならば不要)。
Remove["Global`*"]
DSolve[{x''[t] == 0, y''[t] == -g, 
        x[0] == 0, y[0] == 0,
        x'[0] == v Cos[theta],  y'[0]== v Sin[theta]},
        {x, y}, t]
または
DSolve[{x''[t] == 0, y''[t] == -g, 
        x[0] == 0, y[0] == 0,
        x'[0] == v Cos[theta],  y'[0]== v Sin[theta]},
        {x[t], y[t]}, t]

解や軌跡を図示してみよう。そのためには、 sol=x[t],y[t]/.DSolve[...] として、変数 (ここでは sol) に代入しておくのが便利である。 また、g, v, theta なども 具体的な数値を与える必要がある。

sol={x[t],y[t]} /. DSolve[{x''[t] == 0, y''[t] == -g, 
        x[0] == 0, y[0] == 0,
        x'[0] == v Cos[theta],  y'[0]== v Sin[theta]},
        {x[t], y[t]}, t]

g1=Plot[sol /. {g->9.8, v-> 20, theta->45Degree}, {t,0, 2}]
g2=ParametricPlot[sol /. {g -> 9.8, v -> 20, theta -> 45 Degree}, {t, 0,3}]
Export["projection.eps",g2]
(ここでは {g->9.8, v->20, theta->45Degree} と 一時的な代入を行なったが、g=9.8; v=20; theta=45Degree と 代入しておくことも可能である。)

図 1: $ x(t)$ $ u(t)$
\includegraphics[width=6cm]{eps/projection1.eps}
図 2: $ (x,y)$ の軌跡
\includegraphics[width=6cm]{eps/projection2.eps}


next up previous
Next: 4 少し難しい (単に積分だけでは解けない) 微分方程式 Up: 微分方程式 少し背伸びして挑戦 Previous: 2.2 放物運動 (projectile motion,
桂田 祐史
2013-07-14