1 Introduction

Our primary goal is to give a proof of the following result with very few prerequisites. In general, the special values of theta and allied functions are related to deep topics in number theory (complex multiplication, class field theory, modular forms, elliptic functions, etc., cf. [3,4,5]) which we avoid here.

Theorem 1

Consider \(\theta (z)= \sum _{n\in {\mathbb {Z}}} e^{\pi i n^2 z}\). Then

$$\begin{aligned} \theta (i)=(2\pi )^{-1/4} \sqrt{\frac{\Gamma (1/4)}{\Gamma (3/4)}} = \frac{\Gamma (1/4)}{\pi ^{3/4}\sqrt{2}} \end{aligned}$$

with \(\Gamma \) the classical Gamma function \(\Gamma (s)=\int _0^\infty t^{s-1}e^{-t}\; \mathrm{{d}}t\).

We will prove the first equality, and the second equality follows from the relation \(\Gamma (s)\Gamma (1-s)=\pi \csc (\pi s)\) that do not use elsewhere. In fact, the \(\Gamma \) function only appears as a complex function in the computation of an integral (Lemma 3) and, beyond that, we barely use its defining integral representation for \(s>1\).

Except for a special case of the Jacobi triple product identity and the well-known formula for the number of representations as a sum of two squares (both separated in Sect. 2 and admitting elementary proofs, not included here), the proof is completely self-contained. The techniques only involve basic real and complex variable methods. No modular properties of \(\theta \) and \(\eta \) and no functional equations of any L-function or Eisenstein series nor their analytic continuations are required.

Our argument includes a proof of a version of the (first) Kronecker limit formula (Proposition 1) simpler than the ones we have found in the literature (cf. [10]) which may have independent interest. We address the reader to the interesting paper [6] for the history and relevance of this formula.

We finish the paper showing that Theorem 1 and a self-contained argument allow to deduce a remarkable formula of Ramanujan.

2 Two auxiliary results

We first recall the factorization of the \(\theta \) function.

Lemma 1

For \(|q|<1\),

$$\begin{aligned} \sum _{n=-\infty } ^\infty q^{n^2} = \prod _{n=1}^\infty \big (1-q^{2n}\big )\big (1+q^{2n-1}\big )^2. \end{aligned}$$

The next result is the classic formula for r(n), the number of representations of n as a sum of two squares, in terms of the nontrivial character \(\chi \) modulo 4 (i.e., \(\chi (n)=(-1)^{(n-1)/2}\) for n odd and zero for n even).

Lemma 2

For \(n\in {\mathbb {Z}}^+\) and \(s>1\), we have

$$\begin{aligned} r(n)=4\sum _{d\mid n}\chi (n) \quad \text {or equivalently,}\quad \sum _{n=1}^\infty r(n)n^{-s}=4\zeta (s)L(s) \end{aligned}$$

with \(\zeta (s)=\sum _{n=1}^\infty n^{-s}\) the Riemann zeta function and \(L(s)=\sum _{n=1}^\infty \chi (n) n^{-s}\).

We will say some words about their proofs.

Lemma 1 comes from the Jacobi triple product identity which admits elementary combinatorial proofs (see [8, §8.3] and [1]) but arguably, even today, the conceptually most enlightening proof is the classic one based on complex analysis [12, §10.1]. It uses the invariance under two translations of certain entire function to conclude that it is a constant, which is computed with a beautiful argument due to Gauss [11, §78].

Lemma 2 can be derived from the triviality of some spaces of modular forms or from some properties of elliptic functions [12, §10.3.1], [11, §84]. A less demanding proof, requiring quadratic residues and almost nothing else, is to use the representations of an integer by the quadratic forms in a class [8, §12.4]. A longer alternative is to show that \({\mathbb {Z}}[i]\) is a UFD and deduce the result from \(r(p)=4(1+\chi (p))\) for p prime, which is essentially Fermat two squares theorem [7, Art.182] (see [13] for a “one-sentence” proof of the latter).

3 The Kronecker limit formula and the theta evaluation

We first state a compact version of the Kronecker limit formula and provide a proof only requiring the residue theorem and the very easy [9, p. 23] and well-known result \((s-1)\zeta (s)\rightarrow 1\) as \(s\rightarrow 1^+\).

The Epstein zeta function \(\zeta (s,Q)\) associated with a positive definite binary quadratic form Q and the Dedekind \(\eta \) function are defined, respectively, by

$$\begin{aligned} \zeta (s,Q) = \sum _{\mathbf {n}\in {\mathbb {Z}}^2\setminus \{\mathbf {0}\}} \big (Q(\mathbf {n})\big )^{-s} \quad \text { and }\quad \eta (z)= e^{\pi i z/12} \prod _{n=1}^\infty \big (1-e^{2\pi i nz}\big ). \end{aligned}$$

