I was practising questions on principles on mathematics. I stumbled onto this question and I don't know where to start. Can anyone please help??
If $P_1P_2....P_n$ is a regular polygon in the $(x,y)$-plane, each side of length a (so the $P_i$ are the corners of an $n$-sided figure with sides of equal length $a$). Find the sum $$ S = (P_1P_2)^2 + (P_1P_3)^2 + \dots + (P_1P_n)^2; $$ here $P_1P_j$ stands for the length of the line form the point $P_1$ to the point $P_j$ (your expression for $S$ will be a function of $a$, $n$ and also a well-known trigonometric function).

Let $\zeta\in\mathbb C$ be a primitive $n$th root of unity. Then in the specaial case that $a=|\zeta-1|$, we have $$S=\sum_{k=1}^n|\zeta^k-1|^2=\sum_{k=1}^n(2-\zeta^k-\bar\zeta^k)=2n.$$ Hence in general $$ S = \frac{2a^2n}{|\zeta-1|^2}.$$ Note that $|\zeta-1|=2\sin\frac\pi n$, so that ultimately $$ S = \frac{a^2n}{2\sin^2\frac\pi n}.$$