如何在sympy中创建符号变量的向量?我想做像
这样的事情x, x1, x2, x3 = symbols ('x x1 x2 x3')
A = [x+x1,x+x2,x+x3]
B = A * Transpose(A)
print (B)
A
是符号变量数组。
我查看了同情documentation,但无法弄清楚。
(Python 2.7.6,sympy 0.7.4.1)
更新
我想做点什么
x, x1, x2, x3 = symbols ('x x1 x2 x3')
v1e = x+x1
v2e = x+x2
v3e = x+x3
v1 = v1e.subs(x1,1)
v2 = v2e.subs(x2,2)
v3 = v3e.subs(x3,3)
A = Matrix ([v1,v2,v3])
B = A * Transpose(A)
print (B)
但似乎v1,..
作为矩阵元素存在问题。有什么建议吗?
答案 0 :(得分:3)
向量可以表示为Matrix
es in sympy作为列向量或行向量。
from sympy import symbols, Matrix, Transpose
x, x1, x2, x3 = symbols('x x1 x2 x3')
A = Matrix([[x+x1, x+x2, x+x3]])
B = A * Transpose(A)
# or B = A * A.T
print (B)