# Sum over squared index

Is there any way to compute the finite series

$$S_M = \sum_{n=1}^{M} r^{n^2},$$

for some real $r$, integer $M$?

-
(a) Do you mean a "closed" formula? (b) Why do you want a "closed" formula? What is the motivation? – vesszabo Nov 3 '12 at 17:00
A closed-form expression would be the best case scenario. However, I'd be interested in any techniques for expressing this series in terms of better known ones. I have no real motivation aside from curiosity. – user89457 Nov 3 '12 at 18:23