2
$\begingroup$

I have the following problem. There is such an expression as:

P[x_,y_] := z[y] E^(I beta x) + Conjugate[z[y] E^(I beta x)];

The variables x, y, beta are real but the function z[y] is complex. I need to expand P[x, y]^2. So I try this:

ComplexExpand[P[x, y]^2, z[y]]

The output contains Re[z[y]], Im[z[y]], Cos[...] and Sin[...]. In my case, I need the output to be like this:

z[y]^2 E(2 I beta x) + 2 z[y] Conjugate[z[y]] + Conjugate[z[y]]^2 E^(-2 I beta x)

What should I change in my approach? I have already tried TrigToExpand, FullSimplify and Hold but I did not get the desirable result.

$\endgroup$
2
  • $\begingroup$ You can get rid of the Re and Im by using the option TargetFunctions->{Conjugate}. But that still gives Sin and Cos for the exponential functions. $\endgroup$
    – celtschk
    Oct 6, 2014 at 11:54
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Oct 6, 2014 at 12:10

1 Answer 1

3
$\begingroup$

The following gives what you intended:

Refine[Expand[P[x, y]^2], (x|y|beta) \[Element] Reals]
(*
==> Conjugate[z[y]]^2/E^((2*I)*beta*x) + 2*Conjugate[z[y]]*z[y] + 
     E^((2*I)*beta*x)*z[y]^2
*)

In cases where you can live with expansion of complex exponentials into Sin and Cos you can also use

ComplexExpand[P[x, y]^2, z[y], TargetFunctions->{Conjugate}]
(*
==> Conjugate[z[y]]^2*Cos[beta*x]^2 - (2*I)*Conjugate[z[y]]^2*Cos[beta*x]*
      Sin[beta*x] - Conjugate[z[y]]^2*Sin[beta*x]^2 + 
     2*Conjugate[z[y]]*Cos[beta*x]^2*z[y] + 2*Conjugate[z[y]]*Sin[beta*x]^2*
      z[y] + Cos[beta*x]^2*z[y]^2 + (2*I)*Cos[beta*x]*Sin[beta*x]*z[y]^2 - 
     Sin[beta*x]^2*z[y]^2
*)
$\endgroup$
3
  • $\begingroup$ Nice one. I think the question title is misleading b/c the problem isn't about ComplexExpand[] but about expressing a Complex expression in terms of certain things. Can you find a better title? I'm not sure about the better option. $\endgroup$ Oct 6, 2014 at 12:03
  • $\begingroup$ @celtschk Thank you a lot! $\endgroup$
    – Vladimir
    Oct 6, 2014 at 12:06
  • $\begingroup$ @belisarius I agree with you that the title does not express the very problem. I will rename it. $\endgroup$
    – Vladimir
    Oct 6, 2014 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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