# ComplexExpand does not fully expand

Consider

ComplexExpand[Abs[a+Conjugate[b+c]]^2,{a,b,c},TargetFunctions->Conjugate]

(* a b + a c + a Conjugate[a] + b Conjugate[b + c] + c Conjugate[b + c] +
Conjugate[a] Conjugate[b + c] *)


why Conjugate[b + c] is not expanded as Conjugate[b] + Conjugate[c]?

Applying two times ComplexExpand gives the desidered answer:

ComplexExpand[ComplexExpand[Abs[a+Conjugate[b+c]]^2,{a,b,c},TargetFunctions->Conjugate],{a,b,c},TargetFunctions->Conjugate]
(* a b+a c+a Conjugate[a]+b Conjugate[b]+c Conjugate[b]+Conjugate[a] Conjugate[b]+b Conjugate[c]+c Conjugate[c]+Conjugate[a] Conjugate[c] *)


If applied 2 times, ComplexExpand gives a different answer also if a, b and c are reals

ComplexExpand[Abs[a+Conjugate[b+c]]^2,TargetFunctions->Conjugate]
ComplexExpand[%,TargetFunctions->Conjugate]
(* a^2 + a b + a c + a Conjugate[b + c] + b Conjugate[b + c] +
c Conjugate[b + c] *)
(* a^2 + 2 a b + b^2 + 2 a c + 2 b c + c^2 *)


Is there a reason why ComplexExpand doesn't "fully" expand?

• Why don't you simply use ComplexExpand[Abs[a + Conjugate[b + c]]^2]? TargetFunctions probably targets only occurences in the input expression. – Henrik Schumacher May 29 '18 at 11:03
• Because I need an expansion with Conjugate. I need it because I use the expansion as the input of D. – Giancarlo May 29 '18 at 11:15
• So the Idea is this: let's say I want to calculate the derivative of Abs[a]^2 respect toa, where a is complex. Since Abs[a]^2==a Conjugate[a], I want the result to be Conjugate[a]. To get this result, I need the TargetFunction->Conjugate. After expanding Abs[a]^2==a Conjugate[a] I substitute a Conjugate[a]->a aConj and take D[a aConj,a] – Giancarlo May 29 '18 at 11:32
• Abs[a]^2 is not complex differentiable. – Henrik Schumacher May 29 '18 at 11:36
• It is holomorphic nowhere. – Henrik Schumacher May 29 '18 at 11:54

Name notwithstanding, full "expansion" is not part of the charter of ComplexExpand. Rather it has the task of rewriting into an (almost everywhere) equivalent expression, separating into explicitly real and imaginary parts, and using only the provided target functions.

A method that will sometimes work to get full expansion in terms of variables and their explicit conjugates is to apply ComplexExpand twice, first separating using Re and Im and then using Conjugate.

ComplexExpand[
ComplexExpand[Abs[a + Conjugate[b + c]]^2, {a, b, c},
TargetFunctions -> {Re, Im}], {a, b, c},
TargetFunctions -> Conjugate]

(* Out[49]= a b + a c + a Conjugate[a] + b Conjugate[b] +
c Conjugate[b] + Conjugate[a] Conjugate[b] + b Conjugate[c] +
c Conjugate[c] + Conjugate[a] Conjugate[c] *)