# Finite precision - how to get rid of “near zeros” [duplicate]

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.

-
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

## marked as duplicate by Ｊ. Ｍ.Jun 23 '13 at 14:14

Perhaps you will find Chop useful.

-
Chop is just what I was looking for. Thank you! –  Feanor Jun 23 '13 at 13:29