2
$\begingroup$

I noticed the following strange scenario. When I defined a variable to be real, Mathematica does not only recognize that it is real after taking an inverse. How can I resolve this so that it will recognize 1/x is still real?

In[29]:= $Assumptions = {x ∈ Reals}

Out[29]= {x ∈ Reals}

In[30]:= Im[x]

Out[30]= Im[x]

In[31]:= Refine[Im[x]]

Out[31]= 0

In[32]:= Refine[Re[x]]

Out[32]= x

In[33]:= Refine[Im[1/x]]

Out[33]= Im[1/x]

In[34]:= Refine[Re[1/x]]

Out[34]= Re[1/x]
$\endgroup$
2
  • 1
    $\begingroup$ Another way to do it is use ComplexExpand without any assumptions. For example: $Assumptions = True; ReIm[ 1 / x ] // ComplexExpand $\endgroup$
    – LouisB
    Commented Jun 6, 2019 at 22:29
  • 2
    $\begingroup$ You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$
    – Michael E2
    Commented Jun 6, 2019 at 23:36

1 Answer 1

7
$\begingroup$

If x=0, then 1/0 is ComplexInfinity. If you add the assumption that x!=0, then you get what you are wanting:

 Assuming[{b \[Element] Reals, b != 0}, Refine[Im[1/b]]]
   0
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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