Skip to content

Commit

Permalink
Merge pull request #7 from ara-ta3/2016/09/28
Browse files Browse the repository at this point in the history
2016/09/28 進捗
  • Loading branch information
ara-ta3 committed Sep 28, 2016
2 parents 17c90a8 + 9a7c379 commit 8f61e8c
Show file tree
Hide file tree
Showing 2 changed files with 427 additions and 4 deletions.
190 changes: 186 additions & 4 deletions chap04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,194 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 5 4 3 2 \n",
"x x x x \n",
"── + ── + ── + ── + x\n",
"5 4 3 2 \n"
]
}
],
"source": [
"from sympy import Symbol, summation, pprint\n",
"\n",
"x = Symbol('x')\n",
"n = Symbol('n')\n",
"s = summation(x ** n / n, (n, 1, 5))\n",
"pprint(s)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"137/60"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# subsで代入っぽい\n",
"s.subs({x:1})"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"summation(x ** n / n, (n,1,1)).subs({x:1})"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3/2"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"summation(x ** n / n, (n,1,2)).subs({x:1})"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3⋅a + 3⋅d\n"
]
}
],
"source": [
"a = Symbol('a')\n",
"n = Symbol('n')\n",
"d = Symbol('d')\n",
"s = summation(a + (n-1)*d, (n, 1, 3))\n",
"pprint(s)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 不等式"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"[(-oo, -2), (2, oo)]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sympy import Poly, Symbol, solve_poly_inequality\n",
"x = Symbol('x')\n",
"ineq_obj = - x ** 2 + 4 < 0\n",
"lhs = ineq_obj.lhs\n",
"p = Poly(lhs, x)\n",
"rel = ineq_obj.rel_op\n",
"solve_poly_inequality(p, rel)\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"(-oo, -2) U (1, oo)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sympy import Poly, Symbol, solve_rational_inequalities\n",
"\n",
"x = Symbol('x')\n",
"ineq_obj = ((x - 1) / (x + 2)) > 0\n",
"lhs = ineq_obj.lhs\n",
"numer, denom = lhs.as_numer_denom()\n",
"p1 = Poly(numer)\n",
"p2 = Poly(denom)\n",
"rel = ineq_obj.rel_op\n",
"\n",
"solve_rational_inequalities([[((p1,p2), rel)]])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"課題はパス・・・"
]
},
{
"cell_type": "code",
Expand Down
Loading

0 comments on commit 8f61e8c

Please sign in to comment.