I was trying to do the following exercise from Apostol, Introduction to analytic number theory.
Given two-real-valued functions S(x) and T(x) such that
$ T(x) = \sum_{n \leq x}S(\frac{x}{n}) $
If S(x) = O(x) and if c is a positive costant, prove that the relation
$ S(x) \sim cx $ as $ x \rightarrow \infty$
implies
$ T(x) \sim cxlogx $ as $ x \rightarrow \infty$
My idea is that even if S(x) behaves like cx at infinity, the sum T always calculate S near 1, where it can behave as it wants. I thought the following counterexample
$ S(x) = \begin{cases}0 & \text{if x = 1} \\\frac{x^2}{x-1}, & \text{if x > 1} \end{cases} $
$ S(x) \sim x $ as $ x \rightarrow \infty$
but if I take
$ x_k = k + 10^{-k}, k \in \mathbb N$
I have that
$T(x) \geq S(\frac{x_k}{k}) = \frac{(1+\frac{1}{k10^k})^2}{\frac{1}{k10^k}} \geq k10^k$
And so it's not true that
$T(x) \sim xlogx $ as $ x \rightarrow \infty$
Am I right? Nowhere the author claims that the functions need to be continuous (and usually in number theory they are not) nor bounded (maybe is this implicit?)*
I found on the web a solution in which the author use the identity
$ S(x) = cx + o(x) $
and then he inserts it inside the sum and gets
$ T(x) = \sum_{n \leq x}({c\frac{x}{n} + o(\frac{x}{n})})$
and then he gets the result; but I think this is not correct because the asymptotic equivalence works "as x goes to infinity" and not necessarily when x is small (for example when it is x/[x]). So I think he cannot "substitute into the sum". But also Apostol himself uses these substitutions in some proof in the book.
Where am I wrong?Thanks in advance
[EDIT]*I mean bounded in every [0, M]