A closed form for the sum $\sum_{s=0}^{n-1} e^{\frac{s(s+1)}{2}i\theta}$?

63 Views Asked by At

What I'm really looking for is a good way to calculate the sum in parallel across many $n$ for a given real valued $\theta$. Why? Consider the Logo program:

to doit :r :dr
  forward 10
  right :r
  doit :r :r + :dr
end

It tends to draw cute, curly paths. I'd like to be able to draw these quickly (as a shader) in order make animations from varying :r and :dr.

The sum $\sum_{s=0}^{n-1} e^{\frac{s(s+1)}{2}i\theta}$ basically tells you the location of the turtle at the $n$th step where $\theta$ = :dr and the coordinates are rotated and reflected.

For example, with $\theta = \pi/2$ we get a very small zigzag figure as we increase $n$:

$$ \begin{matrix} n & \sum_{s=0}^{n-1} e^{\frac{s(s+1)}{2}i\theta} \\ 0 & 0 \\ 1 & 1 \\ 2 & 1 + i \\ 3 & 1 \\ 4 & 0 \\ 5 & -1 \\ 6 & -1 - i \\ 7 & -1 \\ \end{matrix} $$