# The Magic of Theta Functions

### Introduction

Theta functions were originally introduced by Carl Gustav Jacob Jacobi while studying elliptic functions (which are in turn related to elliptic integrals). These functions are also connected with number theory and they have many interesting properties besides. Since they are related to elliptic integrals and we have seen in a previous post that the elliptic integrals are related to the AGM (arithmetic-geometric mean), it follows that the theta functions are related to the AGM. We will cover these topics in this series of posts and will also mention some number theoretic applications of theta functions.

### Theta Functions

We define three theta functions as follows: \begin{align} \theta_{2}(q) &= \sum_{n = -\infty}^{\infty}q^{(n + 1/2)^{2}} = 2(q^{1/4} + q^{9/4} + q^{25/4} + \cdots )\notag\\ \theta_{3}(q) &= \sum_{n = -\infty}^{\infty}q^{n^{2}} = 1 + 2q + 2q^{4} + 2q^{9} + \cdots \notag\\ \theta_{4}(q) &= \sum_{n = -\infty}^{\infty}(-1)^{n}q^{n^{2}} = 1 - 2q + 2q^{4} - 2q^{9} + \cdots\notag \end{align} (surprisingly we have omitted $\theta_{1}(q)$ above. In fact we are presenting a simplified version of theta functions. The theta functions are functions of two variables one of which we have put as zero and while doing so the function $\theta_{1}$ vanishes identically.)

In the above definitions the parameter $q$ is a real variable with $|q| < 1$. The limitation $|q| < 1$ is needed for convergence and in this case the series defining various theta functions are absolutely convergent. We have restricted ourselves to the real variable $q$ as we don't need the whole "analytic function" machinery for our purposes here. The connection with number theory comes from the fact that the indexes of $q$ are perfect squares (in case of $\theta_{3}(q)$ and $\theta_{4}(q)$).

### Properties of Theta Functions

Theta functions have remarkable properties in the sense that there are lot (lot here means comparatively too many) of algebraical relations between. We shall study some of these properties which are relevant to this post.

Clearly we can see that $$\theta_{4}(q) = \theta_{3}(-q)\tag{1}$$ And we have \begin{align} \theta_{3}(q) + \theta_{4}(q) &= 2 + 4q^{4} + 4q^{16} + 4q^{36} + \cdots\notag\\ &= 2(1 + 2(q^{4})^{1} + 2(q^{4})^{4} + 2(q^{4})^{9} + \cdots)\notag \end{align} so that $$\theta_{3}(q) + \theta_{4}(q) = 2\theta_{3}(q^{4})\tag{2}$$ and similarly $$\theta_{3}(q) - \theta_{4}(q) = 2\theta_{2}(q^{4})\tag{3}$$ If we consider the square of theta functions, for example $\theta^{2}_{3}(q)$, we have $$\theta^{2}_{3}(q) = \sum_{i,\, j = -\infty}^{\infty}q^{i^{2} + j^{2}} = \sum_{n = 0}^{\infty}r_{2}(n)q^{n}$$ and (on replacing $q$ by $-q$) $$\theta^{2}_{4}(q) = \sum_{n = 0}^{\infty}(-1)^{n}r_{2}(n)q^{n}$$ where $r_{2}(n)$ denotes the number of ways in which the integer $n$ can be written as a sum of two squares (counting sign as well as order, so that $$10 = (\pm 1)^{2} + (\pm 3)^{2} = (\pm 3)^{2} + (\pm 1)^{2}$$ and therefore $r_{2}(10) = 8$).

On adding above two equations we get $$\theta^{2}_{3}(q) +\theta^{2}_{4}(q) = 2\sum_{n = 0}^{\infty}r_{2}(2n)q^{2n}$$ We note that if $n$ can be written as a sum of two squares like $n = a^{2} + b^{2}$ then $2n$ can also be written in this way as $2n = 2(a^{2} + b^{2}) = (a + b)^{2} + (a - b)^{2}$ and the argument can be reversed so that $r_{2}(2n) = r_{2}(n)$.

