Asymptotic Behaviour Of A Bizarre Function It is relatively easy to show that the asymptotic behaviour of $f(x)$, where
$$ f(x)= \left[\frac{x}{2}\right] + \left[\frac{x}{4}\right] + \left[\frac{x}{8}\right] + \left[\frac{x}{16}\right] + \cdots $$ is given by $$f(x)\sim x $$
( $[t]$ is the floor function)
However, I wonder what the second term in the asymptotic expansion of $f(x)$ is. So, if $$ f(x)=x-e(x)$$ where $e(x)$ is the error function and $$e(x)=o(x) $$ what is the asymptotic behaviour of $e(x)$? Can anyone find it and prove their result?
Edit: I have changed the sign of the error function in the definition since most of you were considering $x-f(x) $ as your error term and it is more natural anyways, since $f(x)$ is always slightly less than $x$. Also, I add on what I already can prove. For positive $x$, all the terms are positive. Hence, if we add up the first, say, $n$ terms, we will obtain a lower bound of f(x). The lowest possible value of these first $n$ terms would be:
$$ f(x)= \frac{x}{2} -1 + \frac{x}{4} -1 + \frac{x}{8} -1  + \cdots + \frac{x}{2^n} -1 = x\frac{2^{n}-1}{2^n} -n $$ Hence the maximum value of $e(x)$ is given by:
$$e(x) < x - (x\frac{2^{n}-1}{2^n} -n) = \frac{x}{2^n} + n  $$ We are free to chose any $n$ to make the bound as tight as possible. The bound has no maximum for large $n$, so taking its derivative and setting it equal to zero gives a value of $n$ for which the bound is tightest:
$$ 0 = 1 - x\frac{\ln 2}{2^n} $$ which yields
$$ n = \frac{\ln x + \ln ln 2}{\ln 2} $$ but we can only take integer $n$, so for optimising the bound we take the closest integer, resulting in:
$$ n = \frac{\ln x + \ln ln 2}{\ln 2} + t $$ where $ -\frac{1}{2} \leq t \leq \frac{1}{2} $ Hence the upper bound for $e(x)$ becomes
$$e(x)< \frac{\ln x}{\ln 2} + \frac{\ln ln 2}{\ln 2} + t + \frac{2^{-t}}{\ln 2} = O(\ln x) $$ I admit that Christian Blatter's proof can reach the same result and is simpler, but I just wanted to show what I had before posting the question.
Edit 2: Will Jagy, I've just realised the full consequences of your comment on the exponent of 2 in $[x]!$. It implies that $$f(x)=f([x]) $$ Hence it is sufficient to understand $f(x)$ for integer values!
Edit 3: The bound only holds for positive $x$. $$f(x)=-\infty$$ for all negative $x$
Edit 4: Will Jagy, indeed, for natural $x$, the error function $e(x)$ is equal to the amount of 1s in the binary expansion on $x$, or equivalently the sum of its digits in its binary expansion, as can be seen by writing $x$ as a sum of powers of two(binary).  That also easily proves the observation on $2^k -1$(all 1s in binary) and also proves the bound of $\frac{\ln x}{\ln 2}$ for the error function and explains why your "ties" increase by 1. Neat.
 A: When $x<0$ then $f(x)=-\infty$, since an infinite number of terms is $=-1$.
It is easy to check that for all $n\geq0$ one has
$$\left\lfloor{x\over 2^n}\right\rfloor =\left\lfloor{\lfloor x\rfloor\over 2^n}\right\rfloor\ .\tag{1}$$
Therefore it is enough to consider integer $x\geq0$. Each such $x$ has a well defined binary representation
$$x=\sum_{k\geq0}b_k\>2^k,\qquad b_k\in\{0,1\}\ ,\tag{2}$$
whereby only finitely many $b_k$ are $\ne0$. Put $\sum_{k\geq0} b_k=: s(x)$.
We shall prove that for integer $x\geq0$ one has $$f(x)=x-s(x),\tag{3}$$ so that together with $(1)$ one obtains
$$f(x)=\lfloor x\rfloor -s\bigl(\lfloor x\rfloor\bigr)\qquad(x\in{\mathbb R}_{\geq0})\ .$$
One has $s(x)=O(\log x)$ for $x\to\infty$, but $(s(2^n)=1$ for all $n\geq0$.
Proof of $(3)$: From $(2)$ it follows that
$$\left\lfloor{x\over 2^n}\right\rfloor=\left\lfloor\sum_{k\geq0}b_k\>2^{k-n}\right\rfloor=\sum_{k\geq n}b_k\>2^{k-n}\ .$$
Therefore we obtain
$$f(x)=\sum_{n=1}^\infty\left\lfloor{x\over 2^n}\right\rfloor=\sum_{n=1}^\infty\sum_{k\geq n}b_k\>2^{k-n}=\sum_{k\geq1}b_k\>2^k\sum_{n=1}^k 2^{-n}\ .$$
This can be rewritten as
$$f(x)=\sum_{k\geq1}b_k2^k(1-2^{-k})=\sum_{k\geq0}b_k\>2^k-\sum_{k\geq0}b_k\ ,$$
as claimed.
