       Re: How to select terms wanted in a series

• To: mathgroup at smc.vnet.net
• Subject: [mg85943] Re: [mg85916] How to select terms wanted in a series
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Thu, 28 Feb 2008 02:52:10 -0500 (EST)
• References: <200802270933.EAA16377@smc.vnet.net>

```On 27 Feb 2008, at 10:33, Barrow 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
>

Cases[expression, _?( ! FreeQ[#1, x*y] & )]
{2*x*y, u*x*y, (-x)*y*z}

or

Select[List @@ expression, Not[FreeQ[#, x*y]] &]
{2 x y, u x y, -x y z}

or even

x*y*List @@ (GroebnerBasis`DistributedTermsList[expression, {x, y}]
[[1, 1, 2]])
{2 x y, u x y, -x y z}

and many more.

Andrzej Kozlowski

```

• Prev by Date: Re: Text does not scale with size of graphic
• Next by Date: Re: Re: Deleting elements from a Table
• Previous by thread: Re: How to select terms wanted in a series
• Next by thread: Re: How to select terms wanted in a series