# Freaky dots in the complex plane

Context:

I recently saw user @David's profile picture and description:

"My icon is the graph of the exponential sum $$\sum_{n=1}^{10620}e^{2\pi if(n)}$$ for $$f(n)=\frac{n}{20}+\frac{n^2}{9}+\frac{n^3}{59}\ ,$$ where the "graph" of an exponential sum means the sequence of partial sums, plotted in the complex plane, with successive points joined by straight line segments."

This intrigued me, so I decided to investigate. My findings and questions are below.

Reproducing it in Desmos: (for those interested)

I first decided to recreate the picture on Desmos. You can see it here (it will take a while to load).

I created the image by defining $$f(x)$$ as it is defined above, then setting $$x_2(x)=\sum_{k=1}^{x}\cos(2\pi f(k))\\ y_2(x)=\sum_{k=1}^{x}\sin(2\pi f(k))\\ p(x)=(x_2(x),y_2(x))$$ So that $$p(x)$$ was essentially $$\sum_{k=1}^{x}e^{2\pi i f(k)}$$. Then I defined the lists \begin{align} I_1&=[1,2,\dots,1000]\\ I_2&=[1001,1002,\dots,2000]\\ \dots &\dots\\ I_{10}&=[9001,9002,\dots,10000] \end{align} Then entering $$p(I_{1}),\ p(I_2),\ \text{etc.}$$ gave a whole bunch ($$10000$$ to be precise) of points. Then clicking the little gear symbol and then the colored circle next to each entry (on the left) I was able to connect the points $$p(i)$$ and $$p(i+1)$$ for any integer $$1\leq i\leq 9999$$. I used the $$10$$ different lists instead of $$1$$ in order to keep Desmos from freaking out.

My investigations:

Also using Desmos and the same technique as described above, I decided to create the graphs corresponding to the functions $$H_n(x)=x+\frac{x^2}2+\frac{x^3}3+\dots+\frac{x^n}n\qquad (n>1)$$ i.e. I made the graphs for $$p(k)=\left(\sum_{r=1}^{k}\cos[2\pi H_n(r)],\sum_{r=1}^{k}\sin[2\pi H_n(r)]\right)$$ I made each sequence/graph have $$700$$ points (AKA I graphed $$p([1,2,...,700])$$) just to see if any irregular behavior started to occur. Here are the graphs for the first $$6$$ values of $$n$$.

$$n=2$$:

$$n=3$$:

$$n=4$$:

$$n=5$$: I do not know how well you can see it, but the points are starting to move around a little. This is a picture of the $$n=5$$ graph when I zoomed in on one of the corners:

$$n=6$$: Needless to say, the wiggly effect has been amplified. For comparison, here's the $$n=6$$ graph of $$p([1,2,...,31])$$:

$$n=7$$: Which is very far from well behaved. I think its 'supposed' to look something like the graph of $$p([1,2,...,105])$$: Although even that has some drifty looking points.

You can look at more of these graphs by changing the value of $$n$$ on this graph.

Questions:

At this point I'm fairly certain that the strange behavior (as demonstrated by the cases $$n=5,6,7$$) can be attributed to the accumulating numerical inaccuracies of Desmos. For example, Wolfram evaluates $$A=\sum_{r=1}^{700}\exp[2i\pi H_{7}(r)]$$ as $$A= -11.470821630307989891763598910658573978486117477630759175... - 3.6768673678262517039383839969453158461799151084757854088... i$$ (and provides a monstrous closed form. Whereas Desmos puts the sum at the wildly incorrect $$1.3535617164+9.88880050357i$$ I did the same sort of test with $$B=\sum_{r=1}^{20}\exp[2i\pi H_5(r)]$$ and Wolfram gave $$B=-6.3944653536668510841041628532095052345320229467766883302... + 1.0127838162151622424794134150036094634983505690619992502... i$$ And Desmos gave $$-6.39446535424+1.01278381623i$$ Which is conclusive evidence that Desmos gets less accurate as $$n$$ and $$x$$ get larger.

That was the subject of my original question, but it seems to have been resolved by now.

