TITLE: Is it already known that $\sum_{i=1}^x\cos(S(i))\sim ax\cos(b\ln x)$, as $x\to\infty$, where $S(i)$ is the number of Collatz steps from $i$ to $1$?
QUESTION [18 upvotes]: I was playing with the Collatz Conjecture today, and empirically found a curious behaviour:
Let $S(i)$ be the function that calculates the number of steps needed for $i$ to reach $1$:
It seems that
$\sum\limits_{i=1}^{x} \cos(S(i)) \sim ab\displaystyle\int_{1}^{x} \cos(b\ln(cu)) \,du   \sim ax\cos(b\ln(x)), \,\, x \rightarrow \infty, \,\ x \in \mathbb{N}$
Where $\,\,a \approx 0.0754, \,\, b \approx 10.4404, \,\, c \approx 2.102$
The constants have been found empirically while trying to minimize the error between the functions, and do not necessarily correspond to the correct ones.
Graphical evidence up to $2 \cdot10^6$:

Were these facts already known? If not, I conjecture they're true, it's just a matter of finding the correct constants $a,b,c$. Why do you think they behave like this?

REPLY [3 votes]: Here is non-rigorous heuristic approach-
The values of $S(x)$ are random locally, but we can make a global estimate $s(x)$. In half the cases, $x$ is even, where we get $S(x)=1+S(\frac{x}{2})$. In the other half of cases, we get $S(x)=2+S(\frac{3x+1}{2})$. Thus:
$$s(x)=\frac{1}{2}(1+s(\frac{x}{2})) + \frac{1}{2}(2+S(\frac{3x}{2}))$$
Taking $u=\frac{3x}{2}$, we have:
$$s(u) = 2s(\frac{2u}{3}) - s(\frac{u}{3}) - 3$$
We can see that $s(x)$ must grow logarithmically. Let us estimate $s(x)=b\log{x}$. Then, our equation above gives us the constraint:
$$b\log{u} = 2b(\log{u}+\log{2}-\log{3}) - b(\log{u}-\log{3}) - 3$$
$$b(2\log{2}-\log{3}) = 3 \implies b = \frac{3}{2\log{2}-\log{3}} \approx 10.43$$
Now, we have a rough estimate for $S(i)$, given by $s(i)$. Let's try to use this to estimate our summation:
$$f(x) = \sum_{i=1}^x \cos(S(i)) \approx \sum_{i=1}^x \cos(s(i)) = \sum_{i=1}^x \cos(b\log{i}) \sim \int_1^x \cos(b\log{u}) du$$
Evaluating the integral, we get:
$$f(x) \approx \frac{bx\sin(b\log{x})+\cos(b\log{x})}{b^2+1} \sim \bigg(\frac{b}{b^2+1}\bigg)x\sin(b\log{x})$$
Since phase changes do not affect the estimation much, we get something of the form $ax\cos(b\log{x})$, where $a=\frac{b}{b^2+1} \approx 0.095$.
Our values of $b$ match, but the values of $a$ do not. I am unsure why this happens. Maybe this method can be refined to get more accurate values, or I have made a mistake in the calculation, or the experimental value of $a$ will approach the estimated value.