When I sum a complex number and its conjugate, that have been obtained when calculating the eigenvalues of a matrix, there is still an imaginary part that is equal to zero.
ev = {-0.8957457857324409` + 3.0607525560671736` I,
-0.8957457857324409` - 3.0607525560671736` I};
ev[[1]] + ev[[2]]
(* Out: -1.79149 + 0. I *)
How I eliminate the imaginary part if it is zero, to have a pure real number?
Using something like Re[-1.79149 + 0. I] is not sufficient as the summation of the eigenvalues that are calculated sometime have an imaginary part.
Chopon the result? – MarcoB May 03 '18 at 15:28Chopbecause it might unpack arrays (it may change the type fromComplextoRealor toInteger. I would advice something likeThreshold[#, 100 $MachineEpsilon] &instead. – Henrik Schumacher May 03 '18 at 15:32