# Return to Answer

3 fixed i --> I
Conj[a+ib]Conj[a + I b]


$$a-ib$$ a - i b

Conj[x_, exclu_:{}] :=
Refine[Conjugate[x], _?((Head[#] == Symbol && ! MemberQ[exclu, #]) &) ∈ Reals];
Conj[a + iI b, {b}]

Conjugate[a+ib]Conjugate[a + I b]

ComplexExpand[Conjugate[a+ib]]ComplexExpand[Conjugate[a + I b]]

ComplexExpand[Conjugate[Exp[a + iI b]]]

Refine[Conjugate[a+ib]Refine[Conjugate[a + I b], _∈_ ∈ Reals]


a  -ib i b

Refine[Conjugate[Sqrt[i*a]]Refine[Conjugate[Sqrt[I*a]], _ ∈ Reals]

Refine[Conjugate[a+ibRefine[Conjugate[a + I b, {a,b} ∈ Reals}]

Simplify[Conjugate[iSimplify[Conjugate[I(x^2 + 2 x y + y^2)], _Symbol ∈ Reals]


$$-i (x - y)^2$$-i $$($$x - y$$)^2$$

when you may really have wanted $$-i(x^2 + 2 x y + y^2)$$-I(x^2 + 2 x y + y^2).

(a + iI b) /. {iI -> -iI}

Exp[-i]I] /. {iI -> -iI}

FullForm[Exp[-i]]I]]

Conj[a+ib]


$$a-ib$$

Conj[x_, exclu_:{}] :=
Refine[Conjugate[x], _?((Head[#] == Symbol && ! MemberQ[exclu, #]) &) ∈ Reals];
Conj[a + i b, {b}]

Conjugate[a+ib]

ComplexExpand[Conjugate[a+ib]]

ComplexExpand[Conjugate[Exp[a + i b]]]

Refine[Conjugate[a+ib], _∈ Reals]


a-ib

Refine[Conjugate[Sqrt[i*a]], _ ∈ Reals]

Refine[Conjugate[a+ib, {a,b} ∈ Reals}]

Simplify[Conjugate[i(x^2 + 2 x y + y^2)], _Symbol ∈ Reals]


$$-i (x - y)^2$$

when you may really have wanted $$-i(x^2 + 2 x y + y^2)$$.

(a + i b) /. {i -> -i}

Exp[-i] /. {i -> -i}

FullForm[Exp[-i]]

Conj[a + I b]


a - i b

Conj[x_, exclu_:{}] :=
Refine[Conjugate[x], _?((Head[#] == Symbol && ! MemberQ[exclu, #]) &) ∈ Reals];
Conj[a + I b, {b}]

Conjugate[a + I b]

ComplexExpand[Conjugate[a + I b]]

ComplexExpand[Conjugate[Exp[a + I b]]]

Refine[Conjugate[a + I b], _ ∈ Reals]


a  - i b

Refine[Conjugate[Sqrt[I*a]], _ ∈ Reals]

Refine[Conjugate[a + I b, {a,b} ∈ Reals}]

Simplify[Conjugate[I(x^2 + 2 x y + y^2)], _Symbol ∈ Reals]


-i $$($$x - y$$)^2$$

when you may really have wanted -I(x^2 + 2 x y + y^2).

(a + I b) /. {I -> -I}

Exp[-I] /. {I -> -I}

FullForm[Exp[-I]]

2 added 189 characters in body

The most complete and extendable answer is to define

but this becomes quite unwieldy if you have many variables or if you make variable substitutions. (If you forget one variable in a large expression, you may not notice.) Avoiding Furthermore, if you want to encapsulate this by defining a function like Conj, you need to pass the list of variables manually or scrape them from the input expression.

Avoiding this issue by making the reality assumption for all things with the Head of Symbol gives the answer above.

The most complete answer is to define

but this becomes quite unwieldy if you have many variables or if you make variable substitutions. (If you forget one variable in a large expression, you may not notice.) Avoiding this issue by making the reality assumption for all things with the Head of Symbol gives the answer above.

The most complete and extendable answer is to define

but this becomes quite unwieldy if you have many variables or if you make variable substitutions. (If you forget one variable in a large expression, you may not notice.) Furthermore, if you want to encapsulate this by defining a function like Conj, you need to pass the list of variables manually or scrape them from the input expression.

Avoiding this issue by making the reality assumption for all things with the Head of Symbol gives the answer above.

1

The most complete answer is to define

Conj[x_] := Refine[Conjugate[x], _Symbol ∈ Reals];


Then we get

Conj[a+ib]


$$a-ib$$

as expected. It is also possible to generalize so that Conj takes a second argument telling it which variables to treat as complex, recovering similar abilities of ComplexExpand

Conj[x_, exclu_:{}] :=
Refine[Conjugate[x], _?((Head[#] == Symbol && ! MemberQ[exclu, #]) &) ∈ Reals];
Conj[a + i b, {b}]


a - i Conjugate[b]

### Issues with other methods

This question and related versions have been asked many times before: 1,2,3,4,5,6,7,8,9,10,11. Here's a round up.

The basic issue is that using Conjugate alone doesn't work because Mathematica doesn't know your variables are real:

Conjugate[a+ib]


Conjugate[a] - i Conjugate[b]

Rojo's suggestion to deploy ComplexExpand is very common advice and it works in the simplest case

ComplexExpand[Conjugate[a+ib]]


a - i b

but it has the undesirable behavior of converting some exponentials functions to trig functions.

ComplexExpand[Conjugate[Exp[a + i b]]]


$$e^a$$ Cos[b] - i $$e^a$$ Sin[b]

This becomes terrible when you have multiple exponentials.

One can use Refine and assume everything is real

Refine[Conjugate[a+ib], _∈ Reals]


a-ib

but then you can run into trouble when it starts assuming every expressions is real (not just variables):

Refine[Conjugate[Sqrt[i*a]], _ ∈ Reals]


$$\sqrt{i a}$$

Like Rojo's alternate answer, you can assume that only the symbols in your expression are real

Refine[Conjugate[a+ib, {a,b} ∈ Reals}]


Conjugate[$$\sqrt{i a}$$]

but this becomes quite unwieldy if you have many variables or if you make variable substitutions. (If you forget one variable in a large expression, you may not notice.) Avoiding this issue by making the reality assumption for all things with the Head of Symbol gives the answer above.

Also note that you can use Simplify in place of refine, but this will muck around by simplifying your expression,

Simplify[Conjugate[i(x^2 + 2 x y + y^2)], _Symbol ∈ Reals]


$$-i (x - y)^2$$

when you may really have wanted $$-i(x^2 + 2 x y + y^2)$$.

The simple hack of flipping the sign on i is too fragile to rely on. This works

(a + i b) /. {i -> -i}


a - i b

but this doesn't

Exp[-i] /. {i -> -i}


$$e^{-i}$$

because

FullForm[Exp[-i]]


Power[E,Complex[0,-1]]

Even if you try the rule {Complex[re_, im_] :> Complex[re, -im]}, there are issues with complex-valued functions like ArcSin[2].