       Re: accumulate coefficients of a polynomial

• To: mathgroup at smc.vnet.net
• Subject: [mg102831] Re: [mg102813] accumulate coefficients of a polynomial
• From: Leonid Shifrin <lshifr at gmail.com>
• Date: Fri, 28 Aug 2009 05:43:04 -0400 (EDT)
• References: <200908280444.AAA28832@smc.vnet.net>

```Hi,

this will give you the general form of coefficients in terms of rules:

In =
Clear[k];
coeffRules =  List @@ ComplexExpand[Re[p[Exp[I Pi/k]]]] /.  x_a*y : _ : 1 :>
(x :> y)

Out = {a:>1,a:>Cos[\[Pi]/k],a:>Cos[(2 \[Pi])/k],a:>Cos[(3
\[Pi])/k],a:>Cos[(4 \[Pi])/k],a:>Cos[(5 \[Pi])/k],a:>Cos[(6
\[Pi])/k],a:>Cos[(7 \[Pi])/k],a:>Cos[(8 \[Pi])/k],a:>Cos[(9
\[Pi])/k],a:>Cos[(10 \[Pi])/k]}

This will compute the matrix of vectors of coefficients for 1<=k<=5 (5
instead of 20 just to keep
the output size reasonable):

In = Table[Array[a, {10}] /. coeffRules, {k, 1, 5}]

Out =
{{-1,1,-1,1,-1,1,-1,1,-1,1},{0,1,0,-1,0,1,0,-1,0,1},{-1,-(1/2),1/2,1,1/2,-(1/2),-1,-(1/2),1/2,1},{1/Sqrt,1,1/Sqrt,0,-(1/Sqrt),-1,-(1/Sqrt),0,1/Sqrt,1},{1/4
(1+Sqrt),1/4 (-1+Sqrt),1/4 (1-Sqrt),1/4 (-1-Sqrt),-1,1/4
(-1-Sqrt),1/4 (1-Sqrt),1/4 (-1+Sqrt),1/4 (1+Sqrt),1}}

Regards,
Leonid

On Fri, Aug 28, 2009 at 8:44 AM, BHUPALA <bhupala at gmail.com> wrote:

> I have generated a polynomial as
>
> p[z_] = Sum[a[k]*z^(10 - k), {k, 0, 10}]
>
> to give
>
> z^10 a + z^9 a + z^8 a + z^7 a + z^6 a + z^5 a +
>  z^4 a + z^3 a + z^2 a + z a + a
>
> I want to substitute z = Exp[I Pi/k] where k varies from 1 to 20 and
> for each k retain the coefficients of the real part as a vector.
>
> I used the following command for a single iteration (e.g k=6)
>
> ComplexExpand[Re[p[Exp[I Pi/6]]]]]
>
> But how to do it in a loop?
>
> Thanks for any help.
>
> Bhupala
>
>

```

• Prev by Date: Re: ClearAll ?? or what
• Next by Date: if only on parameter of 2D is to be shown in 3D
• Previous by thread: Re: accumulate coefficients of a polynomial
• Next by thread: no StateData[] ?