MathGroup Archive 2008

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

Search the Archive

Re: Selecting Element from List via Pattern Matching

On Jun 8, 8:33 am, at 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

Hi, actually I do not understand why you convert the series into a
list. If you stick with the series just use

ex[f_, c_] := Coefficient[f /. {c -> s}, s]
ex[t, Subscript[a, 2]^2]

which does the job.

  • Prev by Date: Re: Dynamic GUI problem II.
  • Next by Date: Re: Creation and evaluation of polynomials
  • Previous by thread: Re: Selecting Element from List via Pattern Matching
  • Next by thread: color depth of eps export