For which values of $p$ and $q$ does an improper integral converge Determine all $p$ and $q$ for which the following improper integral converges. Justify your answer.
$$\int_0^{\pi/2}\frac{\mathrm{d}x}{(\sin^px)(\cos^qx)}$$
I think I have an idea of how to approach this problem, but I'm not certain it's correct.
What I've done is to split the interval so we have:
$$\int_{0}^{\pi/4}\frac{\mathrm{d}x}{(\sin^px)(\cos^qx)}+ \int_{\pi/4}^{\pi/2}\frac{\mathrm{d}x}{(\sin^px)(\cos^qx)}$$
Then I state that since $ \frac{\sqrt{2}}{2} \le \cos^qx \le 1 $ in the first interval, I can use the comparison test:
$$0 \le \frac{1}{\sin^px} \le \frac{1}{(\sin^px)(\cos^qx)}$$
and find that the comparison function converges when $p\le0$ 
After that I would do something similar for the second interval in which the comparison function would involve $\cos^qx$ in place of $\sin^px$
Is what I've done so far correct? Thanks in advance.

This function is known as the Beta function,  $$B(x,y)=2\int_0^{\pi/2} \sin(t)^{2x-1}\cos(t)^{2y-1}\, \mathrm{d}t.$$  In particular, you are looking at $$\frac{1}{2}B\left(\frac{1}{2}-\frac{p}{2},\frac{1}{2}-\frac{q}{2}\right).$$
This converges as long as $p,q<1$.
For a direct proof, note that by substitution $$\int_0^{\pi/2} \sin(t)^{-p}\cos(t)^{-q}\, \mathrm{d}t=\int_0^\infty \frac{t^{-p/2-1/2}}{(1+t)^{1-p/2-q/2}}\, \mathrm{d}t.$$  For convergence around $0$, we must have that $\frac{p}{2}<\frac{1}{2}$, and for convergence near $\infty$, we must have $\frac{q}{2}<\frac{1}{2}$.  This yields $p,q<1$.
