[Date Index]
[Thread Index]
[Author Index]
Re: Extracting terms of a multivariate polynomial order by order
*To*: mathgroup at smc.vnet.net
*Subject*: [mg80299] Re: [mg80280] Extracting terms of a multivariate polynomial order by order
*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>
*Date*: Thu, 16 Aug 2007 07:28:06 -0400 (EDT)
*References*: <200708160851.EAA23714@smc.vnet.net> <AC2665C6-B04E-42F9-A41A-B15ECAEC0AC9@mimuw.edu.pl>
A correction. There was a problem with copying and pasting in my
posting.
s = Normal[CoefficientArrays[p, {x, y, z}]];
should have been
ls = Normal[CoefficientArrays[p, {x, y, z}]];
Andrzej Kozlowski
On 16 Aug 2007, at 12:45, Andrzej Kozlowski wrote:
> I think this is easier to do in Mathematica 6 than in 5.2, so,
> although you are only asking about 5.2 I will start with 6. As an
> example I will construct a polynomial in three variables x, y,z of
> total degree 6, with coefficients a[i,j,k]. (The following code
> only works in v. 6.)
>
>
>
> poly = Total[Array[a[#1 - 1, #2 - 1, #3 - 1]*x^(#1 - 1)*y^(#2 - 1)
> *z^(#3 - 1) & ,
> {2, 3, 4}], 3]
>
> a[0, 0, 3]*z^3 + y*a[0, 1, 3]*z^3 + y^2*a[0, 2, 3]*z^3 + x*a[1, 0,
> 3]*z^3 +
> x*y*a[1, 1, 3]*z^3 + x*y^2*a[1, 2, 3]*z^3 + a[0, 0, 2]*z^2 +
> y*a[0, 1, 2]*z^2 +
> y^2*a[0, 2, 2]*z^2 + x*a[1, 0, 2]*z^2 + x*y*a[1, 1, 2]*z^2 +
> x*y^2*a[1, 2, 2]*z^2 +
> a[0, 0, 1]*z + y*a[0, 1, 1]*z + y^2*a[0, 2, 1]*z + x*a[1, 0, 1]*z +
> x*y*a[1, 1, 1]*z +
> x*y^2*a[1, 2, 1]*z + a[0, 0, 0] + y*a[0, 1, 0] + y^2*a[0, 2, 0] +
> x*a[1, 0, 0] +
> x*y*a[1, 1, 0] + x*y^2*a[1, 2, 0]
>
> In Mathematica 6.0 there is a very convenient function
> CoefficientArrays which makes it possible to do what you want to do
> (assuming I have understood you corrrectly) easily:
>
> s = Normal[CoefficientArrays[p, {x, y, z}]];
>
> Now, for example,
>
> ls[[3]]
>
> {{0, a[1, 1, 0], a[1, 0, 1]}, {0, a[0, 2, 0], a[0, 1, 1]}, {0, 0, a
> [0, 0, 2]}}
>
> gives you all the coefficients of terms of total degree 2 (note
> that the coefficients always appear in arrays of full rank so
> usually they will contain some 0s).
>
> In Mathematica 5.2 the most convenient function for this purpose is
> undocumented and appears in the Internal context. The function name
> is Internal`DistributedTermsList. In Mathematica 6 this function
> appears in the GroebnerBasis` context so its name has to be changed
> accordingly.
>
> terms = GroebnerBasis`DistributedTermsList[p, {x, y, z}]
>
> I have supressed the output but if you look at it you will
> immediately understand what it does. Now, it is easy to use pattern
> matching to extract coefficients of terms of any chosen total
> degree, e.g.
>
> Cases[terms, {p_, l_} /; Total[p] == 4 -> l, Infinity]
> {a(1, 2, 1), a(1, 1, 2), a(1, 0, 3), a(0, 2, 2), a(0, 1, 3)}
>
> gives all the coefficients of terms of total degree 4.
>
> Andrzej Kozlowski
>
>
>
> On 16 Aug 2007, at 10:51, Marcus P S wrote:
>
>> Hello,
>>
>> I have a multivariate polynomial (3 variables) from which I would
>> like to extract terms order by order. More explicitly, I want all
>> the
>> lowest order terms, or all terms of the form
>>
>> c(L,M,N) x^L y^M z^N
>>
>> where L+M+N is smallest, and c(LMN) is some coefficient. If I have
>> this, I can extract order by order, and taylor to which order I want
>> to approximate my polynomial.
>>
>> I considered "Coefficients", but if I ask for the coefficients of
>> the form x^2 z^2, it may return something like "1 + y", which is not
>> what I want. Moreover, I have to explicitly request each possible
>> term of a given order, which seems too mechanical/repetitive to be
>> the
>> "right way" to do things. The function for manipulating SeriesData
>> objects are similarly limited.
>>
>> I am assuming that there is function in Mathematica (even 5.2) that
>> will do this. Any suggestions would be greatly welcome.
>>
>> Thanks in advance.
>>
>> Marcus Silva
>>
>>
>
Prev by Date:
**Re: Evaluating a convolution integral in Mathematica**
Next by Date:
**Mathematica 6**
Previous by thread:
**Re: Extracting terms of a multivariate polynomial order by order**
Next by thread:
**Re: Extracting terms of a multivariate polynomial order by order**
| |