Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

comparing sets of roots of charpoly

I am missing something about how to compare list of roots. During a small algorithm I need to know wether a matrix has or not complex eigenvalues. I did the following

   A=matrix(QQ,[[1,2,1],[6,-1,0],[-1,-2,-1]])
   a=(B.charpoly()).roots(ring= QQ, multiplicities=False)
   b=(B.charpoly()).roots(ring= QQbar, multiplicities=False)

then a is the list [-4,0,3] and b is the list [3,0,-4]. I don't get the following :

set(a)==set(b)

return false while

set([-4,0,3])==set([3,0,-4])

return true.

Any help, either on the first pb (knowing that a QQ matrix has complex eigenvalues) or on the second would be greatly appreciated. Cheers.

comparing sets of roots of charpoly

I am missing something about how to compare list of roots. During a small algorithm I need to know wether a matrix has or not complex eigenvalues. I did the following

   A=matrix(QQ,[[1,2,1],[6,-1,0],[-1,-2,-1]])
   a=(B.charpoly()).roots(ring= QQ, multiplicities=False)
   b=(B.charpoly()).roots(ring= QQbar, multiplicities=False)

then a is the list [-4,0,3] and b is the list [3,0,-4]. I don't get the following :

set(a)==set(b)

return false while

set([-4,0,3])==set([3,0,-4])

return true.

Any help, either on the first pb (knowing that a QQ matrix has complex eigenvalues) or on the second would be greatly appreciated. Cheers.