I know that sympy in python can set assumptions on variables, such as x is positive, negative, real, complex, etc. I was wondering if sympy can set assumptions on variables
The assumptions are not coming into play here. That usually only matters if you have square roots, because sqrt(x**2) = x
only if x >= 0
.
All you need to do for this is simplify the result. Matrix.eigenvects
has a simplify
flag, but it apparently doesn't simplify the results. I'll open an issue for that. In the meanwhile, you can do so manually. Note that Matrix.simplify
acts in-place (if you don't like that, you can use Matrix.applyfunc(simplify)
>>> A = M.eigenvects()
>>> A[0][2][0].simplify()
>>> A[1][2][0].simplify()
>>> pprint(A)
⎡⎛1, 1, ⎡⎡1⎤⎤⎞, ⎛-4⋅b + 1, 1, ⎡⎡-1⎤⎤⎞, ⎛-2⋅a - 2⋅b + 1, 2, ⎡⎡-1⎤, ⎡0 ⎤⎤⎞⎤
⎢⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥ ⎢ ⎥⎥⎟⎥
⎢⎜ ⎢⎢1⎥⎥⎟ ⎜ ⎢⎢-1⎥⎥⎟ ⎜ ⎢⎢1 ⎥ ⎢0 ⎥⎥⎟⎥
⎢⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥ ⎢ ⎥⎥⎟⎥
⎢⎜ ⎢⎢1⎥⎥⎟ ⎜ ⎢⎢1 ⎥⎥⎟ ⎜ ⎢⎢0 ⎥ ⎢-1⎥⎥⎟⎥
⎢⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥⎥⎟ ⎜ ⎢⎢ ⎥ ⎢ ⎥⎥⎟⎥
⎣⎝ ⎣⎣1⎦⎦⎠ ⎝ ⎣⎣1 ⎦⎦⎠ ⎝ ⎣⎣0 ⎦ ⎣1 ⎦⎦⎠⎦