How to prove identity $\sum_{k=0}^{n-1}\tan^2\left(\theta+{k\pi\over n}\right)=n^2\cot^2\left({n\pi\over2}+n\theta\right)+n(n-1)$? Looking at Jolley, Summation of Series, formula 445:
$\sum_{k=0}^{n-1}\tan^2\left(\theta+{k\pi\over n}\right)=n^2\cot^2\left({n\pi\over2}+n\theta\right)+n(n-1)$
How can one prove this?
Considering $\left(  \sum^{n-1}_{j=0}Z_j\right)^2 = \sum^{n-1}_{j=0} Z_j^2 +\sum^{n-1}_{j=0}\sum^{n-1}_{i\neq j} Z_jZ_i$ from here
I thought one could take the log differential of the well known sine product:
$\begin{align}
\prod_{k=0}^{n-1}\sin\left(\theta + \frac{k\pi}{n}\right)
&= 2^{1-n} \sin(n\theta)
\end{align}$
to get
$n \cot(n\theta) = \sum_{k=0}^{n-1}\cot\left(\theta+\frac{k\pi}{n}\right)$
or
$-n \cot(\frac{n\pi}{2}+n\theta) = \sum_{k=0}^{n-1}\tan\left(\theta+\frac{k\pi}{n}\right)$
then square to get
$n^2 \cot(\frac{n\pi}{2}+n\theta)^2 = (\sum_{k=0}^{n-1}\tan\left(\theta+\frac{k\pi}{n})\right)^2$
but I cannot see how to show the
$\sum _{j=0}^{n-1} \sum _{k=0}^{n-1} \tan \left(\theta +\frac{\pi  j}{n}\right) \tan \left(\theta +\frac{\pi  k}{n}\right) [j\neq k]$
necessary for the $n(n-1)$ part of the identity.
Perhaps somebody could show a more successful method.

If $\frac{2n\theta}{\pi}$ is an odd integer, one $\tan^2$ value in the sum is undefined (or "infinity"), so assume that's not the case.
$$ z = \tan \left(\theta + \frac{k\pi}{n}\right); 0 \leq k \leq n-1 $$
satisfy $\arg(z+i) = \frac{\pi}{2} + \theta + \frac{k\pi}{n}$. Defining $\alpha = \theta + \frac{\pi}{2}$ just for brevity, this is $\arg(z+i) = \alpha + \frac{k\pi}{n}$. These $n$ values of $z$ also satisfy
$$ \operatorname{Im}\left(\left((z+i)e^{-i\alpha}\right)^n\right) = 0$$
$$\left(((z+i)e^{-i\alpha}\right)^n - \left((z-i)e^{i\alpha}\right)^n = 0$$
Since this is a polynomial in $z$ of degree $n$ (call it $p$), there are no other solutions, and
$$ \begin{align*}
p(z) &= (z+i)^n e^{-in\alpha} - (z-i)^n e^{in\alpha} \tag{1}\label{1} \\
p(z) &= (e^{-in\alpha} - e^{in\alpha})\prod_{k=0}^{n-1} \left(z-\tan\left(\theta+\frac{k\pi}{n}\right)\right) \\
p(z) &= -2i \sin(n\alpha) \prod_{k=0}^{n-1} \left(z-\tan\left(\theta+\frac{k\pi}{n}\right)\right) \tag{2}\label{2}
\end{align*} $$
Now augment the polynomial's set of roots by the negatives of its $n$ roots, to get polynomial $q(z) = (-1)^n p(z)p(-z)$. From $\ref{1}$:
$$ \begin{align*} (-1)^n q(z) &= \left((z+i)^n e^{-in\alpha} - (z-i)^n e^{in\alpha}\right)\left((-z+i)^n e^{-in\alpha} - (-z-i)^n e^{in\alpha}\right) \\
q(z) &= (z^2+1)^n e^{-2in\alpha} - (z-i)^{2n} - (z+i)^{2n} + (z^2+1)^n e^{2in\alpha} \\
q(z) &= 2(z^2+1)^n \cos(2n\alpha) - (z+i)^{2n} - (z-i)^{2n} \tag{3}\label{3} \end{align*} $$
From $\ref{2}$:
$$ \begin{align*}
(-1)^n q(z) &= -4 \sin^2(n\alpha) \prod_{k=0}^{n-1} \left(z-\tan\left(\theta+\frac{k\pi}{n}\right)\right) \left(- z - \tan\left(\theta + \frac{k\pi}{n}\right)\right) \\
q(z) &= -4 \sin^2(n\alpha) \prod_{k=0}^{n-1} \left(z^2 - \tan^2\left(\theta + \frac{k\pi}{n}\right) \right) \tag{4}\label{4}
 \end{align*} $$
Now to get the sum of the $\tan^2$ values, equate the coefficients of $z^{2n-2}$ in $\ref{4}$ and $\ref{3}$:
$$ \begin{align*}
a_{2n-2} &= 4 \sin^2(n\alpha) \sum_{k=0}^{n-1} \tan^2\left(\theta + \frac{k\pi}{n}\right) \\
a_{2n-2} &= 2{n \choose 1} \cos(2n\alpha) - {2n \choose 2}i^2 - {2n \choose 2}(-i)^2 \\
&= 2n(1-2\sin^2(n\alpha)) + 2n(2n-1) \\
&= -4n \sin^2(n\alpha) + 4n^2
\end{align*} $$
$$ \begin{align*}
\sum_{k=0}^{n-1} \tan^2\left(\theta + \frac{k\pi}{n}\right) &= n^2 \csc^2(n\alpha) - n \\
&= n^2 (1+\cot^2(n\alpha)) - n \\
&= n^2 \cot^2\left(\frac{n\pi}{2} + n\theta\right) + n(n-1)
\end{align*} $$
