Sum of tangent functions where arguments are in specific arithmetic series

By looking through an book, I found this interesting series

To prove that:

$$\tan(\theta)+\tan \left(\theta+ \frac{\pi}{n} \right) + \tan\left(\theta + \frac{2\pi}{n}\right) + \dots + \tan \left (\theta + \frac{(n-1)\pi}{n} \right) = -n\cot \left(\frac{n\pi}{2} + n\theta \right)$$

I have tried the Gaussian pairing trick and using:

$$\tan A + \tan B = \tan(A+B) (1-\tan A \tan B)$$

And

$$\tan A \tan B = \frac{\cos(A-B) - \cos(A+B)}{\cos(A-B)+\cos(A+B)}$$

However I could not do anything of great use.

I also considered perhaps roots of unity of:

$$z^{2n} = \cos \theta + i\sin \theta$$

But that grew to no real use, but it may be an idea for others.

I know I can sum an arithmetic series of the arguments for the cosine and sine functions but I cannot find a source on the internet about the tangent function.

Thank You.


$$\tan rx=\frac{\binom r1\tan x-\binom r3\tan^3x+\cdots}{1-\binom r2\tan^2x+\cdots}\text{ (Proof below) }$$

Now, if $\tan rx=\tan r\theta\implies rx=n\pi+r\theta$ where $n$ is any integer

$\implies x=n\frac{\pi}r+\theta$

If $r$ is even, $=2m$(say) $$\tan2m\theta=\tan2mx=\frac{\binom {2m}1\tan x-\binom {2m}3\tan^3x+\cdots+\binom {2m}{2m-1}(-1)^{m-1}\tan^{2m-1}x}{1-\binom {2m}2\tan^2x+\cdots+(-1)^m\tan^{2m}x}$$

$$\implies (\tan2m\theta)\tan^{2m}x+(2m)\tan^{2m-1}x+\cdots=0$$

This is a $2m$ degree equation in $\tan x$

So, $\sum_{0\le n<2m}\tan\left(n\frac{\pi}r+\theta\right)=-\frac{2m}{\tan 2m\theta}=-2m\cot(2m\theta)$

For $n=2m,-n\cot \left(\frac{n\pi}{2} + n\theta \right)=-2m\cot(m\pi+2m\theta)=-2m\cot(2m\theta)$

Similarly for $n$ is odd


Proof:

Using De Moivre's formula,

$$\sin rx=\binom r1\cos^{r-1}x\sin x-\binom r3\cos^{r-3}x\sin^3x+\binom r5\cos^{r-5}x\sin^5x-\cdots$$ $$=\cos^nx\left(\binom r1 \tan x-\binom r3\tan^3x+\binom r5\tan^5x-\cdots\right)$$ and

$$\cos rx=\cos^rx-\binom r2\cos^{r-2}x\sin^2x+\binom r4\cos^{r-4}x\sin^4x-\cdots$$ $$=\cos^nx\left(1-\binom r2\tan^2x+\binom r4\tan^4x-\cdots\right)$$

On division,

$$\tan rx=\frac{\binom r1\tan x-\binom r3\tan^3x+\binom r5\tan^5x-\cdots}{1-\binom r2\tan^2x+\binom r4\tan^4x-\cdots}$$