       • To: mathgroup at smc.vnet.net
• Subject: [mg69188] Re: [mg69149] Re: [mg69055] a curious answer
• From: "Chris Chiasson" <chris at chiasson.name>
• Date: Fri, 1 Sep 2006 06:41:29 -0400 (EDT)
• References: <200608290725.DAA28971@smc.vnet.net> <200608310839.EAA19560@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```After seeing Devendra's response, I realize that I am blind. I thought
the input didn't have an x in it.

> On Tue, 29 Aug 2006, rick wrote:
>
> > Hi,
> >
> > Can anyone explain these answers (Out and Out)?
> >
> > Line 1 defines a polynomial in x that depends on n;
> > line 2 tests the definition when n= 4;
> > line 3 lists the coefficients of that polynomial and
> > line 4 checks the list when n= 4; lines 5 and 6 ask for a closed form
> > for the polynomial and coefficients (which is probably not possible). I
> > expected no answer-not gibberish.
> >
> > In:=
> > k[n_]:=Expand[Product[(j*x+n-j),{j,1,n-1}]]
> >
> > In:=
> > k
> >
> > Out=
> > \!\(6 + 26\ x + 26\ x\^2 + 6\ x\^3\)
> >
> > In:=
> > cL[s_]:=CoefficientList[k[s],x]
> >
> >
> > In:=
> > cL
> >
> > Out=
> > {6,26,26,6}
> >
> > In:=
> > cL[n]
> >
> > Out=
> > \!\({\(-\((\(-1\))\)\^n\)\ n\^\(\(-1\) + n\)\ \(\((\(-1\) + n)\)!\)}\)
> >
> > In:=
> > k[n]
> >
> > Out=
> > \!\(\(-\((\(-1\))\)\^n\)\ n\^\(\(-1\) + n\)\ \(\((\(-1\) + n)\)!\)\)
> >
> >
> > Thanks,
> >
>
> Hello Rick,
>
> Thank you for reporting the problem with the above finite product.
>
> In this example, Product fails to identify the coefficient of 'j'
> in the first argument (j*x+n-j) correctly, and returns an answer
> independent of 'x'.
>
> A workaround for this problem is to use Collect in the definition
> of k[n]. This seems to work well and gives a closed form for the
> product in terms of Pochhammer (Out below). The message from
> CoefficientList is given to indicate that the result from Product
> depends on 'x' but is not a polynomial in 'x' for symbolic 'n'.
>
>
> ===================================
>
> In:= \$Version
>
> Out= 5.2 for Linux (June 27, 2005)
>
> In:= k[n_] := Expand[Product[Collect[(j*x + n - j), j], {j, 1, n - 1}]]
>
> In:= k
>
>                         2      3
> Out= 6 + 26 x + 26 x  + 6 x
>
> In:= cL[s_] := CoefficientList[k[s], x]
>
> In:= cL
>
> Out= {6, 26, 26, 6}
>
> In:= cL[n]
>
>                         -1 + n                  n
> General::poly: (-1 + x)       Pochhammer[1 + ------, -1 + n]
>                                               -1 + x
>       is not a polynomial.
>
>                   n                  n
> Out= {(-1 + x)  Pochhammer[1 + ------, -1 + n]}
>                                    -1 + x
>
> In:= k[n]
>
>                  -1 + n                  n
> Out= (-1 + x)       Pochhammer[1 + ------, -1 + n]
>                                        -1 + x
>
> In:= Expand[Together[% /. {n -> 4}]]
>
>                         2      3
> Out= 6 + 26 x + 26 x  + 6 x
>
> =================================
>
> I apologize for the inconvenience caused by this problem.
>
> Sincerely,
>
> Wolfram Research, Inc.
>
>

--
http://chris.chiasson.name/

```

• Prev by Date: Re: generalized foldlist problem - part 2
• Next by Date: Re: efficient term collection algorithm