Sunday, 15 December 2013

sequences and series - Calculate $C_n = sum_{k=0}^{n} cosleft(dfrac{2kpi}{2n+1}right)$ (Python being my assistant)

I'm trying to calculate the following sum: $C_n = \sum_{k=0}^{n} \cos\left(\dfrac{2k\pi}{2n+1}\right)$



In order to get hints, I programmed the following code in Python:






from math import *
def C(k,n):
return cos((2*k*pi)/(2*n+1))

S = 0.0
n = int(input("choose a value for n: "))

while(True):
for k in range(n+1):

S += C(k,n)
print('step ', k,' is S = ',S)
S = 0.0
print('\n\n')
n = int(input("choose a value for n: "))


The sums all end up equal to 0.5.
Wolfram Alpha agrees.




I..don't.. I tried to express the cosine as $\dfrac{e^{i\frac{2k\pi}{2n+1}}+e^{-i\frac{2k\pi}{2n+1}}}{2}$, then extract the $k$ as a power like so: $\sum_{k=0}^{n}\dfrac{ \left( e^{i\frac{2\pi}{2n+1} }\right)^k+ \left(e^{-i\frac{2\pi}{2n+1}} \right)^k }{2}$



$= \dfrac{1}{2} \sum_{k=0}^{n} \left(e^{i\frac{2\pi}{2n+1}}\right)^k +\left(e^{-i\frac{2\pi}{2n+1}} \right)^k$



That way, if I'm correct, those two terms are each a sum of terms of a geometric series. While a $\dfrac{1}{2}$ does appear later on as separate term, this approach seems to create more problems than it solves.



I would be grateful for any pointers :)
Thanks in advance.

No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...