TITLE: Logarithmic weights on number theoretic sums
QUESTION [6 upvotes]: Suppose we are interested in the sum
$\sum _{n\leq x}a_n.$
The study of the sum
$\sum _{n\leq x}a_n\log (x/n)$
may be easier.
What can one say about the first sum from knowing the behaviour of the second?  
In the case I have in mind, I have
$\sum _{n\leq x}a_n\log (x/n)=x+\mathcal O\left (x^{1/2}\right )$
and would like a similar result for the sum without weights.  
How feasible is this?  I'm quite sure an asymptotic formula holds for the sum without weights, but I don't know if I should expect to lose a power saving.  (Logarithms and epsilons in the error are not of concern.)
I'm not sure which properties exactly of the $a_n$ are important.  It may be useful that they are all non-negative.  
Any pointers as to what one should expect in such a situation would be very much appreciated.  
If it seems that one can't really say much without knowing at least something more about the $a_n$ I can give some more details.  But I think my problem has more to do with the fact that I'm lacking some general principles in dealing with weights, so I'll leave the $a_n$ arbitrary for now.
Thanks very much in advance.

REPLY [7 votes]: Put $A(x) =\sum_{n\le x} a_n$, and $B(x) =\sum_{n\le x} a_n\log x/n$.  Then 
$$ 
B(x) = \int_1^x A(t)\frac{dt}{t}. 
$$ 
So information about $A(x)$ readily translates to information about $B(x)$ and there is no loss since integration (which makes things smoother) is involved.  But to pass from $B(x)$ to $A(x)$ we need to differentiate, and based on the situation this could be either impossible, or could involve some loss.  
Suppose first that the $a_n$ are bounded.  Then 
$$ 
B(x+h) - B(x) = \int_{x}^{x+h} A(t) \frac{dt}{t} = (A(x)+O(h)) \log\frac{x+h}{x}, 
$$ 
and choosing $h=x^{3/4}$ we obtain $A(x)=x+O(x^{\frac 34})$.  This was noted in Alpoge's comment above, and also holds if the $a_n$ are given to be non-negative rather than bounded.  However there is a loss in this argument and the $x^{3/4}$ error term cannot be improved, even for bounded non-negative $a_n$.  Here is an example:  Take $a_n=2$ if $n \in [m^4,(m^4+(m+1)^4)/2)$ for some integer $m$, and $a_n=0$ if $n\in ((m^4+(m+1)^4)/2,(m+1)^4)$.  Then you can check that $B(x) = x +O(x^{\frac 12})$ holds, but no estimate sharper than $A(x) = x +O(x^{\frac 34})$ can hold.  
Finally without some restrictions on $a_n$, one can say nothing at all.  For example, take $a_n=1+ (-1)^n n$.  Then you can check that $A(n)$ alternates between about $n/2$ and about $3n/2$, whereas $B(n)$ is very close to $n$.