sympy

Convert from sympy.core.add.Add to numpy complex number

大城市里の小女人 提交于 2020-12-06 07:23:10
问题 I have this list of solutions from Sympy solver: In [49]: sol Out[49]: [-1.20258344291917 - 0.e-23*I, -0.835217129314554 + 0.e-23*I, 0.497800572233726 - 0.e-21*I] In [50]: type(sol) Out[50]: list In [51]: type(sol[0]) Out[51]: sympy.core.add.Add How can I convert this list to a numpy object with cells which are normal complex value? 回答1: You can call the builtin function complex on each element, and then pass the result to np.array() . For example, In [22]: z Out[22]: [1 + 3.5*I, 2 + 3*I, 4 -

Is it possible to implement Newton's Dot Notation (or Lagrange's Prime Notation) in sympy?

浪子不回头ぞ 提交于 2020-12-05 08:27:04
问题 Leibniz's notation can just be a bit cluttering, especially in physics problems where time is the only variable that functions are being differentiated with respect to. Additionally, is it possible to not display the (t) for a function like x(t) with sympy still understanding that x is a function of t and treating it as such? 回答1: You can use the mechanics module, which was designed around Newtonian physics. In particular, dynamicssymbols will give you a symbol which implicitly depends on t .

Is it possible to implement Newton's Dot Notation (or Lagrange's Prime Notation) in sympy?

烈酒焚心 提交于 2020-12-05 08:26:49
问题 Leibniz's notation can just be a bit cluttering, especially in physics problems where time is the only variable that functions are being differentiated with respect to. Additionally, is it possible to not display the (t) for a function like x(t) with sympy still understanding that x is a function of t and treating it as such? 回答1: You can use the mechanics module, which was designed around Newtonian physics. In particular, dynamicssymbols will give you a symbol which implicitly depends on t .

BUAA-OO-2019 第一单元总结

戏子无情 提交于 2020-11-16 04:58:34
第一次作业 第一次作业需要完成的任务为简单多项式导函数的求解。 思路 因为仅仅是简单多项式的求导,所以求导本身没有什么可说的,直接套用幂函数的求导公式就行了,主要的精力是花在了正则表达式上。这里推荐两个网站: <a href="https://github.com/ziishaned/learn-regex" target="_blank"> https://github.com/ziishaned/learn-regex </a> <a href="https://regex101.com" target="_blank"> https://regex101.com </a> 前者可以用来学习正则表达式的语法,后者则提供实时的正则表达式匹配,方便进行调试和验证。尤其是后者,能大幅提高编写正则表达式的效率和正确性,省去了每次都得在IDEA里运行一遍的麻烦。 用正则时有一点需要注意,那就是大正则是不可取的。我一开始就是企图用一大串正则匹配整个输入,结果当时是爆栈了。合理的做法应当是每次只find()一个Term,以及通过Term与Term之间的连接关系判断合法性。 在数据结构方面,我一开始用的是ArrayList,但在后来优化的时候发现合并非常麻烦,于是果断放弃,学习并采用了HashMap。通过将指数作为Key,可以快速地找到指数相同的项,以实现合并同类项的目的。 程序结构分析