       Re: Grouping similar indices together in an expression

• To: mathgroup at smc.vnet.net
• Subject: [mg65254] Re: Grouping similar indices together in an expression
• From: Bill Rowe <readnewsciv at earthlink.net>
• Date: Wed, 22 Mar 2006 06:13:44 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```On 3/21/06 at 7:46 AM, dpsanders at gmail.com (David Sanders) wrote:

>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?

It would be very useful to be able to see what Mathematica code you have tried to better understand what you are trying to do. I will offer a few comments. But without seeing the code, I've no idea how appropriate my comments will be.

First, note in Mathematica, the syntax a[j] does not refer to an indexed variable. Instead Mathematica sees this as a function named "a" to be evaluated at j. When you write something like

a=10

you are defining the function a to have value 10 when evaluated at 1.

For what you are describing, it would be better to define a and b as lists of values, i.e.,

In:=
a = Table[Subscript[a, n], {n, 3}];
b = Table[Subscript[b, n], {n, 3}];

Here, I've used subscripts for clarity in what follows.

Given the data as lists then

In:=
Times @@ MapThread[f, {a, b}]

Out=
f[Subscript[a, 1], Subscript[b, 1]]*
f[Subscript[a, 2], Subscript[b, 2]]*
f[Subscript[a, 3], Subscript[b, 3]]

does what you seem to be asking for
--
To reply via email subtract one hundred and four

```

• 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