Prove that $\int_0^{\pi/2} \cos^{p+q-2}(\theta) \cos((p-q)\theta)d\theta = \frac{\pi}{(p+q-1)2^{p+q-1}B(p,q)}$ Does anybody know how to prove this identity?
$$\int_0^{\pi/2} \cos^{p+q-2}(\theta) \cos((p-q)\theta)d\theta = \frac{\pi}{(p+q-1)2^{p+q-1}B(p,q)}\quad p+q>1,q<1$$
$B(x,y)$ denotes Beta Function. I am confused because the result contains beta function in the denominator. I did it using cauchy's beta integral but my friend says there's another method using contour integration. I can't figure it out.
 A: EDIT: The answer I gave in this thread is embarrassingly bad.  I gave a much better answer in a much more recent thread that Alyosha has linked to in a comment to the original post.
$ $
You must be reading the same book as I am.  And please share your approach.
The contour integration approach is to integrate $z^{p-q-1} \left(z-\frac{1}{z} \right)^{p+q-2}$ around the closed contour that consists of the right half of the circle $|z|=1$ and the vertical line segment from $i$ to $-i$.
There are branch points at $z=0,i$, and $-i$ when $p-q-1$ and $p+q-2$ are not integers. So define standard cuts and indent the contour at those points.
The conditions on the parameters will prevent the contour integral from blowing up in the limit (which I had some difficulty showing), particularly they prevent there from being a pole of order greater than 1 (or actually any pole at all) at the origin when $p-q-1$ and $p+q-2$ are integers.
And apparently after evaluation you can argue that the restrictions on the parameters can be loosened.
