014. Integral to Simplify

Simplify the expression, $\sum\limits_{k = 1}^n \cot \left( x + \cfrac{(k - 1)\pi}{n} \right)$, using the following identity.

\begin{aligned} \sin \left( \cfrac{nx}{2^{n-1}} \right) = \prod_{k = 1}^{n} \sin \left( x + \cfrac{(k-1)\pi}{n} \right) \end{aligned}

There are steps that are hard to come up with to solve this problem. First, taking a logarithm of both sides of the identity, \begin{aligned} \ln \sin \left( \cfrac{nx}{2^{n-1}} \right) = \sum_{k = 1}^{n} \ln \sin \left( x + \cfrac{(k-1)\pi}{n} \right) \end{aligned}

Now, integrating the expression, \begin{aligned} \int \sum_{k = 1}^n \cot \left( x + \cfrac{(k - 1)\pi}{n} \right) &= \int \sum_{k = 1}^n \cfrac{\cos \left( x + \cfrac{(k - 1)\pi}{n} \right)}{\sin \left( x + \cfrac{(k - 1)\pi}{n} \right)} \\ &= \sum_{k = 1}^{n} \ln \sin \left( x + \cfrac{(k-1)\pi}{n} \right) = \ln \sin \left( \cfrac{nx}{2^{n-1}} \right) \end{aligned}

Differentiating both sides again, \begin{aligned} \sum_{k = 1}^n \cot \left( x + \cfrac{(k - 1)\pi}{n} \right) = \cfrac{\cos \left( \cfrac{nx}{2^{n-1}} \right)}{\sin \left( \cfrac{nx}{2^{n-1}} \right)} \cdot \cfrac{n}{2^{n-1}} = \cfrac{n}{2^{n-1}} \cot \left( \cfrac{nx}{2^{n-1}} \right) \end{aligned}