Re: Extracting polynomial coefficients?
- To: mathgroup@smc.vnet.net
- Subject: [mg11524] Re: Extracting polynomial coefficients?
- From: Paul Abbott <paul@physics.uwa.edu.au>
- Date: Fri, 13 Mar 1998 12:22:13 -0500
- Organization: University of Western Australia
- References: <6e87es$nlo@smc.vnet.net>
Thomas Bell wrote:
> I have a very long polynomial that's a function of four variables, a, b,
> c, d. I would like Mathematica to (1) tell me what combinations of a,
> b, c, and d are in my polynomial, and (2) tell me what the coefficients
> are for each of the variable terms.
>
> For example, say I have constant terms r and q. My polynomial might
> look something like
>
> 4 a^2 b^3 c + r q d^5 + a d^3 + q c^2 a^2 + r^2 a d^3
>
> I would like to have Mathematica output something like:
>
> a^2 b^3 => 4
> d^5 => r q
> a d^3 => 1 + r^2
> c^2 a^2 => q
How about the following tabular output?
p = 4 a^2 b^3 c + r q d^5 + a d^3 + q c^2 a^2 + r^2 a d^3;
vars = {a, b, c, d};
TableForm[ns = Exponent[p, vars]; cs = CoefficientList[p, vars],
TableHeadings -> {Table[vars[[1]]^i, {i, 0, ns[[1]]}],
Table[vars[[2]]^i, {i, 0, ns[[2]]}]}]
Cheers,
Paul
____________________________________________________________________
Paul Abbott Phone: +61-8-9380-2734
Department of Physics Fax: +61-8-9380-1014
The University of Western Australia Nedlands WA 6907
mailto:paul@physics.uwa.edu.au AUSTRALIA
http://www.pd.uwa.edu.au/~paul
God IS a weakly left-handed dice player
____________________________________________________________________