Fractal dimension of the function $f(x)=\sum_{n=1}^{\infty}\frac{\mathrm{sign}\left(\sin(nx)\right)}{n}$

We can prove the convergence almost everywhere using the following

Theorem: Let $\varphi $ a function such that $$\varphi\left(x\right)\in L^{2}\left(-\pi,\pi\right),\,\varphi\left(x+2\pi\right)=\varphi\left(x\right),\,\int_{0}^{2\pi}\varphi\left(x\right)dx=0.$$ Assume that $$\sup_{0<h\leq\delta}\left(\int_{0}^{2\pi}\left|\varphi\left(x+h\right)-\varphi\left(x\right)\right|^{2}dx\right)^{1/2}=O\left(\delta^{1/2}\right) $$ and let the sequence of real numbers $\left(a_{n}\right)_{n} $ such that $$\sum_{n\geq2}a_{n}^{2}\log^{\gamma}\left(n\right)<\infty,\,\gamma>3 $$ then the series $$\sum_{n\geq1}a_{n}\varphi\left(nx\right) $$ converges almost everywhere.

(For a reference see V. F. Gaposhkin, “On series relative to the system $\left\{ \varphi\left(nx\right)\right\} $”, Mat. Sb. (N.S.), $69(111)$:$3$ ($1966$), $328–353$)

So it is sufficient to note that $\varphi\left(x\right)=\textrm{sign}\left(\sin\left(x\right)\right) $ verifies the conditions and $$\sum_{n\geq2}\frac{\log^{\gamma}\left(n\right)}{n^{2}}<\infty $$ for all $\gamma>0 $. So we have that $$\sum_{n\geq1}\frac{\textrm{sign}\left(\sin\left(nx\right)\right)}{n}. $$ converges almost everywhere.

At zero an heuristic argument can be that for all $M>0 $ exists some $\delta>0 $ such that, if $0<x<\delta $, we have $$M<\sum_{n\geq1}\frac{\textrm{sign}\left(\sin\left(nx\right)\right)}{n}$$ because if $x$ is “small” we have $\textrm{sign}\left(\sin\left(nx\right)\right)=1$ and so, since $\sum_{n\geq1}\frac{1}{n}$ diverges, we can find a sufficient small $\delta$ such that the series is bigger than every fixed $M$ and the negative contributions are too “small” for a significant cancellation.


The series certainly converges when $x$ is a rational multiple of $\pi$, say $x=p\pi/q$ where $p/q$ is in lowest terms. Here is an outline of a proof of this using Dirichlet's test.

The numbers $$\alpha_k = k\,\pi\frac{p}{q} \mod 2\pi$$ form a group under addition. In particular, each element $\alpha$ has an additive inverse $\beta$ with the property that $\sin(\alpha)=-\sin(\beta)$. As a result, the sequence $(\alpha_k)_k$ is periodic with the same number of positive and negative ones in a period. Thus, if we define $$b_n = \text{sign}(\sin(n\pi p/q)),$$ it's easy to see that the sequence $$S_N = \sum_{n=1}^N b_n$$ is bounded. We can now apply Dirichlet's test (as stated in the link above) using $a_n=1/n$.

I suspect that a similar argument will work for irrational multiples of $\pi$ using uniform distribution of $nx\mod 2\pi$. I also suspect that such an argument might be very hard and depend on how well approximable $x/\pi$ is by rationals.

Returning to rational multiples of $\pi$, these types of sequences can be computed in closed form using various tricks involving transforms of the harmonic sequence. At $x=\pi/2$, for example, the series reduces to $$\sum_{n=0}^{\infty} \frac{(-1)^{n}}{2n+1}=1-\frac{1}{3}+\frac{1}{5}-\frac{1}{7}+\cdots = \frac{\pi}{4}.$$ At $x=2\pi/3$, the sum is $$\sum _{n=0}^{\infty } \left(\frac{1}{3 n+1}-\frac{1}{3 n+2}\right) = \frac{\pi }{3 \sqrt{3}}.$$ There is a key difference between these two series, however. For the first we have $$\left\{\text{sign}(\sin(n\pi/2))\right\}_{n=1,2,3,4} = \{1,0,-1,0\}.$$ which has two zeros. Numbers close to $\pi/2$ but just a little less will start with the pattern $\{1,1,-1,-1\}$. Numbers very close to and less than $\pi/2$ will maintain this pattern in the sum for a long time and result in a sum that's close to $$\sum _{n=0}^{\infty } \left(\frac{1}{4 n+1}+\frac{1}{4 n+2}-\frac{1}{4 n+3}-\frac{1}{4 n+4}\right) = \frac{1}{4} (\pi +\log (4)) \approx 1.13197.$$ Numbers close to $\pi/2$ and just above will yield a sum close to $$\sum _{n=0}^{\infty } \left(\frac{1}{4 n+1}-\frac{1}{4 n+2}-\frac{1}{4 n+3}+\frac{1}{4 n+4}\right) = \frac{1}{4} (\pi -\log (4)) \approx 0.438825.$$ This leads to the appearance of a jump discontinuity at $\pi/2$ where the actual value is, in fact, between the two.

