1
$\begingroup$

What is the best way to rationalize complex numbers, if not both the real and imaginary part are actually rational?

According to the documentation, Rationalize works on complex numbers, but apparently only when both the real and the imaginary part can be rationalized, for example

Rationalize[N[4/3 + I 2/3]]
(*4/3 + I 2/3*)

However, Rationalize[N[4/3 + I Sqrt[2]/3]] is not simplified, whereas I would like it to return 4/3 + I 0.471405.

Thanks.

$\endgroup$
  • 2
    $\begingroup$ Seeing as 4/3 + I N[ Sqrt[2]/3] is immediately and automatically converted to 1.33333 + 0.471405 I, I don't see how it can be done. $\endgroup$ – m_goldberg Oct 18 '14 at 23:00
  • 1
    $\begingroup$ Thanks for this observation. I suppose, using HoldForm will do for me. $\endgroup$ – Eckhard Oct 18 '14 at 23:20
3
$\begingroup$

It's not the exact output you requested but in case you are not aware of the second parameter of Rationalize:

Rationalize[N[4/3 + I Sqrt[2]/3], 1*^-6]
4/3 + (272 I)/577

If your hybrid output really is desired then perhaps building on m_goldberg's deleted answer:

# + Defer[#2 I] & @@ Rationalize /@ {Re@#, Im@#} & @ N[4/3 + I Sqrt[2]/3]
4/3 + 0.471405 I
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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