Consider the function $f_{p_j,n}(x)=|\sin (p_1x)+\sin (p_2x)+\dots+\sin (p_nx)|$ where $p_j$ is any sequence such that no two $p$ are rational multiples of each other where the $p_j$ are linearly independent over $\mathbb{Q}$ (so the function is almost periodic). (After reading @mollyerin's answer, I changed the condition on $p_j$.)
For example, here is the graph of $f_{2^{1/j},\color{red}{5}}(x)$ :
And here is the graph of $f_{2^{1/j},\color{red}{10}}(x)$ :
I call this kind of function $f_{p_j,n}(x)$, the "Mountains of Guilin".
Now consider the mean value of $f_{p_j,n}(x)$. I have evidence that suggests that:
- For any given value of $n$, the mean value of $f_{p_j,n}(x)$ is independent of the choice of sequence $p_j$ (as long as the $p_j$ are linearly independent over $\mathbb{Q}$).
- The mean value of $f_{p_j,\color{red}{2}}(x)$ is $8/\pi^2$.
I have not been able to find a general expression for the mean value of $f_{p_j,n}(x)$ in terms of $n$, but I have the following conjecture:
$$\color{red}{\lim_{n\to\infty}\frac{\text{mean value of $f_{p_j,n}(x)$}}{\sqrt n}=\frac{1}{\sqrt \pi}}$$
Is my conjecture true?
Numerical evidence for my conjecture:
Using desmos, I approximated the mean value of $f_{2^{1/j},n}(x)$ as $M_n=\frac{1}{10^7}\sum\limits_{k=1}^{10^7}|\sin (2^1k)+\sin (2^{1/2}k)+\dots+\sin (2^{1/n}k)|$
Letting $L(n)=\dfrac{M_n}{\sqrt n}$, we have:
$L(1)\approx 1.128379\left(\frac{1}{\sqrt \pi}\right)$
$L(2)\approx 1.015898\left(\frac{1}{\sqrt \pi}\right)$
$L(10)\approx 1.006373\left(\frac{1}{\sqrt \pi}\right)$
$L(100)\approx 1.000334\left(\frac{1}{\sqrt \pi}\right)$
This suggests that my conjecture may be true, but I don't know how to prove it.
Visual representation of the mean value:
If my conjecture is true, then there is a nice way to visually represent the mean value of the function. Draw a circle of area $n$ with its centre on the $x$-axis. A horizontal line through the top of the circle represents, approximately, the average value of the function.