Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Grouping similar indices together in an expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65253] Re: [mg65242] Grouping similar indices together in an expression
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 22 Mar 2006 06:13:43 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

I'm not sure that I understand what you want but here goes

Clear[f];
f[x_?(Length[Union[Cases[#,_,{2}]]]>1&)]:=
    Module[{g,indices},
      indices=Union[Cases[g[x],_,{3}]];
      Times@@(f/@(Times@@Cases[g[x],_[#],{2}]&/@indices))];

f[a[i] b[i]]

f[a[i]*b[i]]

f[a[i] b[j]]

f[a[i]]*f[b[j]]

f[a[i] a[j] b[i] b[j]]

f[a[i]*b[i]]*f[a[j]*b[j]]

f[a[i] a[j] a[k] b[j]]

f[a[i]]*f[a[k]]*f[a[j]*b[j]]

f[a[i] a[j] a[k] b[l]]

f[a[i]]*f[a[j]]*f[a[k]]*f[b[l]]


Bob Hanlon

> 
> From: "David Sanders" <dpsanders at gmail.com>
To: mathgroup at smc.vnet.net
> Subject: [mg65253] [mg65242] Grouping similar indices together in an expression
> 
> Hi,
> 
> I am a newbie in Mathematica, and am trying to do the following.
> 
> I have terms which look like
> a[i] a[j] b[i] b[j]
> 
> I need to apply a function F, for which I need to group the different
> indices (by which I mean i, j) together as follows:
> 
> F(a[i] a[j] b[i] b[j]) = F(a[i] b[i]) F(a[j] b[j])
> 
> I do not in general know how many different indices there might be in a
> term.  E.g. I might have
> a[i] a[j] a[k] b[j]
> 
> Could somebody please give me a hint as to how to do this?
> 
> Thanks,
> David.
> 
> 


  • Prev by Date: Re: Grouping similar indices together in an expression
  • Next by Date: Re: Grouping similar indices together in an expression
  • Previous by thread: Re: Grouping similar indices together in an expression
  • Next by thread: Re: Grouping similar indices together in an expression