Thus we have $$\theta^{2}_{3}(q) +\theta^{2}_{4}(q) = 2\sum_{n = 0}^{\infty}r_{2}(n)q^{2n}$$ and therefore $$\theta^{2}_{3}(q) +\theta^{2}_{4}(q) = 2\theta^{2}_{3}(q^{2})\tag{4}$$ Further we note that \begin{align} 2\theta_{3}(q)\theta_{4}(q) &= (\theta_{3}(q) +\theta_{4}(q))^{2} - (\theta^{2}_{3}(q) +\theta^{2}_{4}(q))\notag\\ &= 4\theta^{2}_{3}(q^{4}) - 2\theta^{2}_{3}(q^{2})\notag\\ &\,\,\,\,\,\,\,\,\text{(using properties }(2)\text{ and }(4)\text{ above)}\notag\\ &= 2(2\theta^{2}_{3}(q^{4}) - \theta^{2}_{3}(q^{2}))\notag\\ &= 2\theta^{2}_{4}(q^{2})\notag \end{align} (using property $(4)$ above with $q$ replace by $q^{2}$) and thus $$\theta_{3}(q)\theta_{4}(q) = \theta^{2}_{4}(q^{2})\tag{5}$$ Again we have \begin{align} \theta^{2}_{3}(q) - \theta^{2}_{3}(q^{2}) &= \sum_{n = 0}^{\infty}r_{2}(n)q^{n} - \sum_{n = 0}^{\infty}r_{2}(n)q^{2n}\notag\\ &= \sum_{n = 0}^{\infty}r_{2}(n)q^{n} - \sum_{n = 0}^{\infty}r_{2}(2n)q^{2n}\text{ (as }r_{2}(n) = r_{2}(2n))\notag\\ &= \sum_{n = 0}^{\infty}r_{2}(2n + 1)q^{2n + 1}\notag\\ &= \sum_{t,\,u = -\infty,\, t^{2} + u^{2} \text{ odd}}^{\infty}q^{t^{2} + u^{2}}\notag\\ &= \sum_{t,\,u = -\infty,\, t+ u \text{ odd}}^{\infty}q^{t^{2} + u^{2}}\notag \end{align} If we put $t = i - j$ and $u = i + j + 1$ we see that $t + u$ is odd and for every given value of $t, u$ the integers $i, j$ are uniquely determined and vice versa. Also in this case we have \begin{align} t^{2} + u^{2} &= (i - j)^{2} + (i + j + 1)^{2}\notag\\ &= 2\left(i^{2} + j^{2} + i + j + \frac{1}{2}\right)\notag\\ &= 2\left(\left(i + \frac{1}{2}\right)^{2} + \left(j + \frac{1}{2}\right)^{2}\right)\notag \end{align} Thus we have $$\theta^{2}_{3}(q) - \theta^{2}_{3}(q^{2}) = \sum_{i,\, j = -\infty}^{\infty}(q^{2})^{\left(i + \frac{1}{2}\right)^{2} + \left(j + \frac{1}{2}\right)^{2}} = \theta^{2}_{2}(q^{2})$$ so that $$\theta^{2}_{3}(q^{2}) + \theta^{2}_{2}(q^{2}) = \theta^{2}_{3}(q)\tag{6}$$ Replacing $\theta^{2}_{3}(q)$ from property $(4)$ in above we get $$\theta^{2}_{2}(q^{2}) + \theta^{2}_{3}(q^{2}) = 2\theta^{2}_{3}(q^{2}) - \theta^{2}_{4}(q)$$ or $$\theta^{2}_{3}(q^{2}) - \theta^{2}_{2}(q^{2}) = \theta^{2}_{4}(q)\tag{7}$$ Multiplying $(6)$ and $(7)$ we get $$\theta^{4}_{3}(q^{2}) - \theta^{4}_{2}(q^{2}) = \theta^{2}_{3}(q)\theta^{2}_{4}(q)$$ and using property $(5)$ we get $$\theta^{4}_{3}(q^{2}) - \theta^{4}_{2}(q^{2}) = \theta^{4}_{4}(q^{2})$$ Thus on replacing $q^{2}$ by $q$ we get $$\theta^{4}_{4}(q) + \theta^{4}_{2}(q) = \theta^{4}_{3}(q)\tag{8}$$ We are now in a position to relate theta functions with AGM.

