Skip to content

coefficient of polynomial expansion

3 messages · Peter Yang, Gabor Grothendieck, Martin Maechler

#
Hi,

I would like to get the coefficient of polynomial expansion. For example,

(1+ x)^2 = 1 + 2x + x^2, and the coefficients are 1, 2 and 1.
(1 + x + x^2)^3 = 1 + 3*x + 6*x^2 + 7*x^3 + 6*x^4 + 3*x^5 + x^6, and
the coefficients are 1, 3, 6, 7, 6, 3, and 1.

I know that we can use polynom library. Is there any other way to do
it without loading a library.

Thanks a lot for your help.


Peter
#
On 8/8/05, Peter Yang <peterwyang at gmail.com> wrote:
Use symbolic differentiation as in:

https://stat.ethz.ch/pipermail/r-help/2004-December/060797.html
#
Peter> Hi, I would like to get the coefficient of polynomial
    Peter> expansion. For example,

    Peter> (1+ x)^2 = 1 + 2x + x^2, and the coefficients are 1,
    Peter> 2 and 1.  (1 + x + x^2)^3 = 1 + 3*x + 6*x^2 + 7*x^3 +
    Peter> 6*x^4 + 3*x^5 + x^6, and the coefficients are 1, 3,
    Peter> 6, 7, 6, 3, and 1.

    Peter> I know that we can use polynom library. Is there any
    Peter> other way to do it without loading a library.

yes, load the polynom *package*  (from the library where the
		      ---------   *package* is installed)

What's bad about using polynom?  IMO it is very nice, very useful
package for the purpose it was written.

Using packages for tasks they were written is one of the
strengths of the R project, 
so why are you reluctant?

Martin