MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Question about subscripts and polynomial

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107387] Re: [mg107355] Question about subscripts and polynomial
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Thu, 11 Feb 2010 05:20:07 -0500 (EST)
  • References: <201002100836.DAA21317@smc.vnet.net>

Luca Zanotti Fragonara wrote:
> Hello everybody,
> 
> I would like to write a Polynomial, in this way:
> 
> Poly = d^2*v
> Subscript[q, 1] =
>  Poly /. {d -> Sum[Subscript[d, i], {i, 1, 3}]} /. {v ->Sum[Subscript[v, 
> i], {i, 1, 3}]}
> Expand[Subscript[q, 1]]
> 
> In this way I will obtain a polynomial in this form:
> 
> d_1^2 v_1+2 d_1 d_2 v_1+d_2^2 v_1+2 d_1 d_3 v_1+2 d_2 d_3 v_1+d_3^2 
> v_1+d_1^2 v_2+2 d_1 d_2 v_2+d_2^2 v_2+2 d_1 d_3 v_2+2 d_2 d_3 v_2+d_3^2 
> v_2+d_1^2 v_3+2 d_1 d_2 v_3+d_2^2 v_3+2 d_1 d_3 v_3+2 d_2 d_3 v_3+d_3^2 v_3
> 
> I would like to reorder the expanded polynomial in a way such that the 
> terms with lower subcripts indexes will be at the beginning of the 
> polynomial, and the terms with higher order of subscripts will be at the 
> end (a sort of order due to the subscript instead of the power terms). 
> So the order should be something:
> 
> Order 3: d_1^2 v_1
> Order 4: 2 d_1 d_2 v_1+d_1^2 v_2+...
> Order 5: d_2^2 v_1+2 d_1 d_3 v_1+...
> Order 6: 2 d_2 d_3 v_1+...
> 
> I've tried to figure it out but I don't know which way to turn!!!
> 
> Thank you in advance.
> 
> Luca

Poly = d^2*v;
Subscript[q, 1] =
  Poly /. {d -> Sum[Subscript[d, i], {i, 1, 3}]} /. {v ->
     Sum[Subscript[v, i], {i, 1, 3}]};
p2 = Expand[Subscript[q, 1]]

Then you can get in the vicinity of the desired ordering using 
MonomialList with default (Lexicographic) term order, and a suitable 
ordering of the variables. I rewrote to remove subscripting, so that 
this could be readily depicted in email-friendly plain ascii.

mlist = MonomialList[p2,
    Riffle[Table[Subscript[d, i], {i, 3}],
     Table[Subscript[v, i], {i, 3}]]];

In[13]:= mlist /. Subscript -> Compose

Out[13]= {d[1]^2 v[1], d[1]^2 v[2], d[1]^2 v[3], 2 d[1] d[2] v[1],
  2 d[1] d[3] v[1], 2 d[1] d[2] v[2], 2 d[1] d[2] v[3],
  2 d[1] d[3] v[2], 2 d[1] d[3] v[3], d[2]^2 v[1], 2 d[2] d[3] v[1],
  d[3]^2 v[1], d[2]^2 v[2], d[2]^2 v[3], 2 d[2] d[3] v[2],
  2 d[2] d[3] v[3], d[3]^2 v[2], d[3]^2 v[3]}

Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: errorbar
  • Next by Date: Re: Question about subscripts and polynomial
  • Previous by thread: Question about subscripts and polynomial
  • Next by thread: Re: Question about subscripts and polynomial