Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Selecting Element from List via Pattern Matching

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89416] Re: [mg89396] Selecting Element from List via Pattern Matching
  • From: "Adriano Pascoletti" <adriano.pascoletti at gmail.com>
  • Date: Mon, 9 Jun 2008 02:27:13 -0400 (EDT)
  • References: <200806080632.CAA02645@smc.vnet.net>

Immanuel,
look for epressions which are not free of a_2^2

Cases[%, x_ /;  ! FreeQ[x, Subscript[a, 2]^2]]


gives


{3 Subscript[a, 1]   SubsuperscriptBox[ a ,  2 ,  2 ],

 3 SubsuperscriptBox[ a ,  2 ,  2 ] Subscript[a, 3],

 3 SubsuperscriptBox[ a ,  2 ,  2 ] Subscript[a, 4],

 3 SubsuperscriptBox[ a ,  2 ,  2 ] Subscript[a, 5]}

Adriano Pascoletti

On Sun, Jun 8, 2008 at 8:32 AM, <immanuel.bloch at googlemail.com> wrote:

> Hello,
>
>  I am trying to extract from a Power Series all elements with a
> certain exponent, e.g.
> let us say I have generated a list via
>
> t = Apply[List, Expand[(Sum[Subscript[a, i], {i, 1, 5}])^3]]
>
> How can I then extract all terms with e.g. a_2^2 in it or any other
> exponent?
>
> I have tried something like
>
> Cases[t, Times[_, Power[Subscript[a,2],2]]]
>
> but this somehow only works with the exponent n=1 and no others...
>
> Does anybody know a solution to this pattern matching problem?
>
> Thanks!
> Immanuel
>
>


  • Prev by Date: Re: Selecting Element from List via Pattern Matching
  • Next by Date: Re: Selecting Element from List via Pattern Matching
  • Previous by thread: Re: Selecting Element from List via Pattern Matching
  • Next by thread: Re: Selecting Element from List via Pattern Matching