[Date Index]
[Thread Index]
[Author Index]
Re: sorting polynomials by the degree of certain terms
*To*: mathgroup at smc.vnet.net
*Subject*: [mg49229] Re: [mg49202] sorting polynomials by the degree of certain terms
*From*: Daniel Lichtblau <danl at wolfram.com>
*Date*: Thu, 8 Jul 2004 02:51:06 -0400 (EDT)
*References*: <200407070542.BAA25018@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
David Hessing wrote:
> Hi,
>
> I dealing with huge polynomials (around 50,000 terms). Each term may
> contain some real coefficient, followed by any combination of 11
> variables, each of which may be raised to some some power. However,
> I'm interested in sorting the polynomial according to the sum of the
> degrees of only 2 of the variables. In other words, in the sorted
> expression, the first terms would be those where the two variables do
> not appear (the sum of their powers is zero). The next terms would be
> the terms where one of the two variables appeared raised to the power
> 1. The next terms would be the terms where both variables appeared
> with power 1, or just one of the variables appeared with power 2. And
> so on.
>
> I've played with passing the expression to the Sort function, along
> with a defined sorting function, but I can't get it to work. Any help
> would be greatly appreciated.
>
> -David
Here is an example with 4 variables. First create a "random" polynomial
with 20 terms.
n = 20;
exponents = Table[Random[Integer,3], {n}, {4}];
coeffs = Table[Random[Integer, {-10,10}], {n}];
InputForm[poly = coeffs .
Inner[Power,{x,y,z,w},Transpose[exponents],Times]]
Out[22]//InputForm=
-7*w^2*x^3*y + 7*w*y^3 + 8*x*y^3 - 9*z + 10*w*x^3*z + 9*w^2*y*z -
8*w^3*x^2*y^2*z - 3*x^2*y^3*z + 9*w^3*x^2*z^2 + 10*y*z^2 -
6*w^2*x^2*y*z^2 +
6*w*x^3*y^2*z^2 + 5*w^2*x*y^3*z^2 + 5*w*x*z^3 + 3*w^2*y*z^3 +
5*x^3*y*z^3 -
8*w^2*x^3*y*z^3 + w^2*x^3*y^2*z^3
To get these sorted by total degree is say {x,y}, multiply each by a new
variable and find the coefficient list with respect to that new variable.
InputForm[CoefficientList[poly /. {x->x*t,y->y*t}, t]]
Out[24]//InputForm=
{-9*z, 9*w^2*y*z + 10*y*z^2 + 5*w*x*z^3 + 3*w^2*y*z^3, 9*w^3*x^2*z^2,
7*w*y^3 + 10*w*x^3*z - 6*w^2*x^2*y*z^2, -7*w^2*x^3*y + 8*x*y^3 -
8*w^3*x^2*y^2*z + 5*w^2*x*y^3*z^2 + 5*x^3*y*z^3 - 8*w^2*x^3*y*z^3,
-3*x^2*y^3*z + 6*w*x^3*y^2*z^2 + w^2*x^3*y^2*z^3}
Variations on this for power series have appeared in the past.
From this point there are various ways in which to break down each
coefficient further in terms of degrees in x and y separately.
Daniel Lichtblau
Wolfram Research
Prev by Date:
**Re: Normal distribtion**
Next by Date:
**RE: If and openwrite and openappend**
Previous by thread:
**sorting polynomials by the degree of certain terms**
Next by thread:
**Re: sorting polynomials by the degree of certain terms**
| |