Asymptotic Behaviour Of A Bizarre Function 2

It is well-known that $$\frac{1}{1}-\frac{1}{2}+\frac{1}{3}-\frac{1}{4}+\cdots = \ln 2 $$ Hence $$\frac{x}{1}-\frac{x}{2}+\frac{x}{3}-\frac{x}{4}+\cdots= x\ln 2 $$ However, consider $f(x)$, where $$f(x)=\left\lfloor\frac{x}{1}\right\rfloor-\left\lfloor\frac{x}{2}\right\rfloor+\left\lfloor\frac{x}{3}\right\rfloor-\left\lfloor\frac{x}{4}\right\rfloor+\cdots $$ and $\lfloor t\rfloor$ denotes the floor function. Can anyone determine and prove the asymptotic behaviour of $f(x)$? Maybe even a good error term as well or even the second term in the asymptotic expansion? I'm guessing that $$ f(x) \sim x \ln 2$$ but cannot prove it.

Edit: I believe I may have solved my own problem. The infinite sum is equal to the limit of the partial sum as the amount of terms tends to infinity. The first $n$ terms can be approximated by dropping the floor function signs at a cost of an error of $O(n)$, leaving one with $$\frac{x}{1}-\frac{x}{2}+\frac{x}{3}-\frac{x}{4}+\cdots + (-1)^{n+1}\frac{x}{n} + O(n)$$ The alternating sum multiplied by $x$ is almost $ x \ln 2$ and the error in approximating the partial sum as the infinite sum is $O(\frac{1}{n})$, since the series is alternating. Hence, the error introduced by approximating $$ \frac{x}{1}-\frac{x}{2}+\frac{x}{3}-\frac{x}{4}+\cdots + (-1)^{n+1}\frac{x}{n}$$ as $x \ln 2$ is $O(\frac{x}{n})$ and so the nth partial sum is equal to $$ x \ln2 + O\left(\frac{x}{n}\right) + O(n)$$ But $n$ is independent of $x$ and so we minimise the error by letting $n=\sqrt x$ giving the final result $$f(x)= x \ln2 + O(\sqrt x) $$ I believe I have made no mistake in this solution.


Solution 1:

I can't leave comments (not enough reputation), so I'm writing here. If I understand you correctly (which I'm not sure I am), I believe your solution in incorrect. For example, for positive integers it seems that $f(2n-1)=f(2n)=n$ (e.g. $f(3)=f(4)=2$), so it can't be true that $f(x)$ is asymptotically $x\ln2$. I think that a useful observation is that generally, for an integer $n$, we get $f\left( n \right)=\sum\limits_{k=1}^{n}{{{\left( -1 \right)}^{k-1}}\left\lfloor \frac{n}{k} \right\rfloor }$ (later terms are all zeros). So the number of nonzero terms in the series is a function of $x$ (and specifically, for every $x$ we get a finite sum - so "taking a limit" becomes trivial). I'm guessing (just guessing) that for positive reals, $f(x)$ is probably (identically) the step function that corresponds to the restriction of $f(x)$ to the integers.