(* 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:

(* 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

(* 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?

  • $\begingroup$ Why don't you simply use ComplexExpand[Abs[a + Conjugate[b + c]]^2]? TargetFunctions probably targets only occurences in the input expression. $\endgroup$ – Henrik Schumacher May 29 '18 at 11:03
  • $\begingroup$ Because I need an expansion with Conjugate. I need it because I use the expansion as the input of D. $\endgroup$ – Giancarlo May 29 '18 at 11:15
  • $\begingroup$ 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] $\endgroup$ – Giancarlo May 29 '18 at 11:32
  • $\begingroup$ Abs[a]^2 is not complex differentiable. $\endgroup$ – Henrik Schumacher May 29 '18 at 11:36
  • 1
    $\begingroup$ It is holomorphic nowhere. $\endgroup$ – 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[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] *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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