Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I am performing a finite-precision operation on a matrix A which I know precisely; call the result B. The operation is taking the square root by B = MatrixPower[A,1/2], but it's not quite relevant. The point is that the form of A is such that the output will contain a lot of entries equal to 0, simply because A has a lot of invariant subspaces spanned by the standard base vectors.

I would like to see resulting matrix is like: in the first approximation it interests me how many non-zero entries it has and where. The problem is, the entries of B which are supposed to be 0 come out as small reals of the type $1.234...\times 10^{-10}$. I've tried applying N to B with some modest requirement on precision, but this does not seem to help. Ideally, I would like to set all entries of B which are approximately 0 to precisely 0. Any help would be appreciated.

P.S. It just occurred to me that I can take a function f that maps small numbers to 0, and is identity otherwise, and apply it to B element-wise. But there should be a more elegant solution, it seems to me.

share|improve this question

marked as duplicate by J. M. Jun 23 '13 at 14:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Take a look at Chop. –  Kuba Jun 23 '13 at 13:26
    
@Kuba: Precisely what I needed! Thanks. –  Feanor Jun 23 '13 at 13:28
    
This question has already been answered here. –  m_goldberg Jun 23 '13 at 13:38

1 Answer 1

Perhaps you will find Chop useful.

share|improve this answer
    
Chop is just what I was looking for. Thank you! –  Feanor Jun 23 '13 at 13:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.