Sum of lengths of sides and diagonals

I will very much appreciate if someone can give me a formula for the sum of lengths of all the sides and all the diagonals of a regular n-gon inscribed in a unit circle. Thank you.

-
See this post from a day ago; it discusses a formula for the length of a side of any given 2n-gon inscribed in a circle of radisus R. So you'd use R = 1 for a unit circle. (Note: this only helps with regular polygons with an even number of sides, and is recursive, so it might help to put Andre's info (comment above) and Ross's answer to work!) math.stackexchange.com/questions/222325/… – amWhy Oct 29 '12 at 20:53

Hint: The sides of the regular $n$-gon are chords of the circle, with central angle $\frac {2\pi}n$. The diagonals are also chords, with central angles some multiple of that. Think about how many diagonals come from one vertex.

-

Without loss of generality we may assume that the circle has radius $1$ (if it has radius $r$ we can multiply by $r$). We can also assume that one of the vertices of the polygon is at $(1,0)$. Let $\theta=\frac{2\pi}{n}$. Then the next vertex (counterclockwise) makes an angle of $\theta$ with the $x$-axis, and the next one an angle of $2\theta$, then $3\theta$, all the way to $(n-1)\theta$.

By basic trigonometry, the distance from $(1,0)$ to the first vertex is $\sin(\theta/2)$. The distance from $(1,0)$ to the second vertex is $\sin(2\theta/2)$. Continue. The distance from $(1,0)$ to the last vertex is $\sin((n-1)\theta/2)$. Add up. We get $$\sin \alpha+\sin 2\alpha+\sin 3\alpha+\cdots +\sin (n-1)\alpha,$$ where $\alpha=\dfrac{\pi}{n}$.

There is a pleasantly simple formula for this kind of sum: see here. This formula is most easily proved by using complex numbers, for then we are just dealing with the sum of two geometric progressions. In that formula, let $\varphi=0$, and use $n-1$ instead of $n$. Note that the already quite simple formula simplifies further.

Now repeat this calculation at all $n$ vertices. We get the same number each time. But if we multiply the sum at each vertex by $n$, we will have counted the length of each edge and each diagonal twice. So we take the sum at the first vertex, multiply by $n$ and then divide by $2$.

-
Very nice Andre. Thank you very much! The sum can be simplified to $n\cot(\pi/2n)$. – Martin Oct 29 '12 at 21:53
As I had mentioned, for this special case where we are summing "all the way," the sum of an arithmetic progression of sines simplifies. – André Nicolas Oct 29 '12 at 21:57