Re: product formula in mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg68767] Re: [mg68702] product formula in mathematica
• From: Murray Eisenberg <murray at math.umass.edu>
• Date: Fri, 18 Aug 2006 03:12:13 -0400 (EDT)
• Organization: Mathematics & Statistics, Univ. of Mass./Amherst
• References: <200608170818.EAA24861@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```In general, if you have a list lis of numbers, you can find their product by

Apply[Times, lis]

or, in abbreviated format:

Times @@ lis

So a strategy would be to form first the list of numbers to be
multiplies, and then use the above.

Now I'm not quite sure what you mean by x_i in your posting.  Are you
trying to explicitly use subscripts (via the Notation package)?  Indices
via the x[[i]] notation?  Ordinary arguments via the x[i] notation.

In any case, since you have no particular pattern in mind for the
subscripts, you'll somehow have to specify them one-by-one.  For example
(doing it slowly, step by step):

x = Table[i^2, {i, 1, 10}]
{1, 4, 9, 16, 25, 36, 49, 64, 81, 100}

indices = {1,3,4,9}
{1, 3, 4, 9}

x[[indices]]
{1, 9, 16, 81}
f[x_] := 1/x   (* for example *)
f[x[[indices]]]
{1, 1/9, 1/16, 1/81}

Times @@ f[x[[indices]]]
1/11664

In the above, I'm using, and assuming you have, a function f that has
attribute Listable.  (Also, I actually showed the InputForm of the two
results that have fractions in them.)

frou wrote:
> Hi I am interested in doing a product over a set of indices that are
> not continuous
> Product [ f(x_i) , { x_i, 1,3,4,9}]     Is this possible it appears
> that the iterator wouldonly take sequences such as 1...10 etc.
>
> Thanks
>
>

--
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

```

• Prev by Date: memory issues
• Next by Date: Re: distance function
• Previous by thread: product formula in mathematica
• Next by thread: Re: product formula in mathematica