SYMPY : How to refine a whole matrix after eigenvector calculation?

Viewed 129

I want to use sympy to calculate eigenvectors and I did some trials with jupyter notebook

from sympy import *
a,b=symbols("a b", real=True)
M  = Matrix([[a,b],[b,-a]])
[T, D] = M.diagonalize(normalize=true)

To check normalization, I calculated the vector norm : simplify(T[0,0]**2+T[1,0]**2). But the ouput is very large. It seems that a and b are not considered as real (squares of absolute values are not simplify to square). To obtain the expected value : 1, I must use

T00ref=refine(T[0,0],Q.real(a) & Q.real(b))
T10ref=refine(T[1,0],Q.real(a) & Q.real(b))
simplify(T00ref**2+T10ref**2)

Why must I refine the matrix elements ?
And moreover,

Tref=refine(T,Q.real(a) & Q.real(b))
simplify(Tref[0,0]**2+Tref[1,0]**2)

does not work. I could not refine the whole matrix.

Thanks for answer.

0 Answers
Related