So my question is how do we find a general formula for $$\pi_n\in\Bbb N$$ such that $$\forall k\in\Bbb N,\quad f_n(k+\pi_n)=f_n(k)$$ where $$f_n(k)=\sum_{\ell=1}^{k}\exp[2i\pi H_n(\ell)]$$ I found the first few values: $$\pi_2=2\\ \pi_3=6\\ \pi_4=6\\ \pi_5=30\\ \pi_6=30$$ But there's got to be some other way to do this. Any help is appreciated.

• $f(x) = x/20 + x^2/9+x^3/59, f(x+1)-f(x) = 27 x^2/531 + 145x/531+1891/10620$, $a(n) = e^{2i \pi f(n)}, A(n) = \sum_{l=1}^n a(l), a(531k+ n) = a(531 k) e^{2i \pi (f(n+531k)-f(531 k))}$ the point is that $e^{2i \pi (f(n+531k)-f(531 k))} = \prod_{l=1}^n e^{2i \pi (f(l+531k)-f(531 k+l-1))}$ doesn't depend on $k$ so $A(531k+n) = A(531k)+a(531 k) A(n)$ and the plot repeats itself at an angle $a(531k)$ and origin $A(531k)$ – reuns Apr 26 at 0:25

If we focus on the equation $$f(k)=\sum_{l=1}^k e^{\imath 2 \pi H(l)}$$ for some function $$H(x)$$ and search for an integer $$\Delta$$ such that $$\forall k \in \mathbb{N} \qquad f(k+\Delta) = f(k),$$ we find $$\begin{eqnarray} 0 & = & \left[ f(k+1+\Delta) - f(k+1) \right] - \left[f(k+\Delta) - f(k) \right]\\ & = & \left[ f(k+1+\Delta) - f(k+\Delta) \right] - \left[f(k+1) - f(k) \right]\\ & = & e^{\imath 2 \pi H(k+1+\Delta)} - e^{\imath 2 \pi H(k+1)} \end{eqnarray}$$ Hence, we find that the problem reduces to finding an integer $$\Delta$$ such that $$\forall k \in \mathbb{N} \qquad H(k+\Delta) - H(k) \in \mathbb{Z}.$$ If we restrict ourselves to $$H(x)$$ being a polynomial of degree $$n$$ with rational coefficients, it can be formulated as: $$H(x) = \frac{1}{N} \sum_{i=0}^n a_i x^i,$$ for some $$N,a_i \in \mathbb{Z}$$ and there is no common divisor in the set of $$\{a_i\}$$. It follows that $$\begin{eqnarray} H(k+\pi) - H(k) & = & \frac{1}{N} \sum_{i=0}^n a_i \left[(\Delta+k)^i - k^i \right]\\ & = & \frac{1}{N} \sum_{i=0}^n a_i \sum_{j=1}^i \binom{i}{j} \Delta^j k^{i-j}\\ & = & \frac{\Delta}{N} \sum_{i=0}^n a_i \sum_{j=0}^{i-1} \binom{i}{j+1} \Delta^j k^{i-j-1} \in \mathbb{Z} \qquad (*) \end{eqnarray}$$ and hence that the denominator $$N$$ of the rational polynomial $$H(x)$$ is a correct solution for $$\Delta$$.
Note, however, that $$N$$ is not necessarily the smallest solution for $$\Delta$$, but that the smallest solution for $$\Delta$$ will have to be a divisor of $$N$$. In fact, the series of polynomial $$H_n(x)=\sum_i \frac{x^i}{i}$$ would have the corresponding denominators $$N_n=2,6,12,60,60,\dots$$ for $$n \geq 2$$ and the OP already established that there are smaller solutions.
Finding the smallest solution of $$\Delta$$ is relatively straightforward, as one can simply check the validity of $$(*)$$ for all $$k$$ by dividing out respective (prime)factors $$d$$ from $$N$$, i.e., if $$N = d \Delta$$ than $$(*)$$ requires that $$\sum_{i=0}^n a_i \sum_{j=0}^{i-1} \binom{i}{j+1} \Delta^j k^{i-j-1} \equiv 0 \mod d \qquad \forall k \in \mathbb{N}$$ for which it is sufficient to check the values $$0 \leq k < d$$.