# Proving $\left(\sum_{n=-\infty}^\infty q^{n^2} \right)^2 = \sum_{n=-\infty}^\infty \frac{1}{\cos(n \pi \tau)}$

The so-called "two squares theorem" can be proven by establishing the following identity:

$$\left(\sum_{n=-\infty}^\infty e^{\pi i \tau n^2}\right)^2 = \sum_{n=-\infty}^\infty \frac{1}{\cos(n \pi \tau)}$$

where $\Im \tau>0$.

Stein and Shakarchi give a lengthy proof in their complex analysis book. The proof is quite complicated and the motivation is unclear. I would be interested in a more intuitive (or at least concise) proof of the above identity.

• What are $q$ and $\tau$ in the title of this question?
– MPW
Apr 1, 2014 at 1:13
• @MPW By convention, $q = e^{\pi i \tau}$ in the study of elliptic functions. Apr 1, 2014 at 1:15
• I think you would enjoy arxiv.org/abs/math/0611300 and the book Number Theory in the Spirit of Ramanujan by Bruce C. Berndt. Part of what you want is in the book, page 58; he applies this to two squares and some related quadratic forms. Apr 1, 2014 at 2:33
• I'd stick to complex analysis at this point. Clearly enough, it seems like a work of pure residues by looking at the right side sum. I am not sure if clever theta-null identities can help, though. Apr 3, 2014 at 9:41

Below is the shortest proof I know. I would say this proof is motivated insomuch that it is a corollary--albeit not immediate--of the Jacobi triple product.

We proceed a la Ramanujan. The proof is quite elementary, but the algebraic manipulations are a bit tedious. The key ingredient of the proof is the Jacobi triple product: $$\sum_{n \in \mathbb{Z}} q^{n^2} x^n = \prod_{n = 1}^\infty (1 - q^{2n})(1 + q^{2n - 1}x)(1 + q^{2n - 1}x^{-1}), \quad |q| < 1, \quad x \ne 0.$$ Replacing $q$ with $\sqrt{q}$ and letting $x = \sqrt{q}y$ leads to $$\sum_{n \in \mathbb Z} q^{n(n + 1)/2} y^n = \frac{y + 1}{y}\prod_{n = 1}^\infty (1 - q^n)(1 + q^n y)(1 + q^n y^{-1}).$$ Now put $y = -z^2$ so that \begin{align*} \sum_{n \in \mathbb Z} (-1)^n q^{n(n + 1)/2} z^{2n + 1} &= \sum_{n \in \mathbb Z} q^{2n^2 + n} z^{4n + 1} - \sum_{n \in \mathbb Z} q^{2n^2 - n} z^{4n - 1}\\ &= (z - z^{-1})\prod_{n = 1}^\infty (1 - q^n)(1 - q^n z^2)(1 - q^n z^{-2}). \end{align*} Using the Jacobi triple product we can express the sums on the left-hand side as infinite products: \begin{align*} &z\prod_{n = 1}^\infty (1 - q^{4n})(1 + q^{4n - 1} z^4)(1 + q^{4n - 3} z^{-4})\\ &\quad- z^{-1}\prod_{n = 1}^\infty (1 - q^{4n})(1 + q^{4n - 3} z^4)(1 + q^{4n - 1} z^{-4})\\ &= (z - z^{-1})\prod_{n = 1}^\infty (1 - q^n)(1 - q^n z^2)(1 - q^n z^{-2}). \end{align*} If we differentiate both sides logarithmically with respect to $z$ and then set $z = 1$ we get $$1 + 4\sum_{n = 1}^\infty (-1)^n \frac{q^{2n - 1}}{1 + q^{2n - 1}} = \frac{\prod_{n = 1}^\infty (1 - q^n)^3}{\prod_{n = 1}^\infty (1 - q^{4n})(1 + q^{4n - 1})(1 + q^{4n - 3})}.$$ Yet, $$\frac{\prod_{n = 1}^\infty (1 - q^n)^3}{\prod_{n = 1}^\infty (1 - q^{4n})(1 + q^{4n - 1})(1 + q^{4n - 3})} = \frac{\prod_{n = 1}^\infty (1 - q^n)^3}{\prod_{n = 1}^\infty (1 + q^n)(1 - q^{2n})} = \frac{\prod_{n = 1}^\infty (1 - q^n)^2}{\prod_{n = 1}^\infty (1 + q^n)^2} = \theta_4^2(q),$$ where the last equality follows from the Jacobi triple product (use $x = -1$) and Euler's identity: $$(1 + q)(1 + q^2)(1 + q^3)\cdots = \frac{1}{(1 - q)(1 - q^3)(1 - q^5)\cdots}.$$ To prove this identity write $$(1 + q)(1 + q^2)(1 + q^3)\cdots = \frac{(1 + q)(1 - q)(1 + q^2)(1 - q^2)(1 + q^3)(1 - q^3)\cdots}{(1 - q)(1 - q^2)(1 - q^3)\cdots}.$$ Evidently, all the terms of the form $(1 - q^{2n})$ cancel because $(1 + q)(1 - q) = (1 - q^2)$, $(1 + q^2)(1 - q^2) = (1 - q^4)$, etc.