For $x=2\pi/3$, by contrast, we have $$\left\{\text{sign}(\sin(2n\pi/3))\right\}_{n=1,2,3} = \{1,-1,0\},$$ which has just one zero. For values of $x$ close to $2\pi/3$ but just a little less, the sequence starts $\{1,-1,-1\}$ and we can make the partial sums as large in absolute value as we like (but negative) by choosing $x$ to be sufficiently close to $2\pi/3$. On the other side of $2\pi/3$ the sequence is $\{1,-1,1\}$ and we have similar but positive behavior. This leads to the appearance of an asymptote like feature at $2\pi/3$.

Note that these arguments are not complete. The argument near $2\pi/3$ is very much like Marco's argument near zero. Detailed analysis for irrational multiples of $\pi$ is likely to be quite sensitive and require a strong knowledge of uniform distribution of sequences mod $2\pi$. I also suspect that both behaviors are genuine and dense in the real line.

Finally, I don't think that fractal dimension is a reasonable concept to apply here. While certain parts of the graph look like other parts, self-similar sets and their generalizations are compact sets. This set is neither closed nor bounded. Neither similarity dimension nor box-counting dimension will be well-defined here. Hausdorff dimension will, I suppose, be defined. I don't think it's likely to be easy to compute, though. The Hausdorff dimension of Weiestrass's function is an open question.


Although I've already selected one of the excellent answers above, I thought I'd post an answer that I figured out to one of the questions I posed in the original post, namely: "I would guess that it diverges as $x\rightarrow 0_+$. How does it diverge there?"

So, as noted above, the term $\mathrm{sign}(\sin(n x))$ is a square wave with period $2\pi/n$. Suppose $x/\pi$ is irrational. Then $\mathrm{sign}(\sin(n x))$ is always -1 or +1, never 0. Define $$ \phi(x,k) = \left\lfloor \frac{k\pi}{x} \right\rfloor $$ as the largest integer such that $\phi(x,k) \, x < k \pi$. Defining $H_m$ as the $m^{\mathrm{th}}$ harmonic number, the original series can then be divided into finite positive and negative subsequences of terms of the form $\pm 1/n$ and rewritten as \begin{align} f(x) &= \sum_{n = 1}^{\phi(x,1)} \frac{1}{n} \;-\;\sum_{n = \phi(x,1)+1}^{\phi(x,2)} \frac{1}{n} \;+\;\sum_{n = \phi(x,2)+1}^{\phi(x,3)} \frac{1}{n} \;-\; ...\\ &= H_{\phi(x,1)} - \left(H_{\phi(x,2)} - H_{\phi(x,1)}\right)+ \left(H_{\phi(x,3)} - H_{\phi(x,2)}\right) - ...\\ &= H_{\phi(x,1)} \;+\; \sum_{n = 1}^{\infty}{(-1)}^n\left(H_{\phi(x,n+1)} - H_{\phi(x,n)}\right) \end{align} for irrational $x/\pi$. In fact, this last expression can be used to calculate the original function. Although this harmonic number representation is ostensibly only valid for irrational $x/\pi$, it seems to overlay the original function very nicely, as shown below:

Plot of original function overlaid by the function as represented by a series of harmonic number terms Now, as to the divergence for small $x$. When $x$ is small, $\phi(x,n)$ becomes large, and we have \begin{align} H_{\phi(x,n)}&\approx \ln\left(\phi(x,n)\right) + \gamma\\ &= \ln\left(\left\lfloor \frac{n\pi}{x} \right\rfloor\right) + \gamma\\ &\approx \ln\left(\frac{n\pi}{x}\right) + \gamma\, . \end{align} The above expression for $f(x)$ then reduces to $$ f(x) \approx \ln\left(\frac{\pi}{x}\right) + \gamma + \sum_{n=1}^{\infty}{(-1)}^n \ln\left(1 + \frac{1}{n}\right)\, , $$ where \begin{align} \sum_{n=1}^{\infty}{(-1)}^n \ln\left(1 + \frac{1}{n}\right) &= \ln\left(\prod_{n=1}^{\infty}\left(1 - \frac{1}{4n^2}\right)\right)\\ &= \ln\left(\frac{2}{\pi}\right)\qquad \text{By the Wallis product}\, . \end{align} The small-$x$ approximation then reduces to $$ f(x) \approx -\ln x \;+\; \gamma \;+\; \ln 2\, . $$ This is plotted below along with the original function. Original function along with small-x log approximation So the answer is: A logarithmic divergence as $x\rightarrow 0_+$.