While studying sequences and series, I came across summations of geometric series. I am able to derive the sum of a geometric progression and that of arithmetico–geometric sequence.

But taking a step further, I found the following series intriguing: the $i^{th}$ term is $a^{i^2}$ (instead of $a^{i}$ as in geometric series).

Is there a name for this series? How can we evaluate its sum?

$$
S = \sum_{i=0}^{n-1}a^{i^2}
$$

First, I tried multiplying $S$ by $a$ and differentiating it by $a$, but to no avail. Then, I went through the eight PDF documents listed on [Gould's home page](https://web.archive.org/web/20190629193344/http://www.math.wvu.edu/~gould/) containing enormous combinatorial identities, but I couldn't make any progress.