### Theta Functions and the AGM

Let us set $a = a_{0} = \theta^{2}_{3}(q)$ and $b = b_{0} = \theta^{2}_{4}(q)$ and in general $$a_{n} = \theta^{2}_{3}(q^{2^{n}}),\,\,\, b_{n} = \theta^{2}_{4}(q^{2^{n}})$$ so that \begin{align} \frac{a_{n} + b_{n}}{2} &= \frac{\theta^{2}_{3}(q^{2^{n}}) + \theta^{2}_{4}(q^{2^{n}})}{2}\notag\\ &= \frac{\theta^{2}_{3}(p) + \theta^{2}_{4}(p)}{2}\text{ (putting }p = q^{2^{n}})\notag\\ &= \theta^{2}_{3}(p^{2}) = \theta^{2}_{3}(q^{2^{n + 1}}) = a_{n + 1}\text{ (from property }(4)\text{ above)}\notag \end{align} and \begin{align} \sqrt{a_{n}b_{n}} &= \sqrt{\theta^{2}_{3}(q^{2^{n}})\theta^{2}_{4}(q^{2^{n}})}\notag\\ &= \theta_{3}(q^{2^{n}})\theta_{4}(q^{2^{n}})\notag\\ &= \theta_{3}(p)\theta_{4}(p)\text{ (putting }p = q^{2^{n}})\notag\\ &= \theta^{2}_{4}(p^{2}) = \theta^{2}_{4}(q^{2^{n + 1}}) = b_{n + 1}\text{ (using property }(5)\text{ above)}\notag \end{align} It therefore turns out that the sequences $\{a_{n}\}$ and $\{b_{n}\}$ form an AGM sequence and therefore tend to a common limit and in this case the common limit is clearly $\theta^{2}_{3}(0) = 1$. Therefore we have $$M(a, b) = M(\theta^{2}_{3}(q), \theta^{2}_{4}(q)) = 1$$ or $$M\left(1, \frac{\theta^{2}_{4}(q)}{\theta^{2}_{3}(q)}\right) = \theta^{-2}_{3}(q)\tag{9}$$ Let $$k = k(q) = \frac{\theta^{2}_{2}(q)}{\theta^{2}_{3}(q)}$$ and $$\displaystyle k' = k'(q) = \frac{\theta^{2}_{4}(q)}{\theta^{2}_{3}(q)}$$ so that using property $(8)$ we have $0 < k,\,k' < 1$ and $$k^{2} + {k^{\prime}}^{2} = 1$$ and therefore from $(9)$ we get $$M(1, k') = \theta^{-2}_{3}(q)$$ Since $$M(1, k') = M(1, \sqrt{1 - k^{2}}) = M(1 + k, 1 - k) = \frac{\pi}{2K(k)}$$ where $K(k)$ is complete elliptic integral of first kind, we have $$K(k) = \frac{\pi}{2}\theta^{2}_{3}(q)\tag{10}$$ In the above we see that starting from a $q$ with $|q| < 1$ we obtain a unique parameter $k$ as an expression in theta functions of $q$ and the complete elliptic integral $K(k)$ also gets expressed in terms of  theta functions of $q$. When the parameter $k$ is related with $q$ in this fashion we call $q$ as the nome. We will see in the next post that given the parameter $k$ with $0 < k < 1$ there is a unique nome $q$ associated with $k$.