I have a problem understanding how Mathematica handles real values in complex numbers. E.g.

a \[Element] Reals;
b \[Element] Reals;
z = a + b I;
t = z^2 + Conjugate[z]

gives the somewhat unexpected answer

(a + I b)^2 + Conjugate[a] - I Conjugate[b]


t = z^2 + Conjugate[z] // ComplexExpand

gives the more 'correct'

a + a^2 - b^2 + I (-b + 2 a b)

I don't understand why Conjugate does not compute to a - b i in the first case.



does not give the expected

a + a^2 - b^2

but instead

-Im[-b + 2 a b] + Re[a + a^2 - b^2]

which I don't understand.

Is there someone that could kindly explain this to me, and perhaps link to some document that have 'exercises' in complex arithmetic using Mathematica that one could practise on? TIA.


1 Answer 1


a \[Element] Reals; has no effect. It evaluates a, checks to see if the result can be identified as real or not, yields True, False, or a \[Element] Reals (if it can't decide), and finally throws away the result using ;.

I suggest you look up ComplexExpand or Simplify with Assumptions.


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