{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:45:55.592236", "start_time": "2017-10-25T13:45:55.028889" }, "collapsed": true }, "outputs": [], "source": [ "import sympy as sy" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:48:35.947972", "start_time": "2017-10-25T13:48:35.944558" }, "collapsed": false }, "outputs": [], "source": [ "x=sy.Symbol('x')\n", "y=sy.Symbol('y')\n", "\n", "x, y, z = sy.symbols('x y z') # 符号对象, 可限定 real = True , positive = True, complex = True , integer = True ..." ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:00:16.754202", "start_time": "2017-10-25T14:00:16.751464" }, "collapsed": false }, "outputs": [], "source": [ "f = sy.Function(\"f\")" ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:16:09.884552", "start_time": "2017-10-25T14:16:09.881899" }, "collapsed": false }, "outputs": [], "source": [ "f, g = sy.symbols('f g', cls=sy.Function)" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:48:25.420147", "start_time": "2017-10-25T13:48:25.417418" } }, "source": [ "# 表达式变换\n", "\n", "- sy.exp(sy.I*x).expand(complex=True) # 展开为复数, 可理解为将x当作复数处理 表达式展开 \n", "- sy.cos(x).series(x, 0, 10) # .series(var, point, order) 泰勒级数展开 \n", "- sy.simplify(expr) # 对数学表达式进行化简 化简\n", "- sy.radsimp(expr) # 对表达式的分母进行有理化 分母进行有理化\n", " 它所得到的表达式的分母部分将不含无理数。即将表达式转换为分子除分母的形式。\n", "- sy.ratsimp(expr) # 对表达式的分母进行通分运算 通分运算 \n", "- sy.cancel(expr) # 对表达式的分子分母进行约分运算 约分运算\n", " 只能对纯符号的分式表达式进行约分\n", " 不能对函数内部的表达式进行约分,不能对带函数的表达式进行约分\n", "- sy.trim(expr) # 对表达式的分子分母进行约分运算 约分运算 \n", " 可以对表达式中的任意部分进行约分,并且支持函数表达式的约分运算。\n", "- sy.apart(expr) # 对表达式进行部分分式分解 部分分式分解\n", "- sy.factor(expr) # 对表达式进行因式分解 因式分解\n", "- sy.together(1/x+1/y) # 代数式的合并 代数式的合并\n", "- sy.trigsimp(expr) # 对表达式中的三角函数进行化简 三角函数化简 \n", " 有两个可选参数——deep和recursive,默认值都为False。\n", " 当deep参数为True时,将对表达式中所有子表达式进行化简运算\n", " 当recursive参数为True时,将递归使用trigsimp()进行最大限度的化简\n", "- sy.expand_trig(expr) # 展开三角函数 三角函数展开 " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 积分" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:46:37.227443", "start_time": "2017-10-25T13:46:37.202667" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "x**6" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.integrate(6*x**5, x) " ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:46:55.153882", "start_time": "2017-10-25T13:46:55.145115" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2500" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.integrate(x**3, (x, 0, 10)) #定积分" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:47:03.642073", "start_time": "2017-10-25T13:47:03.625472" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "x**6*y + x*y**2/2" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.integrate(6*x**5+y, x,y) #双重不定积分" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:47:13.195048", "start_time": "2017-10-25T13:47:13.184671" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "8" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.integrate(x**3+y, (x, -1, 1),(y,1,3) ) #双重定积分" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 微分" ] }, { "cell_type": "code", "execution_count": 55, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:17:23.513604", "start_time": "2017-10-25T14:17:23.510116" }, "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Derivative(f(x), x)\n" ] } ], "source": [ "print f(x).diff(x)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:51:04.744288", "start_time": "2017-10-25T13:51:04.739274" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "cos(x)" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.diff(sy.sin(x), x) # 解析微分" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:51:19.030395", "start_time": "2017-10-25T13:51:19.021344" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "-4*sin(2*x)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.diff(sy.sin(2*x), x, 2) # 高阶微分 diff(func, var, n)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:51:53.444462", "start_time": "2017-10-25T13:51:53.418259" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "x*(x**2*y**2*cos(x*y) + 6*x*y*sin(x*y) - 6*cos(x*y))" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.diff(sy.sin(x*y),x,2,y,3) # 对表达式进行x的2阶求导,对y进行3阶求导" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:52:03.023314", "start_time": "2017-10-25T13:52:03.018842" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2*cos(2*x)" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.diff(sy.sin(2*x),x)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:52:16.120448", "start_time": "2017-10-25T13:52:16.115922" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2*cos(2*x)" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.sin(2*x).diff(x,1)\n" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:52:37.507763", "start_time": "2017-10-25T13:52:37.504503" }, "collapsed": false }, "outputs": [], "source": [ "t=sy.Derivative(sy.sin(x),x) \n", "# Derivative是表示导函数的类,它的第一个参数是需要进行求导的数学函数,第二个参数是求导的自变量,\n", "# 注意:Derivative所得到的是一个导函数,它不会进行求导运算。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 极限" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:53:01.658125", "start_time": "2017-10-25T13:53:01.584689" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.limit(sy.sin(x)/x, x, 0) # 极限" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 求和" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:53:48.524201", "start_time": "2017-10-25T13:53:48.486937" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "y**2" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.summation(2*x - 1, (x, 1, y)) # 连加求和" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 替换" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:54:22.015575", "start_time": "2017-10-25T13:54:22.003114" } }, "source": [ "expression.subs(x, y) # 将算式中的x替换成y 替换\n" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:54:43.157915", "start_time": "2017-10-25T13:54:43.152946" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "pi*y + 1" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(1 + x*y).subs(x, sy.pi) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "expression.subs({x:y,u:v}) 使用字典进行多次替换 \n", "\n", "expression.subs([(x,y),(u,v)]) 使用列表进行多次替换 " ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:55:14.735400", "start_time": "2017-10-25T13:55:14.729637" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "1 + 2*pi" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(1 + x*y).subs([(x, sy.pi), (y, 2)])\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 方程\n", "\n", "方程构建: 任何表达式都可以直接表示值为0的方程,即表达式 expr 也是方程 expr=0\n" ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T13:58:59.391335", "start_time": "2017-10-25T13:58:59.377274" }, "collapsed": false }, "outputs": [], "source": [ "# 用sy.Eq构建方程\n", "u_max, rho_max, A, B = sy.symbols('u_max rho_max A B') # 符号对象, 可限定 real = True , positive = True, complex = True , integer = True ...\n", "eq1 = sy.Eq( 0, u_max*rho_max*(1 - A*rho_max-B*rho_max**2) ) # 一般方程" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:16:20.655852", "start_time": "2017-10-25T14:16:20.650434" }, "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Eq(f(x)**2 + f(x) + Derivative(f(x), x), 0)\n" ] } ], "source": [ "eq1 = sy.Eq(f(x).diff(x)+f(x)+f(x)**2,0) # 微分方程\n", "print eq1" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:00:29.649982", "start_time": "2017-10-25T14:00:29.646593" } }, "source": [ "sy.solve(方程,未知数) # 方程求解 ,返回值为list 方程求解\n", "\n", " 它的第一个参数是表示方程的表达式,其后的参数是表示方程中未知量的符号。\n" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:16:30.278154", "start_time": "2017-10-25T14:16:30.144042" }, "collapsed": false }, "outputs": [ { "ename": "NotImplementedError", "evalue": "\nNo algorithms are implemented to solve equation _Dummy_172 + f(x)**2 + f(x)", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mNotImplementedError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msolve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0meq1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m/Users/chengjun/anaconda/lib/python2.7/site-packages/sympy/solvers/solvers.pyc\u001b[0m in \u001b[0;36msolve\u001b[0;34m(f, *symbols, **flags)\u001b[0m\n\u001b[1;32m 1051\u001b[0m \u001b[0;31m###########################################################################\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1052\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mbare_f\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1053\u001b[0;31m \u001b[0msolution\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_solve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0msymbols\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mflags\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1054\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1055\u001b[0m \u001b[0msolution\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_solve_system\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msymbols\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mflags\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/Users/chengjun/anaconda/lib/python2.7/site-packages/sympy/solvers/solvers.pyc\u001b[0m in \u001b[0;36m_solve\u001b[0;34m(f, *symbols, **flags)\u001b[0m\n\u001b[1;32m 1617\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1618\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mFalse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1619\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mNotImplementedError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'\\n'\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnot_impl_msg\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1620\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1621\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mflags\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'simplify'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mNotImplementedError\u001b[0m: \nNo algorithms are implemented to solve equation _Dummy_172 + f(x)**2 + f(x)" ] } ], "source": [ "sy.solve(eq1,x)" ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:13:30.862972", "start_time": "2017-10-25T14:13:30.845496" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "ConditionSet(x, Eq(x + sin(x), 0), Complexes((-oo, oo) x (-oo, oo), False))" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.solveset(sy.sin(x)+x,x) # 即对 sy.sin(x)+x=0 求解" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "sy.roots(expr) # 计算单变量方程expr=0的根 方程求解" ] }, { "cell_type": "code", "execution_count": 56, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:18:07.319953", "start_time": "2017-10-25T14:18:06.709571" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "Eq(f(x), -C1/(C1 - exp(x)))" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.dsolve(eq1,f(x)) # 微分方程求解 微分方程求解" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "可以对微分方程进行符号求解,它的第一个参数是一个带未知函数的表达式,第二个参数是需要进行求解的未知函数。\n", "\n", "它在解微分方程中可以传递hint参数,指定微分方程的解法,若设置为“best”则放dsolve()尝试所有的方法并返回最简单的解。" ] }, { "cell_type": "code", "execution_count": 57, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:19:17.259701", "start_time": "2017-10-25T14:19:17.256983" }, "collapsed": true }, "outputs": [], "source": [ "from sympy.utilities.lambdify import lambdify" ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:19:47.136254", "start_time": "2017-10-25T14:19:46.949978" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ ">" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ " lambdify([x],f(x),modules=\"numpy\") # 第一个参数为自变量列表" ] }, { "cell_type": "code", "execution_count": 59, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:20:08.439390", "start_time": "2017-10-25T14:20:08.434866" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "3.1415926535897932385" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.N(sy.pi,20)" ] }, { "cell_type": "code", "execution_count": 60, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:20:18.335649", "start_time": "2017-10-25T14:20:18.331422" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "3.1415926535897932384626433832795028841971693993751" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.pi.evalf(n=50)" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:21:07.071614", "start_time": "2017-10-25T14:21:07.069201" }, "collapsed": true }, "outputs": [], "source": [ "i=sy.Symbol('i')" ] }, { "cell_type": "code", "execution_count": 64, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:21:11.609961", "start_time": "2017-10-25T14:21:11.604452" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "Sum(cos(pi*i)*x[i], (i, 1, 10))" ] }, "execution_count": 64, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f = sy.Sum(sy.Indexed('x',i)*sy.cos(i*sy.pi),(i,1,10)) \n", "f" ] }, { "cell_type": "code", "execution_count": 67, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:21:38.297145", "start_time": "2017-10-25T14:21:38.291485" }, "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " at 0x108494b90>\n" ] } ], "source": [ "func = lambdify(x, f, 'numpy') # returns a numpy-ready function\n", "print func" ] }, { "cell_type": "code", "execution_count": 68, "metadata": { "ExecuteTime": { "end_time": "2017-10-25T14:21:52.955199", "start_time": "2017-10-25T14:21:52.881170" }, "collapsed": false }, "outputs": [ { "ename": "TypeError", "evalue": "'Symbol' object does not support indexing", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnumpy_array_of_results\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mnumpy_array_of_results\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/Users/chengjun/anaconda/lib/python2.7/site-packages/numpy/__init__.pyc\u001b[0m in \u001b[0;36m\u001b[0;34m(_Dummy_204)\u001b[0m\n", "\u001b[0;32m/Users/chengjun/anaconda/lib/python2.7/site-packages/numpy/__init__.pyc\u001b[0m in \u001b[0;36m\u001b[0;34m((i,))\u001b[0m\n", "\u001b[0;31mTypeError\u001b[0m: 'Symbol' object does not support indexing" ] } ], "source": [ "numpy_array_of_results = func(y)\n", "numpy_array_of_results " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.12" }, "latex_envs": { "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 0 }, "toc": { "toc_cell": false, "toc_number_sections": true, "toc_threshold": 6, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 0 }