Re: `Collect' with complex numbers??
- To: mathgroup@smc.vnet.net
- Subject: [mg12369] Re: [mg12320] `Collect' with complex numbers??
- From: Daniel Lichtblau <danl@wolfram.com>
- Date: Sun, 10 May 1998 02:04:52 -0400
- References: <199805072252.SAA01018@smc.vnet.net.>
Craig P Earls wrote: > > I couldn't figure out how to do an annoyingly straightforward > transformation with crtesian complex numbers: > > Collect[(a+b)c +b d,b] > > yields > > a c + b(c+d) > > Which is good, but > > Collect[(a+i)b + c I , I] > > yields > > (a+I)b +c I > > How can I do complex algebra when I can't get this transformation? Using > ComplexExpand and Re is less than satisfying. > > -- > ---------------------------------------------------------------------- > Craig P Earls, LT U.S. Navy cearls@ix.netcom.com > MIT Naval Construction and Engineering cpearls@mit.edu > ---------------------------------------------------------------------- The entity I is a number (it is a symbolic convenience for Complex[0,1]) and Collect cannot use a number for its variable. Roughly, this is because Complex[a,b] is an atomic entity (for integer/rational/real a,b), hence will not be split for purposes of collection. You can work around this with simple replacement rules. I do it inside a module in order to localize the complexCollect[expr_, var_] := Module[ {myI,e2,v2}, {e2,v2} = {expr,var} /. Complex[a_,b_]->a+myI*b; Collect[e2,v2] /. myI->I ] In[18]:= complexCollect[(a+I)b + c I , I] Out[18]= a b + I (b + c) Daniel Lichtblau Wolfram Research
- References:
- `Collect' with complex numbers??
- From: Craig P Earls <cearls@ix.netcom.com>
- `Collect' with complex numbers??