sympy

(Some function) is not defined with SymPy Lambdify

◇◆丶佛笑我妖孽 提交于 2020-05-11 17:54:07
问题 So I'm writing a script that evaluates Taylor Series. However, I want it to evaluate for all types of functions. So I tried, for example, using the function acot(x) . x = sy.Symbol('x') f = acot(x) ... func = taylor(f,0,3) taylor_lambda = sy.lambdify(x, func, 'numpy') The above runs without an exception (except if I use acsch , for example, and it does not run). But then when it reaches this line: plt.plot(x1,taylor_lambda(x1),label='taylor approximation') I get: NameError: name 'acot' is not

(Some function) is not defined with SymPy Lambdify

独自空忆成欢 提交于 2020-05-11 17:52:06
问题 So I'm writing a script that evaluates Taylor Series. However, I want it to evaluate for all types of functions. So I tried, for example, using the function acot(x) . x = sy.Symbol('x') f = acot(x) ... func = taylor(f,0,3) taylor_lambda = sy.lambdify(x, func, 'numpy') The above runs without an exception (except if I use acsch , for example, and it does not run). But then when it reaches this line: plt.plot(x1,taylor_lambda(x1),label='taylor approximation') I get: NameError: name 'acot' is not

mpmath and sympy error while packing apk with buildozer

五迷三道 提交于 2020-05-07 09:31:28
问题 I am trying to build a apk but it keeps telling me that i need mpmath=>0.19. the problem is coming from sympy because when i built the apk without it everything worked as expected. I don't know why it need mpmath even when I include mpmath in the requirement I keep getting the same error. I need help please. buildozer.spec Command: buildozer android debug deploy run. Spec file: https://pastebin.com/71maKs5n Full Logs `https://pastebin.com/EvALr3fW` 回答1: This is a dependency ordering issue,

mpmath and sympy error while packing apk with buildozer

两盒软妹~` 提交于 2020-05-07 09:30:44
问题 I am trying to build a apk but it keeps telling me that i need mpmath=>0.19. the problem is coming from sympy because when i built the apk without it everything worked as expected. I don't know why it need mpmath even when I include mpmath in the requirement I keep getting the same error. I need help please. buildozer.spec Command: buildozer android debug deploy run. Spec file: https://pastebin.com/71maKs5n Full Logs `https://pastebin.com/EvALr3fW` 回答1: This is a dependency ordering issue,

Python 实现线性代数计算器

我的梦境 提交于 2020-04-26 13:35:57
计算逆序数,运用O(N^2)的算法计算 # 逆序数计算 def reversePairs(nums): """ 计算数组的逆序数,输入数组,返回逆序数 """ res, n= 0, len(nums) for i in range(1,n): for j in range(0,i): if nums[j]>nums[i]: res +=1 return res nums = [4,6,1,5,2,3] res = reversePairs(nums) print(res) 任意数字行列式的计算 # 数字行列式计算 def determinant(matrix): """ 计算numpy矩阵的行列式,输入numpy矩阵,返回行列式的值 """ return np.linalg.det(matrix) A = np.array([(3,-1,0,7),(1,0,1,5),(2,3,-3,1),(0,0,1,-2)],dtype=np.int32) res = determinant(A) print(res) 字母行列式,使用sympy符号计算功能 # 符号行列式的计算 a = sym.symbols('a') b = sym.symbols('b') c = sym.symbols('c') d = sym.symbols('d') A = sym.Matrix( [[a,1,0,0

pip 国内源安装科学计算包

旧巷老猫 提交于 2020-04-20 14:07:19
python -m pip install --upgrade pip pip install --user numpy scipy matplotlib jupyter pandas sympy nose pip install matplotlib -i http://pypi.douban.com/simple --trusted-host pypi.douban.com pip install numpy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com pip install pandas -i http://pypi.douban.com/simple --trusted-host pypi.douban.com pip install seaborn scipy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com 来源: oschina 链接: https://my.oschina.net/readerror/blog/3276031

BUAA OO Unit2 电梯调度

戏子无情 提交于 2020-04-19 11:43:35
这次作业完成了一个开环可选层电梯调度系统。第二次迭代加入了容量限制、多部电梯,第三次迭代加入了电梯楼层分工、增添电梯请求。 1. 系统架构 graph LR MainClass--Requests-->Schedule Executor--Notify-->Schedule Schedule--Update-->Executor MainClass--Create-->Elevators Schedule--Check-->Elevators Executor--Operate-->Elevators Schedule--Adapt-->Method MainClass用于对各个子系统的组装,发送请求至Schedule Schedule用于接收来自MainClass、Executor的信息,更新状态 Executor监听Schedule的改变,使用单线程操纵所有电梯,同时将操作结果返回Schedule。 Method为策略模块,实现同步控制与策略模块的分离,可以用于适配不同的策略。 2. 同步控制 定时控制 同步控制的主要由Schedule设定,由Executor执行。并发控制的核心为一个阻塞定时监听器,可实现可调整的定时控制。这个模块的实现方法参考了 java.utils.Timer 。 private long scheduledTime = Long.MAX_VALUE;

Is there a way to handle constant function parameters in SymPy?

一个人想着一个人 提交于 2020-04-14 07:34:42
问题 I am generating symbolic functions and using SymPy to simplify them. Now I would like a way to "simplify" symbols that represent constant parameters in a function that is yet to be fitted. For example, if I am generating a polynomial, I might generate a string like this C*x*x + C*x + C*x + C, which SymPy would turn into C*x^2 + 2*C*x + C. Now I would like to find a way to get this: C*x^2 + C*x + C. In other words, is there a way to tell SymPy that a certain symbol is constant and undefined,

How makes all low values in the symbolic calculation become zero?

余生长醉 提交于 2020-04-07 07:08:32
问题 How can I make all low values in a SymPy expression zero? For example, my result is: 1.0*a1*cos(q1) - 6.12e-17*(a2*sin(q2) + a3*sin(q2 + q3) + a4*sin(q2 + q3 + q4))*sin(q1) + 1.0*(a2*cos(q2) + a3*cos(q2 + q3) + a4*cos(q2 + q3 + q4))*cos(q1) and I want to change second term (starting with 6.12e-17 ) to zero. 回答1: A direct way to do this is to replace such numbers with 0. A naive eq.subs(small, 0) will fail because small that you enter is not likely to be exactly the same as the number. But eq

How makes all low values in the symbolic calculation become zero?

一个人想着一个人 提交于 2020-04-07 07:08:20
问题 How can I make all low values in a SymPy expression zero? For example, my result is: 1.0*a1*cos(q1) - 6.12e-17*(a2*sin(q2) + a3*sin(q2 + q3) + a4*sin(q2 + q3 + q4))*sin(q1) + 1.0*(a2*cos(q2) + a3*cos(q2 + q3) + a4*cos(q2 + q3 + q4))*cos(q1) and I want to change second term (starting with 6.12e-17 ) to zero. 回答1: A direct way to do this is to replace such numbers with 0. A naive eq.subs(small, 0) will fail because small that you enter is not likely to be exactly the same as the number. But eq