 
 
 
 
 
 
Re: Coefficents of terms in an expression containing the matching string
- To: mathgroup at smc.vnet.net
- Subject: [mg118000] Re: Coefficents of terms in an expression containing the matching string
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Fri, 8 Apr 2011 04:13:29 -0400 (EDT)
Start with legal syntax. It can't hurt:
y = 0.5*u*Exp[-2 I d1 - d2 - I d4 - phi] -
    0.5*k2*k3*u*Exp[-I d2 - I d4 - phi] -
    0.5*k2*k4*u*Exp[-I d2 - Id 3 - I phi];
Cases[y, Times[a__, Exp[__]] :> Times[a], 1] /. x_Real :> Abs@x
{0.5 u, 0.5 k2 k3 u, 0.5 k2 k4 u}
y = 0.5*u*Exp[-2 I d1 - d2 - I d4 - phi] -
    0.5*k2^2*k3*u*Exp[-I d2 - I d4 - phi] -
    0.5*k2*k4*u*Exp[-I d2 - I d3 - I phi] -
    0.5*k2^2*k5*v*Exp[-I d2 - I d3 - I phi];
DeleteCases[y, x_ /; FreeQ[x, k2^2], 1] /. x_?Real :> Abs@x
-0.5 E^(-I d2 - I d4 - phi) k2^2 k3 u -
  0.5 E^(-I d2 - I d3 - I phi) k2^2 k5 v
Bobby
On Thu, 07 Apr 2011 07:05:33 -0500, Chelly <chelly85086 at gmail.com> wrote:
> I have two questions. The solutions may be very simple, but since I am a  
> Mathematica novice, need some guidance.
> 1) I have an expression:
> y = 0.5*u*exp(-2 I d1 - d2 - I d4 - phi) -
>      0.5*k2*k3*u*exp(-I d2 - I d4 - phi) -
>      0.5*k2*k4*u*exp(-I d2 - Id 3 - I phi) ;
> What command should I use to get just the amplitude of each term, i.e  
> excluding the exponential - exp(). In this case, the results needs to be
> {0.5*u, 0.5*k2*k3*u, 0.5*k2*k4*u)
> 2) The second question is along similar lines. I have an expression and  
> I need to find out the terms that have k2^2 in the amplitude
> y = 0.5*u*exp(-2 I d1 - d2 - I d4 - phi) -
>      0.5*k2^2*k3*u*exp(-I d2 - I d4 - phi) -
>      0.5*k2*k4*u*exp(-I d2 - Id 3 - I phi)  -
>      0.5*k2^2*k5*v*exp(-I d2 - Id 3 - I phi) ;
> In this case, the answer is the second and last term:
> 0.5*k2^2*k3*u*exp(-I d2 - I d4 - phi) -
>   0.5*k2^2*k5*v*exp(-I d2 - Id 3 - I phi)
>
-- 
DrMajorBob at yahoo.com