Consequently, $$\theta_4^2(q) = 1 + 4\sum_{n = 1}^\infty (-1)^n \frac{q^{2n - 1}}{1 + q^{2n - 1}},$$ which is equivalent to $$\theta_3^2(q) = 1 + 4\sum_{n = 0}^\infty (-1)^n \frac{q^{2n + 1}}{1 - q^{2n + 1}}$$ as $\theta_4(-q) = \theta_3(q)$. However, $$\sum_{n = 0}^\infty (-1)^n \frac{q^{2n + 1}}{1 - q^{2n + 1}} = \sum_{n = 1}^\infty \frac{q^n}{1 + q^{2n}}$$ because \begin{align*} &(q + q^2 + q^3 + \cdots) - (q^3 + q^6 + q^9 + \cdots) + (q^5 + q^{10} + q^{15} + \cdots) - \cdots\\ &\quad= (q + q^2 + q^3 + \cdots) - (q^3 + q^6 + q^9 + \cdots) + (q^5 + q^{10} + q^{15} + \cdots) - \cdots\\ &\qquad+ (q^3 + q^7 + q^{11} + \cdots) - (q^3 + q^7 + q^{11} + \cdots)\\ &\quad\qquad= q(1 - q^2 + q^4 - \cdots) + q^2(1 - q^4 + q^8 - \cdots) + q^3(1 - q^6 + q^{12} - \cdots) + \cdots \end{align*} Thus $$\theta_3^2(q) = 1 + 4\sum_{n = 1}^\infty \frac{q^n}{1 + q^{2n}} = 1 + 4\sum_{n = 1}^\infty \frac{1}{q^n + q^{-n}} = 2\sum_{n \in \mathbb{Z}} \frac{1}{q^n + q^{-n}} = \sum_{n \in \mathbb{Z}} \frac{1}{\cos(n \pi \tau)}$$ for it is clear that $q^n + q^{-n} = e^{n\pi i \tau} + e^{-n\pi i \tau} = 2\cos(n\pi \tau).$

• I would like to note that this whole thing becomes even more concise if one uses the q-Pochhammer symbol, as is something like standard in the subject.
– user98602
Apr 3, 2014 at 8:49
• The subst has been $y=-z^2$, not $y=z^2$, it seems. Apr 4, 2014 at 23:05
• @ccorn Yes, of course. It was a typo. Thanks for spotting it. Apr 5, 2014 at 1:24
• Oh, and the last line should have all $\tau$ replaced with $n\tau$. Not spotted until now, although I have looked through the whole thing before. Apr 5, 2014 at 2:41
• @ccorn Yes, thanks again. Apr 5, 2014 at 5:17