I need to evaluate the following integral $$\int_{0}^{\pi/2} \cos^a (x) \sin (a x) \ dx,\ \ ~\ \ a\geq 0$$
I tried the following :$$I(a):=\int_{0}^{\pi/2} \cos^a (x) \sin (a x) \ dx$$ $$I(a)=\Im\left(\int_{0}^{\pi/2} \left(\frac{e^{ix}+e^{-ix}}{2}\right)^a e^{i a x} \ dx\right) $$ $$I(a)=\Im\left(2^{-a}\int_{0}^{\pi/2} \left(1+e^{-2ix}\right)^a e^{2i a x} \ dx\right) $$ $$I(a)=\Im\left(2^{-a}\int_{0}^{\pi/2} \left(1+e^{-2ix}\right)^a e^{i (2a+2) x} \ \frac{i}{2}d(e^{-2 i x})\right) $$ $u=e^{-2ix}$ ($u$ travels clockwise along the unit circle from $1$ to $-i$ to $-1$ then Cauchy's theorem lets us deform the countour to just under the real axis from $1$ to $0$ to $-1$) $$I(a)=\Im\left(2^{-a-1}\ i \int_{1}^{-1} (1+u)^a u^{-a-1} \ du\right) $$ $$I(a)=\Im\left(2^{-a-1}\ i \int_{1}^{0} (1+u)^a u^{-a-1} \ du\right)+\Im\left(2^{-a-1}\ i \int_{0}^{-1} (1+u)^a u^{-a-1} \ du\right) $$ $$I(a)=J(a)+K(a) $$ where $$J(a)=\Im\left(2^{-a-1}\ i \int_{1}^{0} (1+u)^a u^{-a-1} \ du\right) $$ and $$K(a)=\Im\left(2^{-a-1}\ i \int_{0}^{-1} (1+u)^a u^{-a-1} \ du\right)$$ $$J(a)=-2^{-a-1}\int_{0}^{1} (1+u)^a u^{-a-1} \ du $$ In $K(a)$, substitute $u=-v$ so that $du=-dv$ $$K(a)=\Im\left(-2^{-a-1}\ i \int_{0}^{1} (1-v)^a (-v)^{-a-1} \ dv\right)$$ $$K(a)=\Im\left((-1)^{-a}\ i \ 2^{-a-1} \int_{0}^{1} (1-v)^a v^{-a-1} \ dv\right)$$ Write $-1=e^{-i\pi}$ and $i=e^{i\pi/2}$ $$K(a)=\Im\left(e^{i\pi (a+1/2)} \ 2^{-a-1} \int_{0}^{1} (1-v)^a v^{-a-1} \ dv\right)$$ $$K(a)=\sin(\pi (a+1/2)) \ 2^{-a-1} \int_{0}^{1} (1-v)^a v^{-a-1} \ dv$$ $$K(a)=\cos(\pi a) \ 2^{-a-1} \int_{0}^{1} (1-v)^a v^{-a-1} \ dv$$ So by the definition of Beta function $$K(a)=\cos(\pi a) \ 2^{-a-1} \Gamma(a+1)\Gamma(-a)$$ By reflection formula of Gamma function $$K(a)=-\cos(\pi a) \ 2^{-a-1} \frac{\pi}{\sin \pi a}$$