Context:

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

David's profile picture, a pretty complex shape with 20-fold rotational symmetry

"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$: Coordinate system with red line from -1 to 0

$n=3$: Coordinate system with regular hexagon whose upper horizontal line goes from -1 to 0

$n=4$: Three-pointed star containing the same line

$n=5$: Zig-zag circle (15-pointed star with inner circle close to outer circle) 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: Magnification of one corner of the above, showing that each line and corner is really many close lines and corners

$n=6$: Pretty complex shape Needless to say, the wiggly effect has been amplified. For comparison, here's the $n=6$ graph of $p([1,2,...,31])$: Shape with 5-fold symmetry, looking somewhat like a paddle wheel with attached triangles

$n=7$: Another pretty complex shape Which is very far from well behaved. I think its 'supposed' to look something like the graph of $p([1,2,...,105])$: Another paddle wheel with attached triangles, now with 17 paddles 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$ grow.

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.


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+\Delta) - 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$.

Addendum: In view of the observation by the OP (25/10/2019) that the periods $\pi_n$ appear to be the primorial numbers. We consider the particular set of functions $$ H_n(x)=\sum_{k=1}^n \frac{x^k}{k} $$ more closely. The goal is to find the smallest $\pi_n$ such that $H_n(x+\pi_n) - H_n(x) \in \mathbb{Z}$ for all $x$. In order to do so, we focus on the simpler set of functions $f_n(x)=\frac{x^n}{n}$ and find their corresponding period. This is equivalent to solving the smallest $\pi$ for which $$ (x+\pi)^n \equiv x^n \mod n \qquad\text{for all $x$}\qquad (**) $$ In particular this should be true for $x=0$, and hence $n\# | \pi$, where the primorial $n\#$ is the product of all its prime factors $$ n\# = \prod_{\text{prime } p \leq n} p $$ In what follows we will see that $\pi=n\#$ is sufficient and therefore the smallest positive solution.

First we will show that for any prime $p$ and non-negative integer $l$, we find that for any integer $x$ $$ p^{l+1} | (x+p)^{p^l} - x^{p^l} $$ This follows from induction by realising that for $l=0$ it says $p|(x+p)-x$ and the general factorisation expression $$ \frac{(x+p)^{p^{(l+1)}} - x^{p^{(l+1)}}}{(x+p)^{p^l} - x^{p^l}} = (x+p)^{p^l(p-1)} + (x+p)^{p^l(p-2)}x^{p^l} + \cdots + x^{p^l(p-1)} \equiv p x^{p^l(p-1)} \equiv 0 \mod p $$

It follows that for $n=p^l m$ with any prime factor $p$, and co-prime integer $m$ we get $$ (x+p)^n = \left[(x+p)^{p^l}\right]^m \equiv \left[x^{p^l}\right]^m = x^n \mod p^l $$ and therefore also any period that is a multiple of $p$ would equally be allowed, in particular $$ (x+\pi)^n \equiv x^n \mod p^l. $$ Since this is valid for every prime $p|n$ we have proven (**).

It therefor follows that the smallest period $\pi$ for the function $f_n(x)=\frac{x^n}{n}$ is given by $$ \pi = n\# = \prod_{\text{prime } p|n} p $$

As a direct consequence, we can also conclude that for $H_n(x)$ the corresponding primorial $\pi_n$ will satisfy $H_n(x+\pi_n)-H_n(x) \in \mathbb{Z}$, because it is true for each of its individual terms.

However, the constraint on the periods of all of the individual terms in $H_n(x)$ is more restrictive than the case where it only needs to hold for their combination within $H_n(x)$ itself. Hence, although the primorial $\pi_n=n\#$ is indeed a correct solution, we can not yet conclude that it is also the smallest solution for $H_n(x)$.