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[1] =
Clear[k];
coeffRules =  List @@ ComplexExpand[Re[p[Exp[I Pi/k]]]] /.  x_a*y : _ : 1 :>
(x :> y)

Out[1] = {a[10]:>1,a[9]:>Cos[\[Pi]/k],a[8]:>Cos[(2 \[Pi])/k],a[7]:>Cos[(3
\[Pi])/k],a[6]:>Cos[(4 \[Pi])/k],a[5]:>Cos[(5 \[Pi])/k],a[4]:>Cos[(6
\[Pi])/k],a[3]:>Cos[(7 \[Pi])/k],a[2]:>Cos[(8 \[Pi])/k],a[1]:>Cos[(9
\[Pi])/k],a[0]:>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[2] = Table[Array[a, {10}] /. coeffRules, {k, 1, 5}]

Out[2] =
{{-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[2],1,1/Sqrt[2],0,-(1/Sqrt[2]),-1,-(1/Sqrt[2]),0,1/Sqrt[2],1},{1/4
(1+Sqrt[5]),1/4 (-1+Sqrt[5]),1/4 (1-Sqrt[5]),1/4 (-1-Sqrt[5]),-1,1/4
(-1-Sqrt[5]),1/4 (1-Sqrt[5]),1/4 (-1+Sqrt[5]),1/4 (1+Sqrt[5]),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[0] + z^9 a[1] + z^8 a[2] + z^7 a[3] + z^6 a[4] + z^5 a[5] +
>  z^4 a[6] + z^3 a[7] + z^2 a[8] + z a[9] + a[10]
>
> 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[] ?