We assume \(s>1\) and \(\Im z>0\) to assure the convergence.

Proposition 1

Let \(Q(x,y)=ax^2+bxy+cy^2\) be a real form with \(D=4ac-b^2>0\) and \(a>0\). Then

$$\begin{aligned} \lim _{s\rightarrow 1^+} \Big ( \frac{\sqrt{D}}{4\pi }\zeta (s,Q) - \zeta (2s-1) \Big ) = \log \frac{\sqrt{a/D}}{|\eta (z_Q)|^2} \quad \text {with } z_Q = \frac{-b+i\sqrt{D}}{2a}. \end{aligned}$$

Proof

We consider \(p(x)= ax^2+bx+c\) and the following abbreviations:

$$\begin{aligned} g_s(x)= p(x)^{-s}+p(-x)^{-s}, \quad G(s)=-\int _{-\infty }^\infty g_s =-2\int _{-\infty }^\infty p^{-s}, \quad K = \frac{\sqrt{D}}{4\pi }. \end{aligned}$$

The limit in the statement equals \(L_1-L_2\) with

$$\begin{aligned} L_1 = K \lim _{s\rightarrow 1^+} \big ( \zeta (s,Q)+\zeta (2s-1)G(s) \big ), \quad L_2 = \lim _{s\rightarrow 1^+} \zeta (2s-1)\big ( K G(s) +1 \big ). \end{aligned}$$

