MathGroup Archive 2004

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

Search the Archive

Re: Extracting Coefficients and Powers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg48262] Re: Extracting Coefficients and Powers
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 20 May 2004 04:03:36 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <c8f8u8$fd4$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I'm sure, that you will like the code below

Transpose[(#  /. {a_ /; FreeQ[a, x] :> {a, 0}, a_.x^n_. :> {a, n}}) & /@ 
    Cases[x^3.2 + 5 - 3/x^5.2 - x^5, a_.*x^_. | a_ /; FreeQ[a, x]]]

Regards
  Jens



"Bruce W. Colletti" wrote:
> 
> I have a sum of terms, each of the form "a * x^r" or "a * 1/x^r", where
> a and (positive) r are real numbers (if a is missing, it's presumably 1
> or -1 and if there is no x-term, r is understood to be 0).
> 
> In my application, the complete expression is given by Expand[p], where
> p is a product of terms having form a t^b + c t^d (p is actually a
> factorial moment generating function).
> 
> I want to extract all coefficients into a list (including 1 or -1
> coefficients), and exponents into another (to include 0 for any constant
> term).  For instance,
> 
> x^3.2 + 5 - 3 / x^5.2 - x^5
> 
> yields the coefficients' list {1, 5, -3, -1} and exponents' list {3.2,
> 0, -5.2,5}.
> 
> How would I build these lists?  Must Cases[ ] be used or are there
> built-in functions?
> 
> Thanks.
> 
> Bruce


  • Prev by Date: RE : Bug in O[x]
  • Next by Date: Re: Uniform design
  • Previous by thread: Re: Extracting Coefficients and Powers
  • Next by thread: RE: Extracting Coefficients and Powers