I am starting to learn a little about analysis and convergence of Riemann integrals. I came across this problem and it stomped me. I want to find the values of $p$ for which the integral converges.
$$\int_0^2 \frac{\sin^2x}{x^p}\,dx$$
My approach was noting that: $\sin^2x \le \vert \sin x\vert$ and that $\vert \frac{\sin x}{x^p}\vert \le \frac1{x^p} $ then $\vert \frac{\sin^2 x}{x^p}\vert \le \frac1{x^p} $
Integration by parts yields:
$$\int_0^2 \frac{\sin^2x}{x^p}\,dx= \left[ \frac{x^{-p}}{2} \left(x-0.5\sin{2x} \right) \right]_0^2+\frac p2 \int_0^2 x^{-p}-\frac {x^{-p-1}}{2}\sin {2x}\,dx $$
$$= \frac1{2^p}\left( 1 - \frac {\sin4}{2}\right)+\frac p2\left[ \frac{2^{-p+1}}{-p+1} \right]_0^2- \frac p4\int_0^2 x^{-p-1}\sin {2x}\,dx$$
$$= \frac1{2^p}\left( 1 - \frac {\sin4}{2}\right) +\frac {p}{2^p\left(-p+1\right)}-\frac p4\int_0^2 x^{-p-1}\sin {2x}\,dx$$ $$$$ But since $\vert x^{-p-1}\sin{2x} \vert \le x^{-p-1}$ and $p+1 \gt 1$, then $\frac p4\int_0^2 x^{-p-1}\sin {2x}\,dx$ is convergent because $\int_0^2 x^{-p}\,dx$ convergent for $p \gt1$
So I arrived at the conclusion that for $p \gt1$, $\int_0^2 \frac{\sin^2x}{x^p}\,dx$ converges, since all of the terms to the right are finite and the integral on the right also convergent. On the other hand I checked with Wolfram Alpha and it says $\int_0^2 \frac{\sin^2x}{x^3}\,dx$ does not converge, yet $p=3 \gt 1$. So where did I go wrong?
Notice that \begin{align} |\sin x | \le |x| \end{align} when $|x|$ is small. In particular, we see that \begin{align} \int^2_0 \frac{\sin^2 x}{x^p}\ dx \le \int^2_0 \frac{dx}{x^{p-2}}<\infty \end{align} provided $p-2<1$ or $p<3$.
Suppose $p\ge 3$. I need to show that the integral is divergent to complete the problem. In fact, it suffices to show that the following integral is divergent \begin{align} \int^{\pi/2}_0 \frac{\sin^2 x}{x^{p}}\ dx \end{align} since $\pi/2<2$ and the integrand is non-negative.
Let us make the observation that \begin{align} \frac{2}{\pi}x \le \sin x \end{align} on the interval $[0, \pi/2]$ (draw a picture to convince yourself). This means that \begin{align} \int^{\pi/2}_0 \frac{\sin^2 x}{x^p}\ dx \ge \frac{4}{\pi^2}\int^{\pi/2}_0 \frac{dx}{x^{p-2}} = \infty \end{align} provided $p\ge 3$.