Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Converting an expression to a list of terms?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71491] Re: Converting an expression to a list of terms?
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Mon, 20 Nov 2006 18:11:55 -0500 (EST)
  • References: <ejrmpc$96l$1@smc.vnet.net>

Something like the following?

E.g.

Factor[1 - x^9, Extension -> (x /. Solve[1 - x^9 == 0])]
(-((-1)^(2/9) - x))*(-1 + (-1)^(1/3) - x)*((-1)^(4/9) - x)*(-(-1)^(2/9)
+ (-1)^(5/9) - x)*(-1 + x)*((-1)^(1/9) + x)*((-1)^(1/3) +
x)*(-(-1)^(1/9) + (-1)^(4/9) + x)*((-1)^(5/9) + x)

List @@ %
{-1, (-1)^(2/9) - x, -1 + (-1)^(1/3) - x, (-1)^(4/9) - x, -(-1)^(2/9) +
(-1)^(5/9) - x, -1 + x, (-1)^(1/9) + x, (-1)^(1/3) + x, -(-1)^(1/9) +
(-1)^(4/9) + x, (-1)^(5/9) + x}

Expand[(1 - x)^9]
1 - 9*x + 36*x^2 - 84*x^3 + 126*x^4 - 126*x^5 + 84*x^6 - 36*x^7 + 9*x^8
- x^9

List @@ %
{1, -9*x, 36*x^2, -84*x^3, 126*x^4, -126*x^5, 84*x^6, -36*x^7, 9*x^8,
-x^9}

Another way

Factor[1 - x^9, Extension -> (x /. Solve[1 - x^9 == 0])] /. (a_)*(b___)
:> {a, b}
{-1, (-1)^(2/9) - x, -1 + (-1)^(1/3) - x, (-1)^(4/9) - x, -(-1)^(2/9) +
(-1)^(5/9) - x, -1 + x,
(-1)^(1/9) + x, (-1)^(1/3) + x,  -(-1)^(1/9) + (-1)^(4/9) + x,
(-1)^(5/9) + x}

Expand[(1 - x)^9] /. (a_) + (b___) :> {a, b}
{1, -9*x, 36*x^2, -84*x^3, 126*x^4, -126*x^5, 84*x^6, -36*x^7, 9*x^8,
-x^9}

Regards
Dimitris




AES wrote:
> How to convert an expression consisting of a sum of terms in an Output
> cell:
>
>    A + B - C + . . .
>
> (where A, B, C are themselves product expressions) to a list
>
>    {A, B, -C, . . . }
>
> in some easier fashion than doing it by hand using Find and Replace?


  • Prev by Date: Re: How to determine whether a message has been switched
  • Next by Date: Send graphics to file AND/OR to notebook with one DisplayFunction
  • Previous by thread: Re: Converting an expression to a list of terms?
  • Next by thread: Best practice for naming of options