MathGroup Archive 2006

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

Search the Archive

Re: a simple product, but with "i = 1...n AND i != x"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70255] Re: a simple product, but with "i = 1...n AND i != x"
  • From: "Philpp" <piotr at bigpond.net.au>
  • Date: Tue, 10 Oct 2006 06:12:04 -0400 (EDT)
  • References: <egcok5$je2$1@smc.vnet.net>

How about

In[1]=  f[x_, n_] := Product[x - i /. (0. | 0) -> 1, {i, 1, n}]
        f[1 | 1., 1] := 0

For comparison, let

In[3]=  h[x_, n_] := Product[(x - i), {i, 1, n}]

In[4]=  Table[{x, f[x, 3]}, {x, 0, 5}]
        Table[{x, h[x, 3]}, {x, 0, 5}]
Out[4]= {{0, -6}, {1, 2}, {2, -1}, {3, 2}, {4, 6}, {5, 24}}
Out[5]= {{0, -6}, {1, 0}, {2, 0}, {3, 0}, {4, 6}, {5, 24}}

Cheers,
Phil

xarnaudx at gmail.com wrote:
> hi,
> i would like to make a function like
> f[x_] := Product[x - i, {i, 1, n} AND i != x}
>
> obviously, the end of the expression is syntactically incorrect. But
> how to rewrite this product correctly?
> thanks


  • Prev by Date: RE: a simple product, but with "i = 1...n AND i != x"
  • Next by Date: Copy input and User Defined Variables
  • Previous by thread: RE: a simple product, but with "i = 1...n AND i != x"
  • Next by thread: RE: a simple product, but with "i = 1...n AND i != x"