Upper bound on $\sum_{n=1}^\infty q^{(n^2)}$

Let $q\in \mathbb R$ with $|q|<1$. I am looking for an upper bound of the converging series $$\sum_{n=1}^\infty q^{(n^2)}$$ with respect to $q$. Using the inequality $q^{(n^2)} \le q^{2n-1}$, one gets $$\sum_{n=1}^\infty q^{(n^2)} \le q^{-1} \sum_{n=1}^\infty q^{2n} = q\sum_{n=0}^\infty q^{2n} = \frac{q}{1-q^2}$$ Numerical experiments say that this estimate does not reflect the behavior of the sum for $q\to1$. They suggests an upper bound in the order of $\frac1{\sqrt{1-q^2}}$. Is it possible to prove this? Preferably with elementary arguments?

• For your information, $\,\theta_3(0,q)=\sum_{n=-\infty}^\infty q^{n^2}\,$ where $\,\theta_3\,$ is a Theta function. Jul 10 '18 at 10:44

Hint. Note that as $q\to 1^-$, we have that $\ln(q)<0$ and $$\sum_{n=1}^\infty q^{n^2}=\sum_{n=1}^{\infty}e^{\ln(q)n^2}\leq \int_{x=0}^{\infty}e^{\ln(q)x^2}\,dx=\frac{\sqrt{\pi}}{2\sqrt{-\ln(q)}}\sim \frac{\sqrt{\pi}}{2\sqrt{1-q}}.$$
• Thanks for the answer! The second-to-last term seems to be a pretty good approximation numerically for $q\to1$.