I am trying to get rid of terms with 0., $x+0.I$ for example.

I've found this question: A dot appearing after a zero, and making the entries of a matrix into fractions and the solution is using Chop.

However, some terms that I want to keep are very small, $10^{-14}$, and also neglect with Chop too.

As I looked on the internet, I can't find the solution for this question. If it is duplicate, please let me know.


  • 4
    $\begingroup$ Would the 2-argument form of Chop suit your needs? $\endgroup$ – Jason B. Feb 24 '17 at 15:01
  • $\begingroup$ Are you trying to get rid of imaginary parts or am I misinterpreting? If so, you can use Re. $\endgroup$ – N.J.Evans Feb 24 '17 at 16:22
  • $\begingroup$ @N.J.Evans The answer is yes. However, I am stuck with the problem that Re gives me Re(...). Then, I use Refine but imaginary parts still exists, Re(n1+n2*I)x y. Finally, I use Conjugate to get rid of imaginary parts and then I get this problem. $\endgroup$ – NaC Feb 25 '17 at 1:03
  • $\begingroup$ @JasonB. I admitted that I just know that I can use 2-argument form of Chop. It's my mistake. However, @mikado's answer can solve this problem too. $\endgroup$ – NaC Feb 25 '17 at 1:08

Rationalize works for the example you give.

x + 0. I
(* (0. + 0. I) + x *)

(* x *)

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