TITLE: Ramanujan theta function and its continued fraction
QUESTION [12 upvotes]: I believe Ramanujan would have loved this kind of identity.
After deriving the identity, I wanted to share it with the mathematical community. If it's well known, please inform me and give me some links to it.
Let $q=e^{2\pi\mathrm{i}\tau}$, then
$$(1+q^{2}+q^{6}+q^{12}+q^{20}+q^{30}+\cdots)^{2}=\cfrac{1}{1+q-\cfrac{q(1+q)^2}{1+q^3+\cfrac{q^2(1-q^2)^2}{1+q^5-\cfrac{q^3(1+q^3)^2}{1+q^7+\ddots}}}}$$
for $|q|\lt1$.
If possible, please provide more examples of this nature, available in the literature.

REPLY [5 votes]: In a paper of me and Professor M.L. Glasser [1] we have generalized the continued fractions regarding this conversation. Namely
If $|q|<1$ and we set 
$$
(a;q)_{\infty}=\prod^{\infty}_{n=0}\left(1-aq^n\right),\tag 1
$$
then
$$
\left(\frac{(-a;q)_{\infty}}{(a;q)_{\infty}}\right)^2=-1+\frac{2}{1-}\frac{2a}{1-q+}\frac{a^2(1+q)^2}{1-q^3+}\frac{a^2q(1+q^2)^2}{1-q^5+}\frac{a^2q^2(1+q^3)^2}{1-q^7+}\ldots,\tag 2
$$
$$
\sum^{\infty}_{n=0}\frac{q^n}{1-a^2q^{2n}}=\frac{1}{1-q+}\frac{-a^2(1-q)^2}{1-q^3+}\frac{-qa^2(1-q^2)^2}{1-q^5+}\frac{-q^2a^2(1-q^3)^2}{1-q^7+}\ldots,\tag 3
$$
where $a$ is a complex number.
Hence for example
1)  If we set $a=iq$ in (3) and using [2] pg.17, pg.55:
$$
cn(u)=\frac{2\pi}{Kk}\sum^{\infty}_{n=0}\frac{q^{n+1/2}}{1+q^{2n+1}}\cos((2n+1)z)
$$
where $z=\frac{\pi}{2K}u$ and $cn(0)=1$, we get
$$
\sum^{\infty}_{n=0}\frac{q^n}{1+q^{2n+1}}=\frac{1}{1-q+}\frac{q(1-q)^2}{1-q^3+}\frac{q^2(1-q^2)^2}{1-q^5+}\frac{q^2(1-q^3)^2}{1-q^7+}\ldots=
$$
$$
=q^{-1/2}\frac{Kk}{2\pi}=\left(\frac{\theta_2(q)}{2q^{1/4}}\right)^2=\left(\sum^{\infty}_{n=0}q^{n(n+1)}\right)^2,
$$
where $\theta_2(q)=\sum^{\infty}_{n=-\infty}q^{(n+1/2)^2}=\sqrt{2Kk/\pi}$, $q=e^{-\pi\sqrt{r}}$, $r>0$.
2) From [3] pg.37 we have
$$
\theta_4(q)=\sum^{\infty}_{n=-\infty}(-1)^nq^{n^2}=\frac{(q;q)_{\infty}}{(-q,q)_{\infty}}.
$$
Using (2) we arive to
$$
\left(\sum^{\infty}_{n=-\infty}(-1)^nq^{n^2}\right)^{-2}=-1+\frac{2}{1-}\frac{2q}{1-q+}\frac{q^2(1+q)^2}{1-q^3+}\frac{q^3(1+q^2)^2}{1-q^5+}\frac{q^4(1+q^3)^2}{1-q^7+}\ldots
$$
3) For $q\rightarrow q^2$ and $a=q$, we get
$$
S_1=\left(\frac{(-q;q^2)_{\infty}}{(q;q^2)_{\infty}}\right)^2=
-1+\frac{2}{1-}\frac{2q}{1-q^2+}\frac{q^2(1+q^2)^2}{1-q^6+}\frac{q^4(1+q^4)^2}{1-q^{10}+}\frac{q^6(1+q^6)^2}{1-q^{14}+}\ldots\tag 4
$$
we also get
$$
S_2=\left(\frac{(q;q^2)_{\infty}}{(-q;q^2)_{\infty}}\right)^2=\frac{1}{S_1}=
$$
$$
=-1+\frac{2}{1+}\frac{2q}{1-q^2+}\frac{q^2(1+q^2)^2}{1-q^6+}\frac{q^4(1+q^4)^2}{1-q^{10}+}\frac{q^6(1+q^6)^2}{1-q^{14}+}\frac{q^8(1+q^8)^2}{1-q^{18}+}\ldots\tag 5
$$
But $\chi(q)=(-q;q^2)_{\infty}$, $\psi(q)=\sum^{\infty}_{n=0}q^{n(n+1)/2}=\frac{(q^2;q^2)_{\infty}}{(q;q^2)_{\infty}}$, $f(-q)=(q;q)_{\infty}$  (note that $\chi(-q)=\frac{\theta_4(q)}{f(-q)}$). Moreover if $k'_r=\sqrt{1-k_r^2}$ is the complementary elliptic singular modulus, then from [3] chapter 16, Entry 24, pg. 39 we have the following cfrac expansions:
$$
S_1=\frac{\chi(q)}{\chi(-q)}=\frac{f(q)}{f(-q)}=\frac{\psi(q)}{\psi(-q)}=\sqrt{\frac{\theta_3(q)}{\theta_4(q)}}=\frac{1}{\sqrt[4]{k'_r}}
$$
Note.
$$
k_r=\sqrt{m(q)}=4q^{1/2}\exp\left(-4\sum^{\infty}_{n=1}q^n\sum_{d|n}\frac{(-1)^{d+n/d}}{d}\right),
$$
where $q=e^{-\pi\sqrt{r}}$, $r>0$.
etc...
References
[1]: N.D. Bagis and M.L. Glasser. "Evaluations of a Continued Fraction  of Ramanujan". Rend. Sem. Mat. Univ. Padova, Vol. 133 (2015). (submited 2013)
[2]: J.V. Armitage W.F. Eberlein. 'Elliptic Functions'. Cambridge University Press, (2006).
[3]: Bruce C. Berndt. 'Ramanujan`s Notebooks Part III'. Springer Verlag, New York, (1991).