text Sympyによる力学演习
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Sympyによる力学演习相关的知识,希望对你有一定的参考价值。
{
"cells": [
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from sympy import *\n",
"from sympy import printing\n",
"init_printing(use_latex='mathjax')\n",
"\n",
"import matplotlib.pyplot as plt\n",
"plt.rcParams['figure.figsize'] = (6,6)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 運動方程式"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 運動方程式の動径方向,方位角方向の成分"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"2次元極座標系における運動方程式$ma=F$を極座標で表示したほうが便利なことがある.この場合に,運動方程式を極座標に特有な方向に分解する.質点の直交座標$(x,y)$と極座標$(r, \\phi)$には次の関係がある.\n",
"\n",
"$$\n",
" x = r \\cos \\phi\n",
"$$\n",
"\n",
"これをsympyの記号演算で表してみる.時間変数を$t$,時刻$t$における位置の関数をそれぞれ$x, y, r, \\phi$として定義する."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"t = symbols('t')\n",
"x, y, r, phi = symbols('x, y, r, phi', cls=Function)\n",
"\n",
"xt = r(t) * cos(phi(t))\n",
"yt = r(t) * sin(phi(t))"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$x{\\left (t \\right )} = r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )}$$"
],
"text/plain": [
"x(t) = r(t)⋅cos(φ(t))"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(x(t), xt)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$y{\\left (t \\right )} = r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )}$$"
],
"text/plain": [
"y(t) = r(t)⋅sin(φ(t))"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(y(t), yt)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"ベクトルとして表示するには`Matrix`メソッドを用いる."
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}x{\\left (t \\right )}\\\\y{\\left (t \\right )}\\end{matrix}\\right] = \\left[\\begin{matrix}r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )}\\\\r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡x(t)⎤ = ⎡r(t)⋅cos(φ(t))⎤\n",
"⎢ ⎥ ⎢ ⎥\n",
"⎣y(t)⎦ ⎣r(t)⋅sin(φ(t))⎦"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lhs = Matrix([x(t), y(t)])\n",
"rhs = Matrix([r(t) * cos(phi(t)), r(t) * sin(phi(t))])\n",
"Eq(lhs, rhs)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"これを時間で微分することで速度,さらに微分することで加速度を得ることができる.\n",
"sympyの記号演算を用いれば速度,加速度を簡単に導出することができる."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### $x, y$座標系での速度の導出"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d}{d t} x{\\left (t \\right )} = - r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} + \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}$$"
],
"text/plain": [
"d d d \n",
"──(x(t)) = - r(t)⋅sin(φ(t))⋅──(φ(t)) + cos(φ(t))⋅──(r(t))\n",
"dt dt dt "
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(x(t).diff(t), xt.diff(t))"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d}{d t} y{\\left (t \\right )} = r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} + \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}$$"
],
"text/plain": [
"d d d \n",
"──(y(t)) = r(t)⋅cos(φ(t))⋅──(φ(t)) + sin(φ(t))⋅──(r(t))\n",
"dt dt dt "
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(y(t).diff(t), yt.diff(t))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"ベクトルによる表示は次のようになる."
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}\\frac{d}{d t} x{\\left (t \\right )}\\\\\\frac{d}{d t} y{\\left (t \\right )}\\end{matrix}\\right] = \\left[\\begin{matrix}- r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} + \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}\\\\r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} + \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡d ⎤ ⎡ d d ⎤\n",
"⎢──(x(t))⎥ = ⎢- r(t)⋅sin(φ(t))⋅──(φ(t)) + cos(φ(t))⋅──(r(t))⎥\n",
"⎢dt ⎥ ⎢ dt dt ⎥\n",
"⎢ ⎥ ⎢ ⎥\n",
"⎢d ⎥ ⎢ d d ⎥\n",
"⎢──(y(t))⎥ ⎢ r(t)⋅cos(φ(t))⋅──(φ(t)) + sin(φ(t))⋅──(r(t)) ⎥\n",
"⎣dt ⎦ ⎣ dt dt ⎦"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(lhs.diff(t), rhs.diff(t))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### $x, y$座標系での加速度の導出"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d}{d t} x{\\left (t \\right )} = - r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} - r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} - 2 \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )} + \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )}$$"
],
"text/plain": [
" 2 2 \n",
"d d ⎛d ⎞ \n",
"──(x(t)) = - r(t)⋅sin(φ(t))⋅───(φ(t)) - r(t)⋅cos(φ(t))⋅⎜──(φ(t))⎟ - 2⋅sin(φ(t\n",
"dt 2 ⎝dt ⎠ \n",
" dt \n",
"\n",
" 2 \n",
" d d d \n",
"))⋅──(φ(t))⋅──(r(t)) + cos(φ(t))⋅───(r(t))\n",
" dt dt 2 \n",
" dt "
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(x(t).diff(t), xt.diff(t, t))"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d}{d t} y{\\left (t \\right )} = - r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} + r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} + \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )} + 2 \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )}$$"
],
"text/plain": [
" 2 2 \n",
"d ⎛d ⎞ d \n",
"──(y(t)) = - r(t)⋅sin(φ(t))⋅⎜──(φ(t))⎟ + r(t)⋅cos(φ(t))⋅───(φ(t)) + sin(φ(t))\n",
"dt ⎝dt ⎠ 2 \n",
" dt \n",
"\n",
" 2 \n",
" d d d \n",
"⋅───(r(t)) + 2⋅cos(φ(t))⋅──(φ(t))⋅──(r(t))\n",
" 2 dt dt \n",
" dt "
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(y(t).diff(t), yt.diff(t, t))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"ベクトルによる表示は次のようになる."
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}\\frac{d^{2}}{d t^{2}} x{\\left (t \\right )}\\\\\\frac{d^{2}}{d t^{2}} y{\\left (t \\right )}\\end{matrix}\\right] = \\left[\\begin{matrix}- r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} - r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} - 2 \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )} + \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )}\\\\- r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} + r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} + \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )} + 2 \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡ 2 ⎤ ⎡ 2 2 \n",
"⎢ d ⎥ ⎢ d ⎛d ⎞ \n",
"⎢───(x(t))⎥ = ⎢- r(t)⋅sin(φ(t))⋅───(φ(t)) - r(t)⋅cos(φ(t))⋅⎜──(φ(t))⎟ - 2⋅sin\n",
"⎢ 2 ⎥ ⎢ 2 ⎝dt ⎠ \n",
"⎢dt ⎥ ⎢ dt \n",
"⎢ ⎥ ⎢ \n",
"⎢ 2 ⎥ ⎢ 2 2 \n",
"⎢ d ⎥ ⎢ ⎛d ⎞ d \n",
"⎢───(y(t))⎥ ⎢- r(t)⋅sin(φ(t))⋅⎜──(φ(t))⎟ + r(t)⋅cos(φ(t))⋅───(φ(t)) + sin(φ\n",
"⎢ 2 ⎥ ⎢ ⎝dt ⎠ 2 \n",
"⎣dt ⎦ ⎣ dt \n",
"\n",
" 2 ⎤\n",
" d d d ⎥\n",
"(φ(t))⋅──(φ(t))⋅──(r(t)) + cos(φ(t))⋅───(r(t))⎥\n",
" dt dt 2 ⎥\n",
" dt ⎥\n",
" ⎥\n",
" 2 ⎥\n",
" d d d ⎥\n",
"(t))⋅───(r(t)) + 2⋅cos(φ(t))⋅──(φ(t))⋅──(r(t))⎥\n",
" 2 dt dt ⎥\n",
" dt ⎦"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(lhs.diff(t, t), rhs.diff(t, t))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 回転行列による座標変換"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$x, y$座標から$r, \\phi$座標への変換マトリックス$TR$は次の通りである."
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}\\cos{\\left (\\phi{\\left (t \\right )} \\right )} & \\sin{\\left (\\phi{\\left (t \\right )} \\right )}\\\\- \\sin{\\left (\\phi{\\left (t \\right )} \\right )} & \\cos{\\left (\\phi{\\left (t \\right )} \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡cos(φ(t)) sin(φ(t))⎤\n",
"⎢ ⎥\n",
"⎣-sin(φ(t)) cos(φ(t))⎦"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"TR = Matrix([[cos(phi(t)), sin(phi(t))], [-sin(phi(t)), cos(phi(t))]])\n",
"TR"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$r, \\phi$座標系での速度,加速度は$x, y$座標系で結果に回転行列を乗じて得られる."
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}\\frac{d}{d t} r{\\left (t \\right )}\\\\r{\\left (t \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡ d ⎤\n",
"⎢ ──(r(t)) ⎥\n",
"⎢ dt ⎥\n",
"⎢ ⎥\n",
"⎢ d ⎥\n",
"⎢r(t)⋅──(φ(t))⎥\n",
"⎣ dt ⎦"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(TR * rhs.diff(t))"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}- r{\\left (t \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} + \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )}\\\\r{\\left (t \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} + 2 \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡ 2 2 ⎤\n",
"⎢ ⎛d ⎞ d ⎥\n",
"⎢ - r(t)⋅⎜──(φ(t))⎟ + ───(r(t)) ⎥\n",
"⎢ ⎝dt ⎠ 2 ⎥\n",
"⎢ dt ⎥\n",
"⎢ ⎥\n",
"⎢ 2 ⎥\n",
"⎢ d d d ⎥\n",
"⎢r(t)⋅───(φ(t)) + 2⋅──(φ(t))⋅──(r(t))⎥\n",
"⎢ 2 dt dt ⎥\n",
"⎣ dt ⎦"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(TR * rhs.diff(t, t))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\n",
"a_r(t) = - r{\\left (t \\right )} \\left(\\frac{d}{d t} p{\\left (t \\right )}\\right)^{2} + \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )}\n",
"$$\n",
"\n",
"$$\n",
"a_p(t) = r{\\left (t \\right )} \\frac{d^{2}}{d t^{2}} p{\\left (t \\right )} + 2 \\frac{d}{d t} p{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )}\n",
"$$\n",
"\n",
"したがって、極座標の運動方程式は次のようになる。\n",
"\n",
"$$\n",
"M a_r(t) = F_r \\\\\n",
"M a_p(t) = F_p\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 運動方程式の動径方向,子午線方向,方位各方向の成分"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"3次元直交空間の運動方程式を極座標表示することを考える.2次元の場合と同様に記号を定義する."
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"t = symbols('t')\n",
"x, y, r, theta, phi= symbols('x, y, r, theta, phi', cls=Function)\n",
"\n",
"xt = r(t) * sin(theta(t)) * cos(phi(t))\n",
"yt = r(t) * sin(theta(t)) * sin(phi(t))\n",
"zt = r(t) * cos(theta(t))"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$x{\\left (t \\right )} = r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )}$$"
],
"text/plain": [
"x(t) = r(t)⋅sin(θ(t))⋅cos(φ(t))"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(x(t), xt)"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$y{\\left (t \\right )} = r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )}$$"
],
"text/plain": [
"y(t) = r(t)⋅sin(φ(t))⋅sin(θ(t))"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(y(t), yt)"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$z{\\left (t \\right )} = r{\\left (t \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )}$$"
],
"text/plain": [
"z(t) = r(t)⋅cos(θ(t))"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(z(t), zt)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"これをベクトル表示すると次のようになる.\n"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}x{\\left (t \\right )}\\\\y{\\left (t \\right )}\\\\z{\\left (t \\right )}\\end{matrix}\\right] = \\left[\\begin{matrix}r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )}\\\\r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )}\\\\r{\\left (t \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡x(t)⎤ = ⎡r(t)⋅sin(θ(t))⋅cos(φ(t))⎤\n",
"⎢ ⎥ ⎢ ⎥\n",
"⎢y(t)⎥ ⎢r(t)⋅sin(φ(t))⋅sin(θ(t))⎥\n",
"⎢ ⎥ ⎢ ⎥\n",
"⎣z(t)⎦ ⎣ r(t)⋅cos(θ(t)) ⎦"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lhs = Matrix([x(t), y(t), z(t)])\n",
"rhs = Matrix([xt, yt, zt])\n",
"Eq(lhs, rhs)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### $x, y, z$座標系での速度の導出"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d}{d t} x{\\left (t \\right )} = - r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} + r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} + \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}$$"
],
"text/plain": [
"d d d \n",
"──(x(t)) = - r(t)⋅sin(φ(t))⋅sin(θ(t))⋅──(φ(t)) + r(t)⋅cos(φ(t))⋅cos(θ(t))⋅──(θ\n",
"dt dt dt \n",
"\n",
" d \n",
"(t)) + sin(θ(t))⋅cos(φ(t))⋅──(r(t))\n",
" dt "
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(x(t).diff(t), xt.diff(t))"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d}{d t} y{\\left (t \\right )} = - r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} + r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} + \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}$$"
],
"text/plain": [
"d d d \n",
"──(y(t)) = - r(t)⋅sin(φ(t))⋅sin(θ(t))⋅──(φ(t)) + r(t)⋅cos(φ(t))⋅cos(θ(t))⋅──(θ\n",
"dt dt dt \n",
"\n",
" d \n",
"(t)) + sin(θ(t))⋅cos(φ(t))⋅──(r(t))\n",
" dt "
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(y(t).diff(t), xt.diff(t))"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d}{d t} z{\\left (t \\right )} = - r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} + r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} + \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}$$"
],
"text/plain": [
"d d d \n",
"──(z(t)) = - r(t)⋅sin(φ(t))⋅sin(θ(t))⋅──(φ(t)) + r(t)⋅cos(φ(t))⋅cos(θ(t))⋅──(θ\n",
"dt dt dt \n",
"\n",
" d \n",
"(t)) + sin(θ(t))⋅cos(φ(t))⋅──(r(t))\n",
" dt "
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(z(t).diff(t), xt.diff(t))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"ベクトルでの表示は次の通り."
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}\\frac{d}{d t} x{\\left (t \\right )}\\\\\\frac{d}{d t} y{\\left (t \\right )}\\\\\\frac{d}{d t} z{\\left (t \\right )}\\end{matrix}\\right] = \\left[\\begin{matrix}- r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} + r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} + \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}\\\\r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} + r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} + \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}\\\\- r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} + \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡d ⎤ ⎡ d d\n",
"⎢──(x(t))⎥ = ⎢- r(t)⋅sin(φ(t))⋅sin(θ(t))⋅──(φ(t)) + r(t)⋅cos(φ(t))⋅cos(θ(t))⋅─\n",
"⎢dt ⎥ ⎢ dt d\n",
"⎢ ⎥ ⎢ \n",
"⎢d ⎥ ⎢ d d \n",
"⎢──(y(t))⎥ ⎢ r(t)⋅sin(φ(t))⋅cos(θ(t))⋅──(θ(t)) + r(t)⋅sin(θ(t))⋅cos(φ(t))⋅──\n",
"⎢dt ⎥ ⎢ dt dt\n",
"⎢ ⎥ ⎢ \n",
"⎢d ⎥ ⎢ d \n",
"⎢──(z(t))⎥ ⎢ - r(t)⋅sin(θ(t))⋅──(θ(t)) + cos(θ(t)\n",
"⎣dt ⎦ ⎣ dt \n",
"\n",
" d ⎤\n",
"─(θ(t)) + sin(θ(t))⋅cos(φ(t))⋅──(r(t))⎥\n",
"t dt ⎥\n",
" ⎥\n",
" d ⎥\n",
"(φ(t)) + sin(φ(t))⋅sin(θ(t))⋅──(r(t)) ⎥\n",
" dt ⎥\n",
" ⎥\n",
" d ⎥\n",
")⋅──(r(t)) ⎥\n",
" dt ⎦"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq( lhs.diff(t), rhs.diff(t) )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### $x, y, z$座標系での加速度の導出"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d^{2}}{d t^{2}} x{\\left (t \\right )} = - r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} - 2 r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} - r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} - r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}^{2} + r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\theta{\\left (t \\right )} - 2 \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )} + \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )} + 2 \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}$$"
],
"text/plain": [
" 2 2 \n",
" d d \n",
"───(x(t)) = - r(t)⋅sin(φ(t))⋅sin(θ(t))⋅───(φ(t)) - 2⋅r(t)⋅sin(φ(t))⋅cos(θ(t))⋅\n",
" 2 2 \n",
"dt dt \n",
"\n",
" 2 \n",
"d d ⎛d ⎞ \n",
"──(φ(t))⋅──(θ(t)) - r(t)⋅sin(θ(t))⋅cos(φ(t))⋅⎜──(φ(t))⎟ - r(t)⋅sin(θ(t))⋅cos(\n",
"dt dt ⎝dt ⎠ \n",
" \n",
"\n",
" 2 2 \n",
" ⎛d ⎞ d \n",
"φ(t))⋅⎜──(θ(t))⎟ + r(t)⋅cos(φ(t))⋅cos(θ(t))⋅───(θ(t)) - 2⋅sin(φ(t))⋅sin(θ(t))\n",
" ⎝dt ⎠ 2 \n",
" dt \n",
"\n",
" 2 \n",
" d d d d \n",
"⋅──(φ(t))⋅──(r(t)) + sin(θ(t))⋅cos(φ(t))⋅───(r(t)) + 2⋅cos(φ(t))⋅cos(θ(t))⋅──(\n",
" dt dt 2 dt \n",
" dt \n",
"\n",
" \n",
" d \n",
"r(t))⋅──(θ(t))\n",
" dt \n",
" "
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(x(t).diff(t, t), simplify(xt.diff(t, t)))"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d^{2}}{d t^{2}} y{\\left (t \\right )} = - r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} - 2 r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} - r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} - r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}^{2} + r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\theta{\\left (t \\right )} - 2 \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )} + \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )} + 2 \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}$$"
],
"text/plain": [
" 2 2 \n",
" d d \n",
"───(y(t)) = - r(t)⋅sin(φ(t))⋅sin(θ(t))⋅───(φ(t)) - 2⋅r(t)⋅sin(φ(t))⋅cos(θ(t))⋅\n",
" 2 2 \n",
"dt dt \n",
"\n",
" 2 \n",
"d d ⎛d ⎞ \n",
"──(φ(t))⋅──(θ(t)) - r(t)⋅sin(θ(t))⋅cos(φ(t))⋅⎜──(φ(t))⎟ - r(t)⋅sin(θ(t))⋅cos(\n",
"dt dt ⎝dt ⎠ \n",
" \n",
"\n",
" 2 2 \n",
" ⎛d ⎞ d \n",
"φ(t))⋅⎜──(θ(t))⎟ + r(t)⋅cos(φ(t))⋅cos(θ(t))⋅───(θ(t)) - 2⋅sin(φ(t))⋅sin(θ(t))\n",
" ⎝dt ⎠ 2 \n",
" dt \n",
"\n",
" 2 \n",
" d d d d \n",
"⋅──(φ(t))⋅──(r(t)) + sin(θ(t))⋅cos(φ(t))⋅───(r(t)) + 2⋅cos(φ(t))⋅cos(θ(t))⋅──(\n",
" dt dt 2 dt \n",
" dt \n",
"\n",
" \n",
" d \n",
"r(t))⋅──(θ(t))\n",
" dt \n",
" "
]
},
"execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(y(t).diff(t, t), xt.diff(t, t))"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d^{2}}{d t^{2}} z{\\left (t \\right )} = - r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} - 2 r{\\left (t \\right )} \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} - r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} - r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}^{2} + r{\\left (t \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\theta{\\left (t \\right )} - 2 \\sin{\\left (\\phi{\\left (t \\right )} \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )} + \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )} + 2 \\cos{\\left (\\phi{\\left (t \\right )} \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} r{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}$$"
],
"text/plain": [
" 2 2 \n",
" d d \n",
"───(z(t)) = - r(t)⋅sin(φ(t))⋅sin(θ(t))⋅───(φ(t)) - 2⋅r(t)⋅sin(φ(t))⋅cos(θ(t))⋅\n",
" 2 2 \n",
"dt dt \n",
"\n",
" 2 \n",
"d d ⎛d ⎞ \n",
"──(φ(t))⋅──(θ(t)) - r(t)⋅sin(θ(t))⋅cos(φ(t))⋅⎜──(φ(t))⎟ - r(t)⋅sin(θ(t))⋅cos(\n",
"dt dt ⎝dt ⎠ \n",
" \n",
"\n",
" 2 2 \n",
" ⎛d ⎞ d \n",
"φ(t))⋅⎜──(θ(t))⎟ + r(t)⋅cos(φ(t))⋅cos(θ(t))⋅───(θ(t)) - 2⋅sin(φ(t))⋅sin(θ(t))\n",
" ⎝dt ⎠ 2 \n",
" dt \n",
"\n",
" 2 \n",
" d d d d \n",
"⋅──(φ(t))⋅──(r(t)) + sin(θ(t))⋅cos(φ(t))⋅───(r(t)) + 2⋅cos(φ(t))⋅cos(θ(t))⋅──(\n",
" dt dt 2 dt \n",
" dt \n",
"\n",
" \n",
" d \n",
"r(t))⋅──(θ(t))\n",
" dt \n",
" "
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Eq(z(t).diff(t, t), xt.diff(t, t))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"回転行列による座標返還"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"TR = Matrix([\n",
" [ cos(phi(t)) * sin(theta(t)), sin(theta(t)) * sin(phi(t)), cos(theta(t)) ],\n",
" [ cos(theta(t)) * cos(phi(t)), cos(theta(t)) * sin(phi(t)), - sin(theta(t)) ],\n",
" [ -sin(phi(t)) , cos(phi(t)) , 0 ]\n",
"])"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}\\frac{d}{d t} r{\\left (t \\right )}\\\\r{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}\\\\r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡ d ⎤\n",
"⎢ ──(r(t)) ⎥\n",
"⎢ dt ⎥\n",
"⎢ ⎥\n",
"⎢ d ⎥\n",
"⎢ r(t)⋅──(θ(t)) ⎥\n",
"⎢ dt ⎥\n",
"⎢ ⎥\n",
"⎢ d ⎥\n",
"⎢r(t)⋅sin(θ(t))⋅──(φ(t))⎥\n",
"⎣ dt ⎦"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(TR * rhs.diff(t))"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}- r{\\left (t \\right )} \\sin^{2}{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} - r{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}^{2} + \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )}\\\\- \\frac{1}{2} r{\\left (t \\right )} \\sin{\\left (2 \\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} + r{\\left (t \\right )} \\frac{d^{2}}{d t^{2}} \\theta{\\left (t \\right )} + 2 \\frac{d}{d t} r{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}\\\\r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} + 2 r{\\left (t \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} + 2 \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )}\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡ 2 2 2 \n",
"⎢ 2 ⎛d ⎞ ⎛d ⎞ d \n",
"⎢ - r(t)⋅sin (θ(t))⋅⎜──(φ(t))⎟ - r(t)⋅⎜──(θ(t))⎟ + ───(r(t)) \n",
"⎢ ⎝dt ⎠ ⎝dt ⎠ 2 \n",
"⎢ dt \n",
"⎢ \n",
"⎢ 2 \n",
"⎢ ⎛d ⎞ \n",
"⎢ r(t)⋅sin(2⋅θ(t))⋅⎜──(φ(t))⎟ 2 \n",
"⎢ ⎝dt ⎠ d d d \n",
"⎢ - ──────────────────────────── + r(t)⋅───(θ(t)) + 2⋅──(r(t))⋅──(θ\n",
"⎢ 2 2 dt dt \n",
"⎢ dt \n",
"⎢ \n",
"⎢ 2 \n",
"⎢ d d d d\n",
"⎢r(t)⋅sin(θ(t))⋅───(φ(t)) + 2⋅r(t)⋅cos(θ(t))⋅──(φ(t))⋅──(θ(t)) + 2⋅sin(θ(t))⋅─\n",
"⎢ 2 dt dt d\n",
"⎣ dt \n",
"\n",
" ⎤\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
"(t)) ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
" d ⎥\n",
"─(φ(t))⋅──(r(t))⎥\n",
"t dt ⎥\n",
" ⎦"
]
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(TR * rhs.diff(t, t))"
]
},
{
"cell_type": "code",
"execution_count": 79,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} + 2 r{\\left (t \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} + 2 \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )}\n"
]
}
],
"source": [
"A = simplify(TR * rhs.diff(t, t))\n",
"print(latex(A[2]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\n",
"a_r(t) = - r{\\left (t \\right )} \\sin^{2}{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} - r{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}^{2} + \\frac{d^{2}}{d t^{2}} r{\\left (t \\right )}\n",
"$$\n",
"\n",
"$$\n",
"a_{\\theta}(t) = - \\frac{1}{2} r{\\left (t \\right )} \\sin{\\left (2 \\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )}^{2} + r{\\left (t \\right )} \\frac{d^{2}}{d t^{2}} \\theta{\\left (t \\right )} + 2 \\frac{d}{d t} r{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )}\n",
"$$\n",
"\n",
"$$\n",
"a_{\\phi}(t) = r{\\left (t \\right )} \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d^{2}}{d t^{2}} \\phi{\\left (t \\right )} + 2 r{\\left (t \\right )} \\cos{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} \\theta{\\left (t \\right )} + 2 \\sin{\\left (\\theta{\\left (t \\right )} \\right )} \\frac{d}{d t} \\phi{\\left (t \\right )} \\frac{d}{d t} r{\\left (t \\right )}\n",
"$$\n",
"\n",
"したがって,極座標の運動方程式は次のようになる.\n",
"\n",
"$$\n",
"M a_r(t) = F_r \\\\\n",
"M a_{\\theta}(t) = F_{\\theta} \\\\\n",
"M a_{\\phi}(t) = F_{\\phi}\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"_draft": {
"nbviewer_url": "https://gist.github.com/5525105636a06f5985e7d667c0937ce5"
},
"anaconda-cloud": {},
"gist": {
"data": {
"description": "sympy notebook.ipynb",
"public": true
},
"id": "5525105636a06f5985e7d667c0937ce5"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
},
"nav_menu": {},
"toc": {
"navigate_menu": true,
"number_sections": false,
"sideBar": true,
"threshold": 6,
"toc_cell": true,
"toc_section_display": "block",
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 0
}
以上是关于text Sympyによる力学演习的主要内容,如果未能解决你的问题,请参考以下文章