# How to get Re & Im of a complex number in which all variables are real? [closed]

a small question, as following picture shows, even i use Assuming[], still no final result. Formally my question is: if all variabls in a expr are real, how to get Re[] or Im[]

• Did you try ComplexExpand[Re[a + b*I]] up to the documentation? Commented Apr 18, 2023 at 15:33
• @user64494 effective, thanks Commented Apr 18, 2023 at 15:39

Simplification isn't automatic. Try

c = a + I b;
Assuming[Element[a | b, Reals], Re[c] // FullSimplify]
(*    a    *)


Given:

c = a + I b;


The real part of c is:

Re[c] // ComplexExpand


Out: a

The imaginary part of c is:

Im[c] // ComplexExpand


Out: b

You have to apply a simplifying command to get the system work. Without calling some procedures the system only makes some simplifications, that are true universally and don't need time, eg x+x --> 2x and polynomial standarization in general.

By design any function non analytic in the complete complex domain with the exception of some poles are taboo. This reduces automatic simplification to rationals of multinomials, exponentials and elliptic functions.

Your case needs Simplify to make the assumptions work as intended

In[2]:= Assuming[a\[Element]Reals,Simplify[{Re[a],ReIm[a+b]}]]
Out[2]= {a,{a+Re[b],Im[b]}}


Re, Im, Abs and Arg are the basis of non-analytic functions; except for professionals, better to use it on numeric values only:

Always one should keep in mind, that the passage of an expression through such a one-way filter alters the space non-numeric variables are living in, after that.