简体   繁体   English

用数学方程式(python)解决sympy问题

[英]trouble with sympy solve with mathematical equation (python)

I have 8 lists of variables (each identical size). 我有8个变量列表(每个大小相同)。 For each element of the list I wish to create a new list that is the result of a mathematical solution involving the variables. 我希望为列表中的每个元素创建一个新列表,该列表是包含变量的数学解决方案的结果。

Here is my code using Sympy: 这是我使用Sympy的代码:

from sympy.solvers import solve
from sympy import Symbol
x = Symbol('x')
m = []
for a,b,c,d,e,f,g,h in zip(uAFOURIERL,IAFOURIERL,IBFOURIERL,ICFOURIERL,uAFOURIERR,IAFOURIERR,IBFOURIERR,ICFOURIERR):
    m.append(solve(a-(x*(Rl+Xl*1J)*b+x*(Rr+Xr*1J)*c+x*(Rr+Xr*1J)*d)-(e-((1-x)(Rl+Xl*1J)*f+(1-x)*(Rr+Xr*1J)*g+(1-x)*(Rr+Xr*1J)*h))*math.e**(alpha*1J)))

However, when I try to run the code, I keep getting the error: 但是,当我尝试运行代码时,我不断收到错误消息:

TypeError                                 Traceback (most recent call last)
<ipython-input-7-b428f6d803d8> in <module>()
    725 m = []
    726 for a,b,c,d,e,f,g,h in zip(uAFOURIERL,IAFOURIERL,IBFOURIERL,ICFOURIERL,uAFOURIERR,IAFOURIERR,IBFOURIERR,ICFOURIERR):
--> 727     m.append(solve(a-(x*(Rl+Xl*1J)*b+x*(Rr+Xr*1J)*c+x*(Rr+Xr*1J)*d)-(e-((1-x)(Rl+Xl*1J)*f+(1-x)*(Rr+Xr*1J)*g+(1-x)*(Rr+Xr*1J)*h))*math.e**(alpha*1J)))
    728 
    729 

TypeError: 'Add' object is not callable

How do I fix this? 我该如何解决? I've never gotten the error "'Add' object is not callable" before. 我从来没有收到错误“添加对象不可调用”的错误。

Thanks for your help. 谢谢你的帮助。

Looks to me like you're simply missing a * : 在我看来,您只是缺少一个*

for a,b,c,d,e,f,g,h in zip(uAFOURIERL,IAFOURIERL,IBFOURIERL,ICFOURIERL,uAFOURIERR,IAFOURIERR,IBFOURIERR,ICFOURIERR):
    m.append(solve(a-(x*(Rl+Xl*1J)*b+x*(Rr+Xr*1J)*c+x*(Rr+Xr*1J)*d)-
             (e-((1-x)*(Rl+Xl*1J)*f+(1-x)*(Rr+Xr*1J)*g+(1-x)*(Rr+Xr*1J)*h))*math.e**(alpha*1J)))
                      ^

and turning a multiplication of (1-x) by (Rl+Xl*1J) into a function call. 并将(1-x)(Rl+Xl*1J)的乘积转换为函数调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM