How to create vector of symbolic variables in sympy? I want to do something like
x, x1, x2, x3 = symbols ('x x1 x2 x3')
A = [x+x1,x+x2,x+x3]
B = A * Transpose(A)
print (B)
A
is array of symbolic variables.
I checked with sympy documentation, but couldn't figure out.
(Python 2.7.6, sympy 0.7.4.1)
Update:
I want to do something like
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)
But seems that there is problem with v1,..
putting as matrix elements. Any suggestions?
Vectors can be represented as Matrix
es in sympy as column-vectors or row-vectors.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With