Re: Re: finding the (v,w) weighted degree of a polynomial

```xarnaudx at gmail.com wrote:
> thanks to all of you!
>
> 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 /.

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

```

• Prev by Date: RE: Mathematica and other programs (FEM, FEA)
• Next by Date: RE: Define a matrix function with size as argument
• Previous by thread: Re: finding the (v,w) weighted degree of a polynomial
• Next by thread: Factor question