Re: Possible Bug Report: CoefficientList
- To: mathgroup at smc.vnet.net
- Subject: [mg88876] Re: Possible Bug Report: CoefficientList
- From: dh <dh at metrohm.ch>
- Date: Tue, 20 May 2008 02:26:09 -0400 (EDT)
- References: <g0rker$dte$1@smc.vnet.net>
Hi,
consider the variable x in the definition of Chances. This is a global
variable that can be changed by anybody, what is very dangerous. This is
exactly what happens in Table[...]. You must localize this variable e.g.
using Module.
Hope this helps, Daniel
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. >>
>