Sometimes Conjugate
distributes. Sometimes it doesn't. Look:
Conjugate[a b]
(* Conjugate[a b] *)
Conjugate[2 a b]
(* 2 Conjugate[a b] *) (*'2' pulled out*)
Conjugate[a (b + c)]
(* Conjugate[a (b + c)] *)
Conjugate[a (b + 2 c)]
(* Conjugate[a] (Conjugate[b] + 2 Conjugate[c]) *) (* Distributed! *)
Conjugate[a (b + c (d + e))]
(* Conjugate[a (b + c (d + e))] *)
Why is
Conjugate
behaving like this (that is, inconsistently)?Is there a switch I can toggle that prevents
Conjugate
from doing stuff willy nilly? I don't mind ifConjugate[2 a b]
staysConjugate[2 a b]
. It's more consistent that way.
Answer
list = {a b, 2 a b, a (b + c), a (b + 2 c), a (b + c (d + e))};
If you never want Conjugate
to distribute, use Inactive
Inactive[Conjugate] /@ list
If you want Conjugate
to always distribute
conj[expr_] :=
ComplexExpand[expr, Variables@Level[expr, {-1}],
TargetFunctions -> Conjugate] // Simplify
conj@*Conjugate /@ list
(* {Conjugate[a] Conjugate[b], 2 Conjugate[a] Conjugate[b],
Conjugate[a] (Conjugate[b] + Conjugate[c]),
Conjugate[a] (Conjugate[b] + 2 Conjugate[c]),
Conjugate[a] (Conjugate[b] + Conjugate[c] (Conjugate[d] + Conjugate[e]))} *)
If any variables are Reals, say a
and c
, then use Simplify
Simplify[%, Element[{a, c}, Reals]]
(* {a Conjugate[b], 2 a Conjugate[b], a (c + Conjugate[b]),
a (2 c + Conjugate[b]), a (Conjugate[b] + c (Conjugate[d] + Conjugate[e]))} *)
Comments
Post a Comment