Message Boards Message Boards

3 Replies
2 Total Likes
View groups...
Share this post:

Simplification of expression with complex variables

Posted 11 years ago
Hello!  I'm  using  Mathematica  and I stuck with very simple
examples. Thera are well known rules for complex conjugation 
x  x*= |x|^2 and x + x*=2 Re(x)

Problem 1.

It is fine to try
In[1]:= FullSimplify[x Conjugate[x]]

Out[1]= Abs[x]^2

However it doesn't work with

In[2]:= FullSimplify[x y Conjugate[x y]]

Out[2]= x y Conjugate[x] Conjugate[y] 
I'd like it should be 
Abs[x]^2 Abs[y]^2

Problem 2.

It is fine to try
In[8]:= FullSimplify[x + Conjugate[x]]

Out[8]= 2 Re[x]
In[9]:= FullSimplify[x y + Conjugate[x y]]

Out[9]= 2 Re[x y]

However it doesn't work with
In[10]:= FullSimplify[x y + Conjugate[x] Conjugate[y]]

Out[10]= x y + Conjugate[x]Conjugate[y]
I want it should be 
2 Re[x y]

Please, help me.
POSTED BY: Rodion Stepanov
3 Replies
Posted 11 years ago
Nesser, it works excellent now! Thanks a lot! Ideed FullSimplify should be not used.
POSTED BY: Rodion Stepanov
Updated 9/1/13 to answer follow up.

Added additional rules, so that no need to use FullSimplify (sometimes using FullSimplify will reverse the effect of your own rule). Here are 5 rules that covers the cases you have and the new one you added.  (if more cases are not covered, new rules can be added)

You can also also apply all the rules at once, so that you do not have to determine beforehand which one to use for different expression. Mathematia internal pattern matching will pick the rule needed to apply.

 ClearAll[x, y, z, g, foo];
 p1 = Times[Conjugate[x_] Conjugate[y_]] :> Conjugate[x y];
 p2 = Times[x_ Conjugate[x_]] :> Abs[x]^2;
 p3 = Abs[x_ y_]^n_. :> Abs[x]^n Abs[y]^n;
 p4 = Plus[x_ Conjugate[y_] , y_ Conjugate[x_] ] :> 2 (Re[x] Re[y] +  Im[x] Im[y]);
 p5 = Plus[x_ , Conjugate[x_] ] :> 2 Re[x];
 allRules = {p1, p2, p3, p4, p5};
 expr = {
   {foo = x Conjugate[y] + y Conjugate[x]; foo, foo //. allRules},
   {foo = x Conjugate[y] + y Conjugate[x] + z Conjugate[g] + g Conjugate[z]; foo, foo //. allRules},
   {foo = x Conjugate[x]; foo, foo //. allRules},
   {foo = x y Conjugate[x y]; foo, foo //. allRules},
   {foo = x y z Conjugate[x y z]; foo, foo //. allRules},
   {foo = x + Conjugate[x]; foo, foo //. allRules},
   {foo = x y + Conjugate[x y], foo; foo //. allRules},
   {foo = x y z + Conjugate[x y z]; foo, foo //. allRules},
   {foo = x y + Conjugate[x] Conjugate[y]; foo, foo //. allRules},
   {foo = x y z g + Conjugate[x] Conjugate[y]  Conjugate[z]  Conjugate[g]; foo, foo //. allRules}
Grid[expr, Frame -> All, Spacings -> {.5, 1}, Alignment -> Left]
This gives
POSTED BY: Nasser M. Abbasi
Posted 11 years ago
Thank you, Nasser. It is rather good solution but it doesn't work with
x Conjugate[y] + Conjugate[x] y
I didn't manage to solve in the same manner. Another idea? 
POSTED BY: Rodion Stepanov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract