Determine whether the integral $\int_{0}^{\infty}\frac{\cos(x)\sin(1/x)}{x^p}dx$ is convergent or divergent Determine whether the improper integral $\int_{0}^{+\infty}\frac{\cos(x)\sin(1/x)}{x^p}dx$ is convergent or divergent for $p\in\mathrm{R}$. According to the Dirichlet test, I find it is convergent when $-1<p<2$. But how can I show its divergence? Applying Integration by parts seems tedious.
 A: As suggested in the comments, the integrand function behaves like $\frac{\cos x}{x^{p+1}}$ on the interval $(1,+\infty)$, hence the improper Riemann integrability over such interval is granted by Dirichlet's test as soon as $p>-1$, and that also is a necessary condition always by integration by parts. In a right neighbourhood of the origin the integrand function behaves like $\frac{\sin(1/x)}{x^p}$, and
$$ \int_{0}^{1}\frac{\sin(1/x)}{x^p}\,dx = \int_{1}^{+\infty}\frac{\sin(x)}{x^{2-p}}\,dx $$
hence here the necessary and sufficient condition for the improper Riemann integrability is $p<2$.
By putting everything together, the given integral is convergent as soon as $-1<p<2$, and by exploiting the (inverse) Laplace transform, Euler's Beta function and the reflection formulas for the $\Gamma$ function its value is given by 
$$ \int_{0}^{+\infty}\frac{\cos(x)\sin(1/x)}{x^p}\,dx = \frac{\pi}{4\sin\frac{\pi p}{2}}\left[I_{1-p}(2)+2\,I_{p-1}(2)+J_{1-p}(2)-2\,J_{p-1}(2)\right].$$
A: Proving divergence when the integrand is nonnegative or nonpositive may be facilitated by the comparison test. 
However, when the integrand changes sign, the only recourse may be proving  divergence using the negation of the definition of convergence.   In this way, we prove divergence of the improper integral $\int_a^\infty f(x) \, dx$ by showing there exists $\epsilon_0 > 0$ such that for any $c > a$ there exists $c_2 > c_1 > c$ such that
$$\left|\int_{c_1}^{c_2} f(x) \, dx  \right| \geqslant \epsilon_0.$$
Specifically, for any $c > 0$ choose an integer $n$ such that $c_1 = 2n\pi -\pi/4 > c$ and $c_2 = 2n\pi + \pi/4$. Since $\cos x \geqslant 1/\sqrt{2}$ for $c_1 \leqslant x \leqslant c_2$ and $x \sin(1/x) \geqslant \sin 1$ for $x \geqslant c_1 \geqslant 1$ we have
$$\begin{align}\left|\int_{c_1}^{c_2}\frac{\cos x \sin(1/x)}{x^p} \, dx \right| &= \int_{c_1}^{c_2}\frac{x \sin(1/x)\cos x }{x^{p+1}} \, dx \\ &\geqslant \frac{\sin 1}{\sqrt{2}} \int_{c_1}^{c_2} x ^{-(p+1)} \, dx \\ \end{align}$$
If $p \leqslant -1$ then $-(p+1) \geqslant 0$ and $x^{-(p+1)} \geqslant 1$ for $x \geqslant 1$.
Hence,
$$\begin{align}\left|\int_{c_1}^{c_2}\frac{\cos x \sin(1/x)}{x^p} \, dx \right| \geqslant \frac{\sin1}{\sqrt{2}}(c_2 - c_1) = \frac{\pi \sin 1}{2 \sqrt{2}}, \end{align}$$
and the improper integral must diverge.
The same idea works for proving divergence when $p \geqslant 2$ of
$$\int_{0}^{1}\frac{\cos x \sin(1/x)}{x^p} \, dx  = \int_{1}^{\infty}\frac{\cos (1/x) \sin(x)}{x^{2-p}} \, dx  $$
