Let $M$ be a large positive integer, $d$ an odd positive integer and $f: \mathbb{Z}\_{>0} \times \mathbb{Z}\_{>0} \to \mathbb{R}$. For a non-principal character $\chi\_d = \chi$ with modulus $d$, I am interested in the following type of sums.
$$S(\chi, f) = \sum\_{\substack{m = M \\ (m, d) = 1}}^{2M}f(m, d) \chi(m). $$


For $f \equiv 1$, we know that $\lvert S(\chi, f)\rvert \ll \sqrt{d}\log(d)$ by the Pólya–Vinogradov inequality. Now I am interested in bounding $\lvert S(\chi, f)\rvert$ when $$f(m, d) = \frac{\phi(m)}{m} \prod\_{\substack{p \textrm{ prime} \\ (p, md) = 1}} \left(1 - \frac{\rho\_{m}(p)}{p^2} \right)$$


where $\rho\_m(p) = 1 + \genfrac(){}{}m p$ for primes $p$ that do not divide $m$. $\chi\_d(m) = \genfrac(){}{}m d$, the Jacobi symbol.


I expect a similar result as the Pólya–Vinogradov inequality. Computational experiments for some $M$, $d$ values did agree with my expectation. Have these types of sums been studied earlier? Any help would be highly appreciated.



Pólya–Vinogradov like inequality for a character sum with Euler factors
Based on the ideas posted by @OfirGorodetsky and @tomos as comments to this post, I managed to compile this solution.


$$\begin{align\*}
S &= \sum\_{m = M}^{2M} \frac{\phi(m)}{m} \prod\_{p \nmid md}\left(1 - \frac{1}{p^2} - \frac{\chi\_p(m)}{p^2} \right) \; \chi\_d(m) \\
 &= \sum\_{m = M}^{2M} \frac{\phi(m)}{m} \left( \sum\_{r \nmid md} \prod\_{p \nmid mdr} \left(1 - \frac{1}{p^2} \right) \mu(r) \frac{\chi\_r(m)}{r^2} \right) \chi\_d(m) \\
&= \sum\_{m = M}^{2M} \prod\_{p | m} \frac{1}{1 + \frac{1}{p}} \sum\_{r \nmid d} \prod\_{p \nmid dr} \left(1 - \frac{1}{p^2} \right) \mu(r) \frac{\chi\_{rd}(m)}{r^2} \\
&= \sum\_{r \nmid d} \left( \mu(r) \frac{1}{r^2} \prod\_{p \nmid dr} \left(1 - \frac{1}{p^2} \right) \right) \sum\_{m = M}^{2M} \left( \prod\_{p | m} \frac{p}{1 + p} \right)\chi\_{dr}(m) \end{align\*} $$


Now setting $f(m) = \prod\_{p | m} \frac{p}{1 + p}$ and $g = f\*1$, by the Mobius inversion formula we have that $g(m) = \sum\_{ab = m} f(a) \mu(b)$. It is easy to see by computation that $|g(m)| < \frac{1}{m}$. Hence we have,


$$\begin{align\*}
\left| \sum\_{m = M}^{2M} \left( \prod\_{p | m} \frac{p}{1 + p} \right)\chi\_{dr}(m)\right| &= \left| \sum\_{m = M}^{2M} \sum\_{ab = m} g(a)\chi\_{dr}(a) \chi\_{dr}(b) \right| \\ &= \left| \sum\_{a = 1}^{2M} g(a)\chi\_{dr}(a) \sum\_{b = M/a}^{2M/a} \chi\_{dr}(b) \right| \\ &\leq \sum\_{a = 1}^{2M} |g(a)| \left| \sum\_{b = M/a}^{2M/a} \chi\_{dr}(b) \right| \\ &\ll \sum\_{a = 1}^{2M} \frac{1}{a} \sqrt{dr} \log{(dr)} \ll \log{(M)} \sqrt{dr} \log{(dr)}
\end{align\*}$$


So now,
$$\begin{align\*}
|S| \ll \sum\_{r \nmid d} \frac{1}{r^2} \log{(M)} \sqrt{dr} \log{(dr)} \ll \log{(M)} \sqrt{d} \log{(d)}
\end{align\*}$$


The Euler factor involving the $\rho\_m$ function was too complicated to get a useful function applying Mobius inversion. So somehow had to expand out and dealt as shown.


