I have a sequence $a_n$ such that $0 \leq a_n \leq \log n$, and I am considering $\sum_{n \leq X} a_n$. However, I prefer using smooth weights so I would like to approximate it with $\sum_{n \geq 1} a_n w(X)$.

I guess what I would like is a nice function $w$ such that $$ E(X) = | \sum_{n \leq X} a_n - \sum_{n \geq 1}a_n w(X) | $$ is "small" and that the derivative is "not too big". I know this is a bit vague, but I was wondering what $w$ is out there that I can achieve these two things as well as possible... Any comments would be appreciated.

PS alternatively I was curious about what I can expect, as in if I wanted $E(X) < X^{c}$, $0 < c<1$ then what is the best I can hope for for the upper bound of $|w'(x)|$? and vice versa. Thank you.