TITLE: Euler Maclaurin summation examples?
QUESTION [5 upvotes]: How does one use Euler Maclaurin to compute asymptotics for sums like
$$ \sum_{\substack{n\le x \\ (n,q)=1}} \frac{1}{\sqrt{n}} \quad \text{or} \quad \sum_{\substack{n\le x \\ (n,q)=1}} \frac{\log n}{\sqrt{n}}?$$

REPLY [2 votes]: We can actually get an additional term using the Wiener-Ikehara theorem.
Introduce the Dirichlet Series $A(s)$ whose terms are given by the indicator $(n, q) =1$ times $1/\sqrt{n}$. We have
$$ A(s) = \sum_{(n,q)=1} \frac{1/\sqrt{n}}{n^s} =
\sum_{(n,q)=1} \frac{1}{n^{s+\frac{1}{2}}} =
\prod_{p\nmid q} \frac{1}{1-\frac{1}{p^{s+\frac{1}{2}}}} = 
\zeta\left(s+\frac{1}{2}\right) \prod_{p\mid q} 
\left(1-\frac{1}{p^{s+\frac{1}{2}}} \right),$$
where $p$ ranges over the primes.
Furthermore, introduce
$$ B(s) = A(s) - 
\zeta\left(\frac{1}{2}\right) \prod_{p\mid q} \left(1-\frac{1}{\sqrt{p}}\right)$$
This Dirichlet series differs from $A(s)$ in its constant term and converges in $\mathfrak{R}(s) \ge \frac{1}{2}.$ It has a simple pole at $\frac{1}{2}$ and is zero at $s=0.$ Wiener-Ikehara applies to $B(s)$, giving
$$\sum_{k\le n,(k,n)=1} \frac{1}{\sqrt{k}} 
- \zeta\left(\frac{1}{2}\right) \prod_{p\mid q} \left(1-\frac{1}{\sqrt{p}}\right)
\sim \prod_{p\mid q} \left(1-\frac{1}{p}\right) \frac{\sqrt{n}}{1/2} =
2 \frac{\phi(q)}{q} \sqrt{n}.$$
We construct the zero at $s=0$ because we are actually working with the Mellin-Perron type integral
$$\int_{1-i\infty}^{1+i\infty} B(s) n^s \frac{ds}{s}$$
and need to cancel the pole at $s=0$.
The conclusion is that
$$ \sum_{k\le n,(k,n)=1} \frac{1}{\sqrt{k}} \sim
2 \frac{\phi(q)}{q} \sqrt{n} +
\zeta\left(\frac{1}{2}\right) \prod_{p\mid q} \left(1-\frac{1}{\sqrt{p}}\right)$$
The numerics of this approximation are excellent even for small values of $n$.