MathGroup Archive 2008

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

Search the Archive

Re: How to select terms wanted in a series

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85951] Re: How to select terms wanted in a series
  • From: Bhuvanesh <BhuvaneshBhatt at gmail.com>
  • Date: Thu, 28 Feb 2008 02:56:18 -0500 (EST)
  • References: <fq3bhj$gas$1@smc.vnet.net>

On Feb 27, 3:46 am, Barrow <GRsemi... at gmail.com> wrote:
> Dear all,
>
> I have an expression, which is a sum of large number of terms, e.g.
>
> expression = x + 2x*y - x*y*z + u*x*y + 3u^2
>
> And I want to select out terms with the factor (x*y). e.g.
>
> The terms in "expression" that I want are 2x*y, -x*y*z, u*x*y
>
> My first step is,
>
> allterms = Apply[List, expression]
>
> Then, I don't know how to extract the terms I want, I use
>
> Select[allterms, (# == x*y*_)&]
>
> But It doesn't work.
>
> Anyone has some good ideas? any help will be appreciated much!
> Sincerely  Barrow

In[1]:= expression = x + 2x*y - x*y*z + u*x*y + 3u^2;

In[2]:= Select[expression, MatchQ[#, c_.*x*y]&]

Out[2]= 2 x y + u x y - x y z

In[3]:= List@@%

Out[3]= {2 x y, u x y, -(x y z)}

Bhuvanesh,
Wolfram Research


  • Prev by Date: Re: How to select terms wanted in a series
  • Next by Date: Re: How to select terms wanted in a series
  • Previous by thread: Re: How to select terms wanted in a series
  • Next by thread: Re: How to select terms wanted in a series