Greetings,

I'm trying to use `keep_weight`

to extract the leading quadratic terms in a simple cubic. In the following example I use two methods that I was expecting to give the same results. The first method gives the correct result while the second only returns the linear term. Here is the code.

```
{a,b,c,d,e,f,g,h,i,j}::Indices.
eps::LaTeXForm("{\epsilon}").
eps::Weight(label=num).
x^{a}::Weight(label=num).
abc := x^{a} + A_{b} x^{a} x^{b} + A_{b c} x^{a} x^{b} x^{c};
tmp0 := @(abc).
tmp1 := @(abc).
tmp2 := @(abc).
tmp3 := @(abc).
keep_weight (tmp0, $num=0$)
keep_weight (tmp1, $num=1$)
keep_weight (tmp2, $num=2$)
keep_weight (tmp3, $num=3$)
abc := @(tmp0) + @(tmp1) + @(tmp2);
pqr := x^{a} + A_{b} x^{a} x^{b} + A_{b c} x^{a} x^{b} x^{c};
substitute (pqr, $x^{a} -> eps x^{a}$)
collect_factors (pqr)
tmp0 := @(pqr).
tmp1 := @(pqr).
tmp2 := @(pqr).
tmp3 := @(pqr).
keep_weight (tmp0, $num=0$)
keep_weight (tmp1, $num=1$)
keep_weight (tmp2, $num=2$)
keep_weight (tmp3, $num=3$)
pqr := @(tmp0) + @(tmp1) + @(tmp2);
```

The even stranger thing is if I replace `x^{#}`

with `x1^{#}`

(as in the following code) then the results are swapped -- the first method is wrong (it returns the original cubic) while the second method is correct. I'm confused :).

```
{a,b,c,d,e,f,g,h,i,j}::Indices.
eps::LaTeXForm("{\epsilon}").
eps::Weight(label=num).
x1^{a}::Weight(label=num).
abc := x1^{a} + A_{b} x1^{a} x1^{b} + A_{b c} x1^{a} x1^{b} x1^{c};
tmp0 := @(abc).
tmp1 := @(abc).
tmp2 := @(abc).
tmp3 := @(abc).
keep_weight (tmp0, $num=0$)
keep_weight (tmp1, $num=1$)
keep_weight (tmp2, $num=2$)
keep_weight (tmp3, $num=3$)
abc := @(tmp0) + @(tmp1) + @(tmp2);
pqr := x1^{a} + A_{b} x1^{a} x1^{b} + A_{b c} x1^{a} x1^{b} x1^{c};
substitute (pqr, $x1^{a} -> eps x1^{a}$)
collect_factors (pqr)
tmp0 := @(pqr).
tmp1 := @(pqr).
tmp2 := @(pqr).
tmp3 := @(pqr).
keep_weight (tmp0, $num=0$)
keep_weight (tmp1, $num=1$)
keep_weight (tmp2, $num=2$)
keep_weight (tmp3, $num=3$)
pqr := @(tmp0) + @(tmp1) + @(tmp2);
```

Any suggestions?

Cheers,

Leo