# Ramanujan's 'well known' integral, $\int_\frac{-\pi}{2}^\frac{\pi}{2} (\cos x)^m e^{in x}dx$.

$$\int_{-\pi/2}^{\pi/2}\cos^m\left(x\right){\rm e}^{{\rm i}n x}\,{\rm d}x ={\pi \over 2^{m}}\, {\Gamma\left(1 + m\right) \over \Gamma\left( 1 + \left[m + n\right]/2\right)\ \Gamma\left( 1 + \left[m - n\right]/2\right)}$$

Appearing at the start of Ramanujan's paper 'A Class of Definite Integrals', the above is, cited as 'well known', particularly dispiriting as I can't prove it. Anyone know of a nice proof?

$\Re(m)>-1$ and I assume that $m \in \mathbb{C}, n \in \mathbb{R}$.

• If I was much cleverer, I would try to express $\frac{\pi}{2^m}$ as a product of two integrals, multiply both sides by $\Gamma \left(1+ \frac{m+n}{2}\right)\Gamma \left(1+ \frac{m-n}{2}\right)$ and rewrite both triple integrals so that their equality is obvious. I've not been able to come up with a solution. I've also tried the beta function, to no avail. – Meow Mar 19 '14 at 17:48

First add the restriction $n >m$. This can later be removed by means of analytic continuation.

Then \begin{align} \int_{-\pi /2}^{\pi /2} (\cos x)^{m} e^{inx} \ dx &= \int_{- \pi /2}^{\pi /2} (\cos x)^{m} \cos(nx) \ dx \\ &= \text{Re} \int_{- \pi/2}^{\pi /2} \left( \frac{e^{ix}+e^{-ix}}{2} \right)^{m} e^{inx} \ dx \\ &= \frac{1}{2^{m}} \text{Re} \frac{1}{i} \int_{C} (z+z^{-1})^{m} z^{n-1} \ dz \\ &= \frac{1}{2^{m}} \text{Re} \frac{1}{i} \int_{C} \left(z^{2}+1 \right)^{m} z^{n-m-1} \ dz \\ &= \frac{1}{2^{m}} \text{Re} \frac{1}{i} \int_{C} f(z) \ dz \end{align}

where $C$ is the right half of the unit circle traversed counterclockwise with quarter-circle indentations around the branch points at $z=-i$ and $z=i$.

Have the branch cut for $f(z)$ running down the imaginary axis from $z=i$ and define $f(z)$ to be real-valued on the positive real axis.

Now close the contour with a vertical line segment just to the right of $[-i,i]$ with a half-circle indentation around the branch point at $z=0$.

Just to the right of the branch cut and above the origin,

$$f(z) = |z^{2}+1|^{m} |z|^{n-m-1} e^{i \pi /2(n-m-1)} .$$

While just to the right of the branch cut and below the origin and above $z=-i$,

$$f(z) =|z^{2}+1|^{m} |z|^{n-m-1} e^{-i \pi /2(n-m-1)} .$$

And due to the added restriction, the contributions from all three indentations vanish in the limit.

For example, around $z=0$,

$$\Big| \int_{\pi/2}^{- \pi/2} f(re^{it}) \ i r e^{it} \ dt \Big| \le \pi \ (r^{2}+1)^{m} r^{n-m}$$

which vanishes as $r \to 0$ since $n>m$.

Then going around the contour,

$$\int_{C} f(z) \ dz + e^{i \pi /2 (n-m-1)}\int_{1}^{0} \left| (te^{i \pi /2})^{2} +1 \right|^{m} |te^{ i \pi /2}|^{n-m-1} e^{ i \pi /2} \ dt$$

$$+ \ e^{-i \pi /2 (n-m-1)}\int_{0}^{1} \left| (te^{-i \pi /2})^{2} +1 \right|^{m} |te^{ -i \pi /2}|^{n-m-1} e^{ -i \pi /2} \ dt = 0$$

which implies

\begin{align} \int_{C} f(z) \ dz &= e^{ i \pi /2 (n-m)} \int_{0}^{1} (1-t^{2})^m t^{n-m-1} \ dt - e^{- i \pi /2 (n-m)} \int_{0}^{1} (1-t^{2})^{m} t^{n-m-1} \ dt \\ &= 2 i \sin \left( \frac{\pi}{2} (n-m) \right) \int_{0}^{1} (1-t^{2})^{m} t^{n-m-1}\ dt \\ &= i \sin \left( \frac{\pi}{2} (n-m) \right) \int_{0}^{1} (1-u)^{m} u^{n/2-m/2-1} \ du \\ &= i \sin \left( \frac{\pi}{2} (n-m) \right) B \left( \frac{n}{2} - \frac{m}{2}, m+1 \right) \\ &= i \sin \left( \frac{\pi}{2} (n-m) \right) \frac{\Gamma(\frac{n}{2} - \frac{m}{2}) \Gamma(m+1)}{\Gamma(\frac{m}{2}+\frac{n}{2} + 1)} .\end{align}

Then using the reflection formula for the gamma function,

$$\int_{C} f(z) \ dz= i \pi \frac{\Gamma(m+1)}{ \Gamma(1- \frac{n}{2} + \frac{m}{2})\Gamma(\frac{m}{2}+\frac{n}{2}+1)} .$$

Therefore,

