假设我有一个脚本,它创建了一个向量v,其中包含一定数量的元素x1,x2,x3,等等(每个元素都是一个sympy符号)。你知道吗
import sympy as sp
# generated by script, so the number of symbols/length of v is always different:
sp.var("x1,x2,x3,x4,...")
v = sp.Matrix([x1,x2,x3,x4,...])
g = sp.Function("g")
我想要g是x1,x2,x3,…,的函数,所以g(x1,x2,x3,x4,…)用来区分它。你知道吗
g.diff(x1) # does not work
g(x1,x2,x3).diff(x1) # works, but the number of variables varies
你知道我怎么解决这个问题吗?你知道吗
编辑:我应该提一下,我做了不少研究。我希望我没有错过任何明显的东西。你知道吗
使用星形表达式
相关问题 更多 >
编程相关推荐