3

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.

Thanks.

NaC
  • 117
  • 6
  • 4
    Would the 2-argument form of Chop suit your needs? – Jason B. Feb 24 '17 at 15:01
  • Are you trying to get rid of imaginary parts or am I misinterpreting? If so, you can use Re. – N.J.Evans Feb 24 '17 at 16:22
  • @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. – NaC Feb 25 '17 at 01:03
  • @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. – NaC Feb 25 '17 at 01:08

1 Answers1

1

Rationalize works for the example you give.

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

Rationalize[%]
(* x *)
mikado
  • 16,741
  • 2
  • 20
  • 54