\begin{align} \int_{-\pi /2}^{\pi /2} (\cos x)^{m} e^{inx} \ dx &= \frac{1}{2^{m}} \text{Re} \frac{1}{i} i \pi \frac{\Gamma(m+1)}{ \Gamma(1- \frac{n}{2} + \frac{m}{2})\Gamma(\frac{m}{2}+\frac{n}{2}+1)} \\ &=\frac{\pi}{2^m} \frac{\Gamma(1+m)}{\Gamma \left(1+ \frac{m+n}{2}\right)\Gamma \left(1+ \frac{m-n}{2}\right)} . \end{align}


\begin{align} &\color{#c00000}{\int_{-\pi/2}^{\pi/2}\cos^{m}\pars{x}\expo{\ic nx}\,\dd x} =\int_{-\pi/2}^{\pi/2}\bracks{1 + \cos\pars{2x} \over 2}^{m/2}\expo{\ic nx}\,\dd x \\[3mm]&=2^{-m/2 - 1}\int_{-\pi}^{\pi}\bracks{1 + \cos\pars{x}}^{m/2} \expo{\ic nx/2}\,\dd x \\[3mm]&=2^{-m/2 - 1} \int_{\verts{z} = 1 \atop {\vphantom{\Huge A}\verts{{\rm Arg}\pars{z}}\ <\ \pi}} \pars{1 + {z^{2} + 1 \over 2z}}^{m/2}z^{n/2}\,{\dd z \over \ic z} \\[3mm]&=-2^{-m - 1}\,\ic \int_{\verts{z} = 1 \atop {\vphantom{\Huge A}\verts{{\rm Arg}\pars{z}}\ <\ \pi}} \pars{2z + z^{2} + 1}^{m/2}z^{\pars{n - m}/2 - 1}\,\dd z \\[3mm]&=-2^{-m - 1}\,\ic \int_{\verts{z} = 1 \atop {\vphantom{\Huge A}\verts{{\rm Arg}\pars{z}}\ <\ \pi}} \pars{z + 1}^{m}z^{\pars{n - m}/2 - 1}\,\dd z \\[3mm]&=2^{-m - 1}\,\ic \int_{-1}^{0}\pars{x + 1}^{m}\pars{-x}^{\pars{n - m}/2 - 1} \exp\pars{\ic\pi\bracks{{n - m \over 2} - 1}}\,\dd x \\[3mm]&\mbox{}+ 2^{-m - 1}\,\ic \int_{0}^{-1}\pars{x + 1}^{m}\pars{-x}^{\pars{n - m}/2 - 1} \exp\pars{-\ic\pi\bracks{{n - m \over 2} - 1}}\,\dd x \\[3mm]&=2^{-m - 1}\,\ic \int_{0}^{1}\pars{1 - x}^{m}x^{\pars{n - m}/2 - 1} \exp\pars{\ic\pi\bracks{{n - m \over 2} - 1}}\,\dd x \\[3mm]&\mbox{}- 2^{-m - 1}\,\ic \int_{0}^{1}\pars{1 - x}^{m}x^{\pars{n - m}/2 - 1} \exp\pars{-\ic\pi\bracks{{n - m \over 2} - 1}}\,\dd x \\[3mm]&=2^{-m - 1}\ic\braces{2\ic\sin\pars{\pi\bracks{{n - m \over 2} - 1}}} \int_{0}^{1}x^{\pars{n - m}/2 - 1}\pars{1 - x}^{m}\,\dd x \end{align}

$$\color{#c00000}{\int_{-\pi/2}^{\pi/2}\cos^{m}\pars{x}\expo{\ic nx}\,\dd x} =2^{-m}\sin\pars{{n - m \over 2}\,\pi}{\rm B}\pars{{n - m \over 2},m + 1}\,,\qquad \Re\pars{n} > \Re\pars{m} > -1$$ where $\ds{{\rm B}\pars{x,y} \equiv \int_{0}^{1}t^{x - 1}\pars{1 - t}^{y - 1}\,\dd t}$ is the Beta Function $\pars{~\mbox{with}\ \Re\pars{x}, \Re\pars{y} > 0~}$ which has the property $\ds{{\rm B}\pars{x,y} = {\Gamma\pars{x}\Gamma\pars{y} \over \Gamma\pars{x + y}}}$. $\ds{\Gamma\pars{z}}$ is the Gamma Function.

Then \begin{align} &\color{#c00000}{\int_{-\pi/2}^{\pi/2}\cos^{m}\pars{x}\expo{\ic nx}\,\dd x} =2^{-m}\sin\pars{{n - m \over 2}\,\pi}\, {\Gamma\pars{\bracks{n - m}/2}\Gamma\pars{m + 1} \over \Gamma\pars{\bracks{n + m}/2 + 1}}\tag{1} \end{align} By using the Gamma function Euler Reflection Formula $\ds{\Gamma\pars{z}\Gamma\pars{1 - z} = {\pi \over \sin\pars{\pi z}}}$ we find: $$\sin\pars{{n - m \over 2}\,\pi}\Gamma\pars{n - m \over 2} ={\pi \over \Gamma\pars{1 + \bracks{m - n}/2}}$$ such that $\pars{1}$ is reduced to $$\color{#00f}{\large% \int_{-\pi/2}^{\pi/2}\cos^{m}\pars{x}\expo{\ic nx}\,\dd x ={\pi \over 2^{m}}\, {\Gamma\pars{1 + m} \over \Gamma\pars{1 + \bracks{m + n}/2}\,\Gamma\pars{1 + \bracks{m - n}/2}}}$$