TITLE: How did Euler prove the partial fraction expansion of the cotangent function: $\pi\cot(\pi z)=\frac1z+\sum_{k=1}^\infty(\frac1{z-k}+\frac1{z+k})$?
QUESTION [5 upvotes]: As far as we know, Euler was the first to prove $$ \pi \cot(\pi z) = \frac{1}{z} + \sum_{k=1}^\infty \left( \frac{1}{z-k} + \frac{1}{z+k} \right).$$ I've seen several modern proofs of it and they all seem to rely either on the Herglotz trick or on the residue theorem. I recon Euler had neither nor at his disposal, so how did he prove it?
Added: Did Euler prove it for complex $z$ or just reals?

REPLY [4 votes]: Euler did have access to the infinite product representation of the sine function
$$\sin(\pi z)=\pi z\prod_{n=1}^{\infty}\left(1-\frac{z^2}{n^2}\right)$$
Then, we have
$$\begin{align}
\frac{d \log(\sin(\pi z))}{dz}&=\pi \cot(\pi z)\\\\
&=\frac1z+\sum_{n=1}^\infty \frac{2z}{z^2-n^2}\\\\
&=\frac1z+\sum_{n=1}^\infty \left(\frac{1}{z-n}+\frac{1}{z+n}\right)\\\\
\end{align}$$
as was to be shown!