This question already has an answer here:

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?


marked as duplicate by Kuba Jan 19 '18 at 6:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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]) *)

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!

  • 1
    $\begingroup$ 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. $\endgroup$ – 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.


  • $\begingroup$ 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] $\endgroup$ – celtschk Apr 13 '14 at 12:09
  • $\begingroup$ 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. $\endgroup$ – fabio.hipolito Apr 14 '14 at 3:12

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