Re: coefficient of a polynomial term
- To: mathgroup at smc.vnet.net
- Subject: [mg59397] Re: coefficient of a polynomial term
- From: Bhuvanesh <lalu_bhatt at yahoo.com>
- Date: Mon, 8 Aug 2005 03:34:46 -0400 (EDT)
- References: <dd4em8$hm6$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
> There are also undocumented algebra functions whose
> output contains the coefficients of a polynomial,
> for example
>
> s=Internal`DistributedTermsList[poly,{x,y}]
>
> {{{{3, 0}, 1}, {{2, 0}, 2}, {{1, 1}, 3}, {{0, 2}, 4}},
> {x, y}}
>
> You can extract the coefficients with, for example:
>
> s[[1,All,1]][[All,1]]
>
> {3,2,1,0}
You meant:
In[1]:= poly = 2 x^2 +3 x*y +4 y^2+x^3;
In[2]:= s = Internal`DistributedTermsList[poly,{x,y}]
Out[2]= {{{{3, 0}, 1}, {{2, 0}, 2}, {{1, 1}, 3}, {{0, 2}, 4}}, {x, y}}
In[3]:= s[[1,All,2]]
Out[3]= {1, 2, 3, 4}
The result of DistributedTermsList looks like:
{{{expvec1,coef1}, {expvec2,coef2}, ...}, variables}
where "expvec" stands for "exponent vector". There's also the inverse, which converts the result of DistributedTermsList back to the explicit polynomial form:
In[4]:= Internal`FromDistributedTermsList[s]
2 3 2
Out[4]= 2 x + x + 3 x y + 4 y
Bhuvanesh,
Wolfram Research.
- Follow-Ups:
- Re: Re: coefficient of a polynomial term
- From: Andrzej Kozlowski <akozlowski@gmail.com>
- Re: Re: coefficient of a polynomial term