Re: Order of terms
- To: mathgroup at smc.vnet.net
- Subject: [mg77743] Re: Order of terms
- From: dh <dh at metrohm.ch>
- Date: Fri, 15 Jun 2007 06:21:14 -0400 (EDT)
- References: <f4r3ic$980$1@smc.vnet.net>
Hi Thomas, Plus orders its agruments automatically. Therefore, you must either replace Plus by e.g. List or redefine PLus what is pretty dangerous. Here is a rule that replaces by List and orders according to sum of indices: rule={Plus->List,_[x1:__,x2:Subscript[a,k1_]Subscript[b,k2_],x3:Subscript[a,k3_]Subscript[b,k4_],x4__]/;(k1+k2)>(k3+k4):> {x1,x3,x2,x4}}; c[3]//.rule hope this helps, Daniel Thomas Madden wrote: > Given > > > In[1]:= c[p_] := Sum[Subscript[a, k]* Subscript[b, n - k], {n, 0, p}, {k, 0, > n}] > > > > How can I get the output in the same order that the double sum is written? > For example I would like to have the output from c[2] be > > > > In[3]:= Hold[Subscript[a, 0]Subscript[b, 0]+Subscript[a, 0]Subscript[b, > 1]+Subscript[a, 1]Subscript[b, 0]+Subscript[a, 0]Subscript[b, > 2]+Subscript[a, 1]Subscript[b, 1]+Subscript[a, 2]Subscript[b, 0]] > > > rather than the default > > > c[2] > > Thanks in advance for any and all replies. > > Thomas >