       Re: Possible Bug Report: CoefficientList

• To: mathgroup at smc.vnet.net
• Subject: [mg88865] Re: [mg88844] Possible Bug Report: CoefficientList
• From: "W_Craig Carter" <ccarter at mit.edu>
• Date: Mon, 19 May 2008 06:45:56 -0400 (EDT)
• References: <200805190915.FAA12556@smc.vnet.net>

```Hello,
The following will work and gives you a hint of what is going wrong:

Table[Chances[numberDice, 6], {numberDice, 3, 5}]

To avoid this,  localize the scope of x.

Chances[dice_, sides_] :=
Module[{x}, CoefficientList[Expand[(Sum[x^i, {i, sides}])^dice], x]]

Table[Chances[x, 6], {x, 3, 5}]

On Mon, May 19, 2008 at 5:15 AM,  <anglewyrm at yahoo.com> wrote:
> Here is a function using CoefficientList[] that produces a list:
> Chances[dice_, sides_] := CoefficientList[Expand[(Sum[x^i, {i,
> sides}])^dice], x];
>
> (* This works: *)
> Chances[3, 6]
> Chances[4,6]
> Chances[5,6]
>
> (* This fails: *)
> Table[ Chances[x, 6], {x, 3, 5}]
>
> CoefficientList::ivar: 1 is not a valid variable. >>
> CoefficientList::ivar: 2 is not a valid variable. >>
> CoefficientList::ivar: 3 is not a valid variable. >>
> General::stop: Further output of CoefficientList::ivar will be
> suppressed during this calculation. >>
>
>

--
W. Craig Carter

```

• Prev by Date: Re: Mathematica 6: No more memory available problem with ListDensityPlot
• Next by Date: Re: Filtering a list of list for certain elements that
• Previous by thread: Re: Re: Possible Bug Report: CoefficientList
• Next by thread: Re: Possible Bug Report: CoefficientList