Why is $\lim_{x\to 1}\sqrt{1-x}\sum_{n=0}^\infty x^{n^2}=\sqrt{\pi}/2\,\,$? It is well-known that $\sum_{n=0}^\infty x^n=1/(1-x)$. However, it seems difficult to find $\sum_{n=0}^\infty x^{n^2}$. A natural problem is study its behavior around $1$. A problem states that
$$\lim_{x\to 1}\sqrt{1-x}\sum_{n=0}^\infty x^{n^2}=\sqrt{\pi}/2.$$
How can we prove this? Abel summation formula? Any others? I have no idea.
 A: by the Mac-Laurin-Cauchy Test formula,
($S(x)=\sum_{n=0}^{\infty}e^{\log(x)n^2}$)  we have for $x<1$ 
$$
\frac{\sqrt{\pi}}{2\sqrt{-\log(x)}}=\int_0^{\infty}e^{\log(x)n^2}dn\leq \\S(x)=\\ \leq 1+ \int_0^{\infty}e^{\log(x)n^2}dn=1+\frac{\sqrt{\pi}}{2\sqrt{-\log(x)}}
$$
Expanding around $x=1_-$
$$
\frac{\sqrt{\pi}}{2\sqrt{1-x}} \leq S(x)\leq 1+\frac{\sqrt{\pi}}{2\sqrt{1-x}}
$$
and therefore

$$
\lim_{x\rightarrow1_-}\sqrt{1-x}S(x)=\frac{\sqrt{\pi}}{2}
$$

A: We can use also the Abel's summation formula. We have $$S\left(N\right)=\sum_{n=0}^{N}x^{n^{2}}=\left(N+1\right)x^{N^{2}}-2\log\left(x\right)\int_{0}^{N}\left\lfloor t+1\right\rfloor tx^{t^{2}}dt
 $$ where $\left\lfloor t\right\rfloor 
 $ is the floor function. Since $t-1\leq\left\lfloor t\right\rfloor \leq t
 $ we have $$ \left(N+1\right)x^{N^{2}}-2\log\left(x\right)\int_{0}^{N}t^{2}x^{t^{2}}dt\leq S\left(N\right)\leq Nx^{N^{2}}-2\log\left(x\right)\int_{0}^{N}t^{2}x^{t^{2}}dt+1.
 $$ Now let us consider the integral. We have, integrating by parts, $$2\log\left(x\right)\int_{0}^{N}t^{2}x^{t^{2}}=x^{N^{2}}N-\int_{0}^{N}x^{t^{2}}dt=x^{N^{2}}N-\int_{0}^{N}e^{\log\left(x\right)t^{2}}dt
 $$ $$=x^{N^{2}}N-\frac{\sqrt{\pi}\textrm{erfi}\left(iN\sqrt{-\log\left(x\right)}\right)}{2i\sqrt{-\log\left(x\right)}}\rightarrow\frac{\sqrt{\pi}}{2\sqrt{-\log\left(x\right)}}
 $$ as $N\rightarrow\infty
 $, where $\textrm{erfi}\left(x\right)
 $ is the imaginary error function. So using the expansion of $\log$ at $x=1$ and the squeeze theorem we can conclude.
A: We will use variable $q$ instead of $x$ so that we can visibly link the problem to theta functions. We have $$\vartheta_{3}(q) = \sum_{n = -\infty}^{\infty}q^{n^{2}} = \sqrt{\frac{2K}{\pi}}$$ where $K$ is the elliptic integral of first kind and $q = e^{-\pi K'/K}$. Now we can see that $$\sqrt{1 - q}\sum_{n = 0}^{\infty}q^{n^{2}} = \sqrt{1 - q}\cdot\frac{\vartheta_{3}(q) + 1}{2}$$ and then clearly $$\lim_{q \to 1^{-}}\sqrt{1 - q}\sum_{n = 0}^{\infty}q^{n^{2}} = \frac{1}{2}\lim_{q \to 1^{-}}\sqrt{1 - q}\vartheta_{3}(q) = \frac{1}{2}\lim_{q \to 1^{-}}\sqrt{\frac{2K(1 - q)}{\pi}}$$ and from $q = e^{-\pi K'/K}$ we can see that the limit is equal to $$\frac{1}{2}\lim_{k \to 1^{-}}\sqrt{2K'}$$ which is $$\frac{1}{2}\sqrt{\pi}$$ Here we have used the fact that as $q \to 1^{-}$ we have modulus $k \to 1^{-}$ so that $K' \to \pi/2$ and $K \to \infty$ and hence from $q = e^{-\pi K'/K}$ we get $$1 - q = \pi\frac{K'}{K} + o(1/K)$$ A more elementary answer by G. H. Hardy is available here.
A: What about squaring? We have
$$ \left(\sum_{n\geq 0}x^{n^2}\right)^{2} = \sum_{n\geq 0}r_2(n)\,x^n $$
where
$$ r_2(n) = \left|\left\{(a,b)\in\mathbb{N}^2: a^2+b^2 = n\right\}\right| $$
is a nice arithmetic function. For instance, $\sum_{n=0}^{N}r_2(n)$ is the number of lattice points with non-negative coordinates inside the circle $x^2+y^2=N$, but also the coefficient of $x^N$ in
$$ \frac{1}{1-x}\left(\sum_{n\geq 0}x^{n^2}\right)^{2} = \sum_{N\geq 0}\left(\sum_{n=0}^{N}r_2(n)\right) x^N. $$
By Gauss circle problem with Voronoi bound we have that $\sum_{n=0}^{N}r_2(n)=\frac{\pi N}{4}+O(N^{1/3})$, hence $x=1$ is a double pole of the previous function and the first term of its Laurent expansion around $x=1$ is given by $\frac{\pi}{4(1-x)^2}$. By multiplying by $(1-x)^2$ and taking the limit as $x\to 1^-$ we get:
$$ \lim_{x\to 1^-}\,(1-x)\left(\sum_{n\geq 0}x^{n^2}\right)^2 = \frac{\pi}{4} $$
and the claim easily follows.
It is interesting to point out that the same approach shows that, for any $k\geq 2$,
$$ \lim_{x\to 1^-}(1-x)\left(\sum_{n\geq 0}x^{n^k}\right)^k $$
is exactly the (hyper-)volume enclosed by $x_1\geq 0,x_2\geq 0,\ldots x_k\geq 0$ and $x_1^k+x_2^k+\ldots+x_k^k = 1$, that can be computed in the following way: if we assume that $X_1,\ldots,X_k$ are i.i.d. random variables with uniform distribution over $(0,1)$, the PDF of $X_i$ is supported on $(0,1)$ and given by $f(t)=\frac{1}{k} t^{1/k-1}$. To compute the previous volume, it is enough to compute the characteristic function of $X_i$, take its $k$-th power, consider the inverse Fourier transform and integrate it over $(0,1)$ to get the probability that $X_1^k+\ldots+X_k^k\leq 1.$
