Re: coefficient of a polynomial term
- To: mathgroup at smc.vnet.net
- Subject: [mg59362] Re: coefficient of a polynomial term
- From: albert <awnl at arcor.de>
- Date: Sun, 7 Aug 2005 03:46:56 -0400 (EDT)
- References: <dd1idh$19u$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, > > poly = 2 x^2 +3 x*y +4 y^2+x^3 > > I would like to get 2 for first term, 3 for second term, 4 for third term > and so on.. I'm not sure what you really need, if you really need the coefficient of the n'th term something like this should work: n=3 Part[poly, n] /. {x | y -> 1} where you might want to use a more specific or general pattern in the last rule(s) or could try to extract all variables of the polynomial if you don't know them beforehand. Be aware that the ordering of terms will depend on e.g. the naming of your variables and so it is not a very reliable thing... So probably you really are more interested in the coefficient of a certain form, and this is even easier: Coefficient[poly, x^2] gives you the coefficient of the term containing x^2. There is also the function CoefficientList which is probably also of interest for you. Albert