Lacunary series - Finding a limit Let, $f$ be the function defined on the open unit disk:
\begin{equation*}
f(x)=\sum_{n=0}^{+ \infty} x^{n^2}
\end{equation*}
The aim of the exercise is to find the limit of $f(x)$ as $x$ approaches $-1$.
I tried considering the function $g$ defined by $g(x)=f(-x)$ and separating the positive and then negative terms... but I am not making any progress.
Does anyone have an idea? 
I don't know if this is useful but I have proved that :
\begin{equation*}
f(x) \sim \frac{\sqrt{\pi}}{2\sqrt{1-x}} \quad \text{as $x$ approaches $1$}
\end{equation*}
 A: Another approach is by considering $f(t) = e^{i\pi t-\alpha t^2}$ then, 
$\displaystyle \hat{f}(x) = 
\int_{-\infty}^{\infty} e^{itx}f(t)\,dt = \int_{-\infty}^{\infty} e^{itx}e^{i\pi t-\alpha t^2}\,dt = \sqrt{\frac{\pi}{\alpha}}e^{-\frac{(x+\pi)^2}{4\alpha}}$ so that using Poisson Summation formula we have, $$\sum\limits_{n=-\infty}^{\infty} (-1)^{n}e^{-\alpha n^2} = \sqrt{\frac{\pi}{\alpha}}\sum\limits_{n=-\infty}^{\infty} e^{-\frac{(2n+1)^2\pi^2}{4\alpha}}$$
i.e., $\displaystyle \sum\limits_{n=0}^{\infty} (-1)^{n}e^{-\alpha n^2} = \frac{1}{2} + \sqrt{\frac{\pi}{\alpha}}\sum\limits_{n=0}^{\infty} e^{-\frac{(2n+1)^2\pi^2}{4\alpha}}$ and letting $\alpha \to 0^{+}$ gives the desired limit to be equal to $\dfrac{1}{2}$ (since, $\displaystyle \sum\limits_{n=0}^{\infty} e^{-\frac{(2n+1)^2\pi^2}{4\alpha}} < \sum\limits_{n=1}^{\infty} e^{-\frac{n\pi^2}{4\alpha}} = \frac{e^{-\frac{\pi^2}{4\alpha}}}{1-e^{-\frac{\pi^2}{4\alpha}}}$).
Addendum: It also follows from one of the Jacobi Triple product identity: $$\sum\limits_{n=-\infty}^{\infty} (-1)^nx^{n^2} = \prod\limits_{k=1}^{\infty} (1-x^{2k})(1-x^{2k-1})^2$$
A: I have a solution based on the theory of theta functions and I believe more elementary solutions are desirable. 

Put $x=-q$ and then you want to know the limit of expression $$\sum_{n=0}^{\infty}(-q)^{n^{2}}=\frac{1}{2}\left(1+\vartheta_{4}(q)\right)$$ when $q\to 1^{-}$. Now we can exploit the link between theta functions and elliptic integrals and note that when $q\to 1^{-}$ then elliptic modulus $k\to 1^{-}$ and we have $$\vartheta_{4}(q) = \sqrt{\frac{2k'K}{\pi}}$$ We now interchange $k, k'$ and thus calculate the limit of $\sqrt{2kK'/\pi}$ as $k\to 0^{+}$. Noting that $$K'=\log\left(\frac{4}{k}\right)+o(1)$$ as $k\to 0^{+}$ (see this blog post for a proof) we can see that the expression $\sqrt{2kK'/\pi}$ tends to $0$ as $k \to 0^{+}$. The desired limit is thus $1/2$.
A: Here is yet another solution. After the change of variable $x = -y$ with $y \to 1^-$, we have
$$ f(x) = \sum_{n=0}^{\infty} y^{4n^2}(1 - y^{4n+1}). \tag{1}$$
Now the idea is to identify $\text{(1)}$ as sort of Riemann sum for the integral $\int_{0}^{\infty} e^{-2t} \, dt = \frac{1}{2}$.
To this end, we first fix arbitrary $\epsilon \in (0, 1)$ and choose $N = N(\epsilon, y) \in \mathbb{Z}_{> 0}$ such that $y^{4N^2} \to \epsilon$ as $y \to 1^-$. For instance, choose $N$ to be any nearest integer to $(\log \epsilon / 4 \log y)^{1/2}$. Then using the alternating behavior of $\text{(1)}$ we find that
$$ \left| \sum_{n=N+1}^{\infty} y^{4n^2}(1 - y^{4n+1}) \right| \leq y^{4N^2} \xrightarrow[y \to 1^-]{} \epsilon $$
which will be shown to be negligible as $\epsilon \to 0^+$. Next, we define $t_n = t_n(y)$ by
$$t_n = \sum_{k=0}^{n} (4k+1)(1-y) = (2n^2+3n+1)(1-y) $$
and $\Delta t_n = \Delta t_n (y) := t_n - t_{n-1}$. Then we have $y = 1 - \frac{t_n}{2n^2+3n+1}$. Now from the following simple inequality
$$ (4n+1)y^{4n+1}(1-y) \leq 1 - y^{4n+1} \leq (4n+1)(1-y), $$
we find that
\begin{align*}
&\sum_{n=0}^{N} \exp\left\{ 4(n+1)^2 \log\left( 1 - \frac{t_n}{2n^2+3n+1} \right) \right\} \Delta t_n \tag{2}\\
&\qquad \leq \sum_{n=0}^{N} y^{4n^2}(1 - y^{4n+1}) \\
&\qquad \leq \sum_{n=0}^{N} \exp\left\{ 4n^2 \log\left( 1 - \frac{t_n}{2n^2+3n+1} \right) \right\} \Delta t_n \tag{3}
\end{align*}
Since $t_N \to \frac{1}{2}\log\frac{1}{\epsilon}$ and $\max_{0 \leq n \leq N} \Delta t_n = (4N+1)(1-y) \to 0$ as as $y \to 1^-$, we can think of bounds $\text{(2)}$ and $\text{(3)}$ as Riemann sums of $e^{-2t}$ over the inteval $[0, \frac{1}{2}\log\frac{1}{\epsilon}]$. Taking limit as $y \to 1^-$, it is not hard to show (but slightly annoying to give a full argument) that both bounds converge to the same value, which is
$$ \lim_{y \to 1^-} \sum_{n=0}^{N} y^{4n^2}(1 - y^{4n+1}) = \int_{0}^{\frac{1}{2}\log\frac{1}{\epsilon}} e^{-2t} \, dt = \frac{1 - \epsilon}{2}. $$
Then by the usual 3-epsilon argument, we have
$$ \limsup_{y \to 1^-} \left| f(-y) - \frac{1}{2} \right| \leq \frac{3 \epsilon}{2}
\xrightarrow[\epsilon \to 0^+]{} 0 $$
and hence the claim follows.
A: $$\sum_{n=0}^\infty(-x)^{n^2}= \sum_{k=0}^\infty x^{(2k)^2} - \sum_{k=0}^\infty x^{(2k+1)^2} = \sum_{k=0}^\infty \left((x^4)^{k^2}  -(x^4)^{(k+\frac12)^2} \right)
$$
$$
\lim_{x\to 1^-} \sum_{n=0}^\infty(-x)^{n^2}= \lim_{y\to 1^-} \sum_{n=0}^\infty
\left(y^{k^2}  -y^{(k+\frac12)^2} \right)
$$
which you can show goes to $\frac12$.   
(In fact, by the time $x = 0.9$ the sum is $\frac12 + \epsilon$ with $0<\epsilon < 10^{-6}$.)
