       Re: Polynomial to List

• To: mathgroup at smc.vnet.net
• Subject: [mg76952] Re: [mg76897] Polynomial to List
• From: Murray Eisenberg <murray at math.umass.edu>
• Date: Wed, 30 May 2007 05:32:35 -0400 (EDT)
• Organization: Mathematics & Statistics, Univ. of Mass./Amherst
• References: <200705290907.FAA04110@smc.vnet.net>
• Reply-to: murray at math.umass.edu

```First, let's make the problem a bit more complicated by looking at, say,
the polynomial:

p = c + k x - 7 x^2 + x^3 + Pi x^4

Now how does Mathematica parse that?  Use FullForm:

FullForm[p]
Plus[c,Times[k,x],Times[-7,Power[x,2]],Power[x,3],Times[Pi,Power[x,4]]]

Thus the structure is Plus[...] where the argument of Plus is a sequence
of the various terms. You want a list consisting of these terms, so a
way to do it is to change Plus to List.  The Apply function does this:

Apply[List,p]
{c, k*x, -7*x^2, x^3, Pi*x^4}

(There, and below, I show the linear, 1-dimensional InputForm of the 2D
standard form in which Mathematica would display the output.)

Finally, if you want to save some punctuation, use the @@ input form for
Apply, like this:

List@@p
{c, k*x, -7*x^2, x^3, Pi*x^4}

Finally, reverse the order of the terms by using -- what else? -- Reverse:

Reverse[List@@p]
{Pi*x^4, x^3, -7*x^2, k*x, c}

Nick Hoffman wrote:
> I have a polynomial,
> Lets say:
>
> 1 + x + x^2 + x^3 + x^4
>
>
> and all I need to do is get that into a list of this form
>
> {x^4, x^3, x^2, x, 1}
>
> Any help would be greatly appreciated!  Thanks!
>
>

--
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

```

• Prev by Date: Re: Re: Stopping Automatic Animation in v6
• Next by Date: Re: Re: asymptotics
• Previous by thread: RE: Polynomial to List
• Next by thread: Re: Polynomial to List