Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to conjugate a symbolic expression, and I have explicitly stated the real terms. However, I simply can't get it to work:

  I Cos[z] Sin[y] + Sin[z] + 
   A (Cos[z] - I Sin[y] Sin[z]), {z \[Element] Reals, 
   A \[Element] Reals, y \[Element] Reals}]]

What am I doing wrong here?

share|improve this question

3 Answers 3

up vote 10 down vote accepted

Just do the ComplexExpand after the Conjugate

ComplexExpand[Conjugate[I Cos[z] Sin[y] + Sin[z] + A (Cos[z] - I Sin[y] Sin[z])]]

(* A Cos[z] + Sin[z] - I (Cos[z] Sin[y] - A Sin[y] Sin[z]) *)
share|improve this answer

One straightforward way to take the conjugate of an expression is to replace I with -I

ComplexExpand[I Cos[z] Sin[y] + Sin[z] + A (Cos[z] - I Sin[y] Sin[z])] //. I -> (-I)

A Cos[z] + Sin[z] - I (Cos[z] Sin[y] - A Sin[y] Sin[z])

As Szabolcs points out in the comments, this solution can be problematic, so beware!

share|improve this answer
Unfortunately this is not a robust solution. It's a common but subtle error to try to do this. Try 1 + I /. I -> -I. It gives 1+I. The reason is that I does not in fact appear in 1+I anywhere. 1+I is an atomic object with FullForm Complex[1,1]. Note that the problem is not simply that it doesn't contain I, but that it's atomic, so 1+I /. 1 -> -1 also has no effect. –  Szabolcs Apr 9 '14 at 22:19

The simple rule I to -I is not guaranteed to work, e.g.

Exp[3 I] /. I -> -I

and ComplexConjugate might be too slow (for lengthy expressions). Therefore, I rather define an alternative function to conjugate

AltConjugate[x_] := ReplaceAll[FullSimplify[x], Complex[a_, b_] -> Complex[a, -b]];

This functions looks for the pattern Complex[a_, b_] and replaces it by Complex[a, -b].

@celtschk - roots might be problematic, simple functions like f[x_]=Sqrt[-x^2] can be handle by simplifying the input function, i.e. adding FullSimplify in the definition of AltConjugate. Nevertheless, this will fail for functions including more general roots, such as f[x]=Sqrt[-x^2 +I b] where both x and b are reals.

Use this carefully and always test it.


share|improve this answer
An example where it doesn't work: Sqrt[-x^2]. ComplexExpand[Conjugate[Sqrt[-x^2]]] gives -I Sqrt[x^2], but ComplexExpand[AltConjugate[Sqrt[-x^2]]]` gives I Sqrt[x^2] –  celtschk Apr 13 '14 at 12:09
Thanks @celtschk - Square roots are problematic, simplifying the initial expression solves a few simple cases, such the one you just describe. But, it fails for a more general function. –  fabio.hipolito Apr 14 '14 at 3:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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