Expression for Jacobi theta function derivative Please explain how to get $$\frac{\vartheta'_{1}(z, q)}{\vartheta_{1}(z, q)} = \cot z + 4\sum_{n = 1}^{\infty}\frac{q^{2n}}{1 - q^{2n}}\sin 2nz$$ where $\vartheta_{1}(z, q)$ is one of the Jacobi theta functions. Thanks!
 A: The infinite product representation for $\vartheta_{1}(z, q)$ given by $$\vartheta_{1}(z, q) = 2q^{1/4}\sin z\prod_{n = 1}^{\infty}(1 - q^{2n})(1 - 2q^{2n}\cos 2z + q^{4n})\tag{1}$$ I hope you are familiar with the above result. Taking logs we get
\begin{align}\log\vartheta_{1}(z, q) &= \log(2q^{1/4}) + \log\sin z + \log\prod_{n = 1}^{\infty}(1 - q^{2n})\notag\\
&\,\,\,\,\,\,\,\, + \sum_{n = 1}^{\infty}\log(1 - 2q^{2n}\cos 2z + q^{4n})\tag{2}
\end{align}
and differentiating with respect to $z$ we get
\begin{align}
\frac{\vartheta'_{1}(z, q)}{\vartheta_{1}(z, q)} &= \cot z + 4\sum_{n = 1}^{\infty}\frac{q^{2n}\sin 2z}{1 - 2q^{2n}\cos 2z + q^{4n}}\notag\\
&= \cot z + \frac{4}{2i}\sum_{n = 1}^{\infty}\frac{q^{2n}(e^{2iz} - e^{-2iz})}{(1 - q^{2n}e^{2iz})(1 - q^{2n}e^{-2iz})}\notag\\
&= \cot z + \frac{4}{2i}\sum_{n = 1}^{\infty}q^{2n}\left(\frac{e^{2iz}}{1 - q^{2n}e^{2iz}} - \frac{e^{-2iz}}{1 - q^{2n}e^{-2iz}}\right)\notag\\
&= \cot z + \frac{4}{2i}\left(\sum_{n = 1}^{\infty}\frac{q^{2n}e^{2iz}}{1 - q^{2n}e^{2iz}} - \sum_{n = 1}^{\infty}\frac{q^{2n}e^{-2iz}}{1 - q^{2n}e^{-2iz}}\right)\notag\\
&= \cot z + \frac{4}{2i}\left(\sum_{n = 1}^{\infty}\sum_{m = 1}^{\infty}\{q^{2n}e^{2iz}\}^{m} - \sum_{n = 1}^{\infty}\sum_{m = 1}^{\infty}\{q^{2n}e^{-2iz}\}^{m}\right)\notag\\
&= \cot z + \frac{4}{2i}\left(\sum_{n = 1}^{\infty}\sum_{m = 1}^{\infty}q^{2m}e^{2imz}q^{2m(n - 1)}\right. \notag\\
&\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, \left. - \sum_{n = 1}^{\infty}\sum_{m = 1}^{\infty}q^{2m}e^{-2imz}q^{2m(n - 1)}\right)\notag\\
&= \cot z + \frac{4}{2i}\left(\sum_{m = 1}^{\infty}q^{2m}e^{2imz}\sum_{n = 1}^{\infty}q^{2m(n - 1)}\right.\notag\\
&\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, \left. - \sum_{m = 1}^{\infty}q^{2m}e^{-2imz}\sum_{n = 1}^{\infty}q^{2m(n - 1)}\right)\notag\\
&= \cot z + \frac{4}{2i}\left(\sum_{m = 1}^{\infty}\frac{q^{2m}e^{2imz}}{1 - q^{2m}} - \sum_{m = 1}^{\infty}\frac{q^{2m}e^{-2imz}}{1 - q^{2m}}\right)\notag\\
&= \cot z + 4\sum_{n = 1}^{\infty}\frac{q^{2n}}{1 - q^{2n}}\sin 2nz\tag{3}\end{align}

The above proof is taken from one of my blog posts (see equation $(25)$ of that post).
