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.



Approximating the sum $\sum_{n \leq X} a_n$ with a smooth sum $\sum_{n \geq 1} a_n w(X)$
In Section 11.8 of Harman's book "Prime-Detecting Sieves", he introduced an infinitely differentiable function $\psi\_1(t)$ on $\mathbb{R}$ such that $\psi\_1(t)\in[0, 1]$ for all $t$ and
$$
\psi\_1(t)=\left\{
\begin{array}{lr}
1\text{ if }x-y+\Delta\_1\le t\le x-\Delta\_1,\\
0\text{ if }t\not\in(x-y, x)
\end{array}
\right.
$$
with
$$
\psi^{(j)}(t)\ll\_j\Delta\_1^{-j}\text{ for }j=1, 2, ...
$$
where $\Delta\_1=yx^{-\eta}$ for some $\eta>0$. But the construction, which he gave in the appendix of the book, works for very general $x, y$ and $\Delta\_1$. For example, you can choose $x=y$ and $\Delta\_1$ to be a suitable power of $x$. As another example, in Fouvry and Iwaniec's paper "Gaussian Primes" (p. 257), they estimated the sum
$$\sum\_{\substack{n\equiv0\pmod d\\n\leq x}}a\_n$$
by comparing it to
$$\sum\_{n\equiv0\pmod d}a\_nf(n)$$
where $f$ is a suitable smooth function. Then they applied Poisson's summation to transform and estimate the latter sum (where the bounds on the derivatives of $f$ play an important role). And since $f(n)=1$ for most $n$ (say, for all $0\le n\le x^{1-\epsilon}$) and $|1-f(n)|\le1$ for all $n$, so the sum
$$\sum\_{\substack{n\equiv0\pmod d\\n\leq x}}a\_n(1-f(n))$$
can be shown to be small.


