 
 
 
 
 
 
Re: Re: finding the (v,w) weighted degree of a polynomial
- To: mathgroup at smc.vnet.net
- Subject: [mg71373] Re: [mg71318] Re: finding the (v,w) weighted degree of a polynomial
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Thu, 16 Nov 2006 00:52:59 -0500 (EST)
- References: <200611121148.GAA18658@smc.vnet.net><ejc5b4$6st$1@smc.vnet.net> <200611151143.GAA01169@smc.vnet.net>
xarnaudx at gmail.com wrote:
> thanks to all of you!
> 
> adopted solution:
> WDeg[Q_, v_, w_] :=
>    {v, w}.Internal`DistributedTermsList[Q, {x, y}, MonomialOrder ->
> {{v, w}, {0, 1}}][[1, 1, 1]];
> 
> The last suggested solution, despite of being very elegant, has an
> issue: different monomials of same weighted degree can cancel each
> other and vanish. For example:
> P(x,y) = x^3 y - x^1 y^2
> For the (1,2)-degree, when replacing {x -> t, y -> t^2}, we get: P(t) =
> t^5 - t^5 = 0
> Resulting in a weighted degree of 0 instead of the correct answer which
> would be 5.
Right. I knew that, once, long ago. The corrected version uses random 
coefficients to avoid this cancellation pitfall.
weightedDegree[poly_, vars_, wts_] := Module[{t},
   Exponent[poly /.
     Thread[vars -> Table[Random[],{Length[wts]}]*t^wts], t]]
In[25]:= weightedDegree[x^3*y - x*y^2, {x,y}, {1,2}]
Out[25]= 5
I like Internal`DistributedTermsList (I wrote it), but I think it is 
overkill for this particular problem. Though if you need more 
information about a polynomial with respect to a particular term order, 
it's the function of choice (granted, as an "internal" function it is 
not documented).
Daniel Lichtblau
Wolfram Research
- References:
- finding the (v,w) weighted degree of a polynomial
- From: "xarnaudx@gmail.com" <xarnaudx@gmail.com>
 
- Re: finding the (v,w) weighted degree of a polynomial
- From: "xarnaudx@gmail.com" <xarnaudx@gmail.com>
 
 
- finding the (v,w) weighted degree of a polynomial

