Re: Extracting terms of a polynomial into a list and then multiply
- To: mathgroup at smc.vnet.net
- Subject: [mg90381] Re: Extracting terms of a polynomial into a list and then multiply
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 8 Jul 2008 02:24:10 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <g4sm99$p$1@smc.vnet.net>
Bob F wrote:
> Can anyone suggest a way to extract the terms of a polynomial into a
> list. For example the integral of the series expansion of
>
> 1
> --------------------
> (1 - t^2) ^(1/2)
>
> could be expressed in Mathematica (the first 50 terms) as
>
> Integrate[Normal[Series[(1 - t^2)^(-1/2), {t, 0, 50}]], {t, 0,
> x}]
>
> and gives the polynomial
>
> x + x^3/6 + (3 x^5)/40 + (5 x^7)/112 + (35 x^9)/1152 + (63 x^11)/
> 2816 + (231 x^13)/13312 + (143 x^15)/10240 +
> (6435 x^17)/557056 + (12155 x^19)/1245184 + (46189 x^21)/
> 5505024 + . . .
Let's call the above expression "poly".
> And I would like to extract each term of this polynomial into a list
> like
>
> { x, x^3/6, (3 x^5)/40, (5 x^7)/112, (35 x^9)/1152, (63 x^11)/
> 2816, (231 x^13)/13312, (143 x^15)/10240,
> (6435 x^17)/557056, (12155 x^19)/1245184, (46189 x^21)/
> 5505024, . . . }
Then, we change the *head* of the expression poly to a List thanks to
the command Apply:
List @@ poly
> Then I would like to take this list and multiply each element in the
> list by the integrated polynomial in order to get a list of
> polynomials that shows all of the components of the fully multiplied
> polynomial in an expanded form. In other words I would like to show
> the term by term expansion of the integral multiplied by itself, ie
>
> Expand[ Integrate[Normal[Series[(1 - t^2)^(-1/2), {t, 0, 50}]],
> {t, 0, x}] *
> Integrate[Normal[Series[(1 - t^2)^(-1/2), {t, 0,
> 50}]], {t, 0, x}]]
>
> Was working thru an example of what Euler did to compute Zeta[2] and
> was looking for patterns in the polynomial coefficients.
The result you are looking for should be
Expand[terms*poly]
since lists (terms) are automatically *threaded* over a single
expression (poly) when multiplied (Times), and Expand is *listable*,
i.e. it is automatically applied to each element of a list.
The resulting one-liner is
(Expand[List @@ #1*#1] & )[Integrate[
Normal[Series[(1 - t^2)^(-2^(-1)), {t, 0, 50}]], {t, 0, x}]]
Here is a detailed example (with the first 10 terms of the series
expansion).
In[1]:= poly = Integrate[Normal[Series[(1 - t^2)^(-2^(-1)), {t, 0,
10}]], {t, 0, x}]
Out[1]=
3 5 7 9 11
x 3 x 5 x 35 x 63 x
x + -- + ---- + ---- + ----- + ------
6 40 112 1152 2816
In[2]:= terms = List @@ poly
Out[2]=
3 5 7 9 11
x 3 x 5 x 35 x 63 x
{x, --, ----, ----, -----, ------}
6 40 112 1152 2816
In[3]:= Expand[terms*poly]
Out[3]=
4 6 8 10 12
2 x 3 x 5 x 35 x 63 x
{x + -- + ---- + ---- + ------ + ------,
6 40 112 1152 2816
4 6 8 10 12 14
x x x 5 x 35 x 21 x
-- + -- + -- + ----- + ------ + ------,
6 36 80 672 6912 5632
6 8 10 12 14 16
3 x x 9 x 3 x 7 x 189 x
---- + -- + ----- + ----- + ----- + -------,
40 80 1600 896 3072 112640
8 10 12 14 16 18
5 x 5 x 3 x 25 x 25 x 45 x
---- + ----- + ----- + ------ + ------ + ------,
112 672 896 12544 18432 45056
10 12 14 16 18 20
35 x 35 x 7 x 25 x 1225 x 245 x
------ + ------ + ----- + ------ + -------- + -------,
1152 6912 3072 18432 1327104 360448
12 14 16 18 20 22
63 x 21 x 189 x 45 x 245 x 3969 x
------ + ------ + ------- + ------ + ------- + --------}
2816 5632 112640 45056 360448 7929856
Regards,
-- Jean-Marc