MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Algebra on complex expressions: Collect


Ross, Sean wrote:
> 
> Does anyone know a way to have a Collect -like function work on
> expressions with complex numbers?  If I have an expression with "x" in
> it, I can use Collect[expr,x], but if I have an expression with "I" in
> it, Collect[expr,I] does not separate the expression into a part with
> and without "I" which would be equivalent to separating the expression
> into real and imaginary parts given all symbols were real.
> 
> The RealOnly package does not seem to apply as it excludes imaginary
> numbers alltogether.  ComplexExpand results in a ridiculous amount of
> complexity and is worse than nothing for this purpose.  Expanding and
> multiplying numerator and denominator separately by the complex
> conjugate of the denominator is tedious to do manually and results in
> the same problem of no way to neatly separate the real and imaginary
> parts of a symbolic expression given that all symbols are real.
> 
> Thanks.
> 
> Sean Ross
> 
> Please reply to rosss at plk.af.mil as I no longer subscribe to the
> mathgroup.
You can read mathgroup through www.dejanews.com without subscribing,
right?


In[1]:=
cc[z_,r___]:=Collect[z/.Complex[w_,v_]:>comp[w,v],comp[__],r]/.comp->Complex

In[2]:= cc[ (a+b I) c + (d+e I) x] 

Out[2]= a c + d x + I (b c + e x)

-- 

Dr. Rolf Mertig
Mertig Research & Consulting  
Mathematica training and programming Development and distribution of
FeynCalc  Amsterdam, The Netherlands http://www.mertig.com


  • Prev by Date: Re: Getting rid of annoying zeroes in algebraic expressions
  • Next by Date: Re: Getting rid of annoying zeroes in algebraic expressions
  • Previous by thread: Re: Algebra on complex expressions: Collect
  • Next by thread: Re: Re: Algebra on complex expressions: Collect