L’Hôpital’s rule shows \(L_2=\frac{1}{2}KG'(1)\) because \((2s-2)\zeta (2s-1)\rightarrow 1\) (and \(G(1)=-K^{-1}\) by direct integration). Then the result follows if we prove

$$\begin{aligned} L_1= -\log |\eta (z_Q)|^2 \qquad \text {and}\qquad G'(1)=K^{-1}\log ({D}/{a}). \end{aligned}$$
(1)

We have \(G'(1)=2\int _{-\infty }^\infty (\log p)/p\). With the change of variables \(2a x+b=\sqrt{D}\tan (t/2)\), we obtain

$$\begin{aligned} G'(1) = - \frac{4}{\sqrt{D}} \int _{-\pi }^\pi \log \frac{2\cos (t/2)}{\sqrt{D/a}} = - \frac{4}{\sqrt{D}} \Re \int _{C} \log \Big (\frac{1+z}{\sqrt{D/a}}\Big ) \frac{\mathrm{{d}}z}{iz} \end{aligned}$$

with C the unit circle, where we have used \(\log \big (2|\cos (t/2)|\big ) =\Re \log (1+z)\) with \(z=e^{it}\). Cauchy’s integral formula gives the second identity in (1).

When we sum \(Q(m,n)^{-s}\), the contribution of \(n=0\) is \(2a^{-s}\zeta (2s)\). For \(n\ne 0\), the residue of \(i\cot (\pi nz)\) at \(z=m/n\) is \(i/\pi \). Then, the residue theorem in the band \(B_\epsilon =\{|\Im z|<\epsilon \}\), with \(0<\epsilon <\Im z_Q\), gives

$$\begin{aligned} \zeta (s,Q)-2\frac{\zeta (2s)}{a^s} = \sum _{n=1}^\infty \frac{1}{n^{2s}} \sum _{m\in {\mathbb {Z}}} g_s\big (\frac{m}{n}\big ) = \sum _{n=1}^\infty \frac{-1}{2n^{2s-1}} \int _{\partial B_\epsilon } g_s(z)i\cot (\pi nz)\; \mathrm{{d}}z. \end{aligned}$$

As \(g_s\) is even, \(\int _{\partial B_\epsilon }=-2\int _{L_\epsilon }\) with \(L_\epsilon = \{\Im z=\epsilon \}\) oriented to the right and the sum is \(\sum _{n}n^{1-2s}\int _{L_\epsilon }\). Note that \(\int _{L_\epsilon }g_s=\int _{L_0}g_s=-G(s)\). Then adding \(\zeta (2s-1)G(s)\) is equivalent to replace \(i\cot (\pi nz)\) by \(i\cot (\pi nz)-1\) in \(\int _{L_\epsilon }\). The expansion \(i\cot w-1=2e^{2iw}/(1-e^{2iw})=2(e^{2iw}+e^{4iw}+\dots )\) assures an exponential decay and we have

$$\begin{aligned} L_1= K \bigg ( 2\frac{\zeta (2)}{a} + \sum _{n,k=1}^\infty \frac{2}{n} \int _{L_\epsilon }g_1(z)e^{2\pi inkz}\; \mathrm{{d}}z \bigg ). \end{aligned}$$

Substitute \(\zeta (2)=\pi ^2/6\) and note that \(g_1(z)=\big (a(z-z_Q)(z-{\bar{z}}_Q)\big )^{-1}+\big (a(z+z_Q)(z+{\bar{z}}_Q)\big )^{-1}\). The residue theorem in \(\{\Im z>\epsilon \}\) gives promptly

$$\begin{aligned} L_1 = \frac{\pi \sqrt{D}}{12a} + \sum _{n,k=1}^\infty \frac{1}{n} \big ( e^{2\pi nkiz_Q}+e^{-2\pi nki{\bar{z}}_Q} \big ) = \frac{\pi \sqrt{D}}{12a} - \sum _{k=1}^\infty \log \big |1- e^{2\pi kiz_Q}\big |^2, \end{aligned}$$

where the second equality comes from \(\log (1-w)+\log (1-{\bar{w}})= \log |1-w|^2\). The sum is \(\log \big (|\eta (z_Q)|^2|e^{-\pi i z_Q/6}|\big )\) and the proof of (1) is complete. \(\square \)

The evaluation of an integral will be played a role in the final step of our proof of Theorem 1. We proceed again employing the residue theorem.

Lemma 3

Let

$$\begin{aligned} I = \frac{1}{\pi } \int _0^\infty \frac{\log t}{\cosh t}\; \mathrm{{d}}t \qquad \text {then}\quad \exp (I)= \frac{\Gamma (3/4)}{\Gamma (1/4)}\sqrt{2\pi }. \end{aligned}$$

Proof

Consider \(f(z)=i\sec (2\pi z)\log \Gamma (1/2+z)\) on the vertical band \(B = \big \{|\Re z |<1/2\big \}\). It defines a meromorphic function (for certain branch of the logarithm because \(\Gamma \) does not vanish) with simple poles at \(z_{\pm }=\pm 1/4\). Clearly the residues satisfy \(2\pi i\text {Res}(f,z_{\pm })=\pm \log \Gamma (1/2+z_{\pm })\). This function is integrable along \(\partial B\) and the residue theorem shows

$$\begin{aligned} \log \frac{\Gamma (3/4)}{\Gamma (1/4)} = \int _{\partial B} f = \int _{-\infty }^\infty \frac{\log \Gamma (1+it)}{\cosh (2\pi t)}\; \mathrm{{d}}t - \int _{-\infty }^\infty \frac{\log \Gamma (it)}{\cosh (2\pi t)}\; \mathrm{{d}}t. \end{aligned}$$

Using \(\Gamma (1+it)=it\Gamma (it)\) and taking real parts to avoid considerations about the branch of the logarithm,

$$\begin{aligned} \log \frac{\Gamma (3/4)}{\Gamma (1/4)} = \int _{-\infty }^\infty \frac{\log |t|}{\cosh (2\pi t)}\; \mathrm{{d}}t = \frac{1}{\pi } \int _{0}^\infty \frac{\log (t/2\pi )}{\cosh t}\; \mathrm{{d}}t = I - \int _{0}^\infty \frac{\log (2\pi )}{\pi \cosh t}\; \mathrm{{d}}t. \end{aligned}$$

The last integral is \(\log \sqrt{2\pi }\) just changing \(t=\log \tan u\) for \(u\in [\pi /4,\pi /2)\). \(\square \)

Proof

(of Theorem 1) From Lemma 1 with \(q=e^{\pi i z}\), we obtain the identity \(\theta (z)=\prod _{n=1}^\infty \big (1-e^{2\pi inz}\big )\big (1+e^{\pi i(2n-1)z}\big )^2\). Elementary manipulations with the definition of \(\eta \) show \(\theta (z)=\eta ^2\big (\frac{1}{2} z+\frac{1}{2}\big )/\eta (z+1)\). Let \(Q=x^2+y^2\) and \(Q'=2x^2-2xy+y^2\) with \(z_Q=i\) and \(z_{Q'}=\frac{1+i}{2}\). We have \(\zeta (s,Q)=\zeta (s,Q')\) because \(Q'=x^2+(x-y)^2\). Then Proposition 1 implies \(|\eta (z_{Q'})|^2/|\eta (z_{Q})|^2=\sqrt{2}\) and, noting \(\theta (i)=|\theta (i)|\) and \(|\eta (z+1)|=|\eta (z)|\),

$$\begin{aligned} \theta (i) = \theta (z_Q) = \Big | \frac{\eta (z_{Q'})}{\eta (z_{Q}+1)} \Big |^2|\eta (z_{Q}+1)| =\sqrt{2}|\eta (i)|. \end{aligned}$$

Recalling Lemma 3, Theorem 1 is equivalent to \(I=-\log \big (2|\eta (i)|^2\big )\). By Lemma 2, we have \(\zeta (s, Q)=4\zeta (s)L(s)\) and, since Proposition 1, we must prove

$$\begin{aligned} \lim _{s\rightarrow 1^+} \Big ( \frac{2}{\pi }\zeta (s)L(s)- \zeta (2s-1) \Big ) = I. \end{aligned}$$

It is known \(\zeta (s)\sim (s-1)^{-1}+\gamma \) as \(s\rightarrow 1\) with \(\gamma \) the Euler–Mascheroni constant, and it admits a short elementary proof [9, p. 23]. UsingFootnote 1\(\Gamma '(1)=-\gamma \), we have \(\zeta (s)-2\Gamma (s)\zeta (2s-1)\rightarrow 0\) and the previous limit is

$$\begin{aligned} \lim _{s\rightarrow 1^+} \Big ( \frac{4}{\pi }\Gamma (s)L(s)-1 \Big ) \zeta (2s-1) = \lim _{s\rightarrow 1^+} \frac{4\Gamma (s)L(s)-\pi }{2\pi (s-1)} = \frac{2}{\pi } \frac{d}{ds}\Big |_{s=1}\big (\Gamma (s)L(s)\big ) \end{aligned}$$

by L’Hôpital’s rule. It only remains to show that this derivative is \(\pi I/2\). Plainly \(\Gamma (s)n^{-s}=\int _0^\infty t^{s-1}e^{-nt}\; \mathrm{{d}}t\). Then

$$\begin{aligned} \Gamma (s)L(s)= \int _0^\infty t^{s-1} \big ( e^{-t} -e^{-3t} +e^{-5t} -e^{-7t}+\dots \big )\; \mathrm{{d}}t = \int _0^\infty \frac{t^{s-1}}{2\cosh t}\; \mathrm{{d}}t \end{aligned}$$

and Lemma 3 implies the result differentiating under the integral sign. \(\square \)

4 A remarkable formula of Ramanujan

The purpose of this section is to use Theorem 1 to give a proof not requiring any background in the theory of elliptic functions of the following result due to Ramanujan [2, §18, Entry 11(i)]. It constitutes one of his most famous and emblematic formulas. It is simple, beautiful and striking. As mentioned in [2, p. 163] “One wonders how Ramanujan ever discovered this most unusual and beautiful formula”.

Theorem 2

(Ramanujan) For \(|z|<1\) we have

$$\begin{aligned} \Big ( \sum _{n=-\infty }^\infty \frac{\cos (\pi nz)}{\cosh (\pi n)} \Big )^{-2} + \Big ( \sum _{n=-\infty }^\infty \frac{\cosh (\pi nz)}{\cosh (\pi n)} \Big )^{-2} = \frac{4\pi \Gamma ^2(3/4)}{\Gamma ^2(1/4)}. \end{aligned}$$

Note that using the reflection property of the \(\Gamma \) function, the constant equals \(2\pi ^{-1}\Gamma ^4(3/4)\), which is the original form appearing in [2].

For the proof, we consider the function

$$\begin{aligned} p(z)= \prod _{2\not \mid m} \frac{\cosh (\pi m) + \cos (\pi z)}{\cosh (\pi m) - \cos (\pi z)} = \prod _{2\not \mid m} \coth \Big ( \frac{\pi }{2} (m-iz) \Big ) \coth \Big ( \frac{\pi }{2} (m+iz) \Big ) \end{aligned}$$

with \(m\in {\mathbb {Z}}^+\). The trained reader will notice the relation between p and the Jacobi function \(\text {dn}\) in part of the proof, but we avoid any reference to properties of elliptic functions. The equality between both products follows easily from \(\coth x =(e^x+e^{-x})/(e^x-e^{-x})\). The function p is meromorphic with simple poles at \(\big \{ i +2(k+i\ell )\,:\, k,\ell \in {\mathbb {Z}}\big \}\) and it enjoys the symmetries

$$\begin{aligned} p(z+2)=p(z), \quad p(z+1)=\frac{1}{p(z)}, \quad p(z)=p(-z), \quad p(z+2i)=-p(z). \end{aligned}$$
(2)

Excepting the last, they are trivial consequences of the first product representation. Using the second product, the effect of \(z\mapsto z+2i\) is shifting m forward in the first factor and backwards in the second. Then \(p(z+2i)/p(z)\) equals \(\coth \big (\frac{\pi }{2}(-1+iz)\big )/\coth \big (\frac{\pi }{2}(1-iz)\big )=-1\), proving the last equality.

Lemma 4

For certain constant \(K_0\in {\mathbb {C}}\), we have

$$\begin{aligned} p^2(z)+p^2(i+1+iz) = \frac{1}{p^2(z)} + \frac{1}{p^2(iz)} =K_0. \end{aligned}$$

Proof

Using (2), \(p(i+z)=p(-i-z)=-p(i-z)\). Then p is odd around the pole \(z=i\) and we have \(p(z)=A(z-i)^{-1}+B(z-i)+ \cdots \) This proves that \(p^2(z)+p^2(i+1+iz)\) has not a pole at \(z=i\) because the principal parts cancel out. By the periodicity under \(z\mapsto z+2\) and \(z\mapsto z+2i\), we conclude that it is a bounded entire function and hence a constant \(K_0\). The remaining equality follows from (2) changing \(z\mapsto z+1\). \(\square \)

Lemma 5

There exists a constant \(K_1\in {\mathbb {C}}\) such that

$$\begin{aligned} p(z) = K_1 \sum _{n=-\infty }^\infty \frac{\cos (\pi nz)}{\cosh (\pi n)} \qquad \text {for}\quad |\Im z|<1. \end{aligned}$$

Proof

It is enough to consider \(z=t\in {\mathbb {R}}\) because the formula extends analytically to the convergence region \(|\Im z|<1\). As p(t) is 2-periodic, we only need to prove that the Fourier coefficients match. This means \( \int _0^2 p(t) e^{-i\pi n t}\, \mathrm{{d}}t = K_2\,\text {sech}(\pi n) \) for some \(K_2\in {\mathbb {C}}\). Consider the parallelogram \({\mathcal {P}}\) with vertexes 0, 2, 2i and \(-2-2i\). By the first and the last equalities in (2), we have \( \int _{\partial {\mathcal {P}}} p(z) e^{-i\pi n z}\, \mathrm{{d}}z = \big (1+e^{2\pi n}\big ) \int _0^2 p(t) e^{-i\pi n t}\, \mathrm{{d}}t \). On the other hand, by the residue theorem, this is also \(2\pi i e^{\pi n}\text {Res}(p,i)\) and the proof is complete. \(\square \)

Lemma 6

We have

$$\begin{aligned} \sum _{n=-\infty }^\infty \frac{1}{\cosh (\pi n)} = \frac{\Gamma (1/4)}{\Gamma (3/4)\sqrt{2\pi }}. \end{aligned}$$

Proof

The Taylor expansion of \(x/(1+x^2)\) shows for \(n>0\)

$$\begin{aligned} \frac{1}{\cosh (\pi n)} = \frac{2 e^{-\pi n}}{1+e^{-2\pi n}} = 2 \sum _{m=0}^\infty (-1)^me^{-\pi n(2m+1)} = 2 \sum _{d=1}^\infty \chi (d) e^{-\pi nd}. \end{aligned}$$

Then the sum in the statement is, by Lemma 2,

$$\begin{aligned} 1+ 4 \sum _{n=1}^\infty \sum _{d=1}^\infty \chi (d) e^{-\pi nd} = 1+ 4 \sum _{m=1}^\infty \sum _{d\mid m} \chi (d) e^{-\pi m} = \sum _{m=0}^\infty r(m) e^{-\pi m}. \end{aligned}$$

The last sum is \(\theta ^2(i)\) which is evaluated with Theorem 1. \(\square \)

Proof of Theorem 2

From Lemmas 4 and 5, we get the result except for the value of the constant, which follows choosing \(z=0\) by Lemma 6. \(\square \)

The same argument using \(p^2(z-1)+p^2(1+iz)=K_0\) (by Lemma 4) shows

$$\begin{aligned} \Big ( \sum _{n=-\infty }^\infty (-1)^n\frac{\cos (\pi nz)}{\cosh (\pi n)} \Big )^{2} + \Big ( \sum _{n=-\infty }^\infty (-1)^n\frac{\cosh (\pi nz)}{\cosh (\pi n)} \Big )^{2} = \frac{\Gamma ^2(1/4)}{2\pi \Gamma ^2(3/4)}, \end{aligned}$$

which, to our knowledge, does not appear in Ramanujan’s work. An immediate variant of the proof of Lemma 6 shows that for \(z=0\), the quantities in the parentheses are \(\theta ^2(i+1)\), giving the evaluation \(\theta (i+1)=2^{-1/4}\theta (i)\).