Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Possible Bug Report: CoefficientList

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88881] Re: [mg88844] Possible Bug Report: CoefficientList
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 20 May 2008 02:27:10 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

You usined x both locally and globally at the same time.

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

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

{{0,0,0,1,3,6,10,15,21,25,27,27,25,21,15,10,6,3,1},{0,0,0,0,1,4,10,20,35,56,\
80,104,125,140,146,140,125,104,80,56,35,20,10,4,1},{0,0,0,0,0,1,5,15,35,70,\
126,205,305,420,540,651,735,780,780,735,651,540,420,305,205,126,70,35,15,5,1}}


Bob Hanlon

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



  • Prev by Date: Re: Redundant manipulate
  • Next by Date: Re: Mathematica 6: No more memory available problem with
  • Previous by thread: Re: Possible Bug Report: CoefficientList
  • Next by thread: Mathematica 6: No more memory available problem with ListDensityPlot