# How to integrate $\int \frac{\cos^m x}{\cos nx} \,\mathrm{d}x$

How to integrate $$\int \frac{\cos^m x}{\cos nx} \,\mathrm{d}x$$

Motivation: $\int \cos mx \sec nx \,\mathrm{d}x$ and $\int \cos mx\sec^n x\,\mathrm{d}x$ and $\int \cos^m x \cos nx \,\mathrm{d}x$ and $\int \cos mx \cos nx \,\mathrm{d}x$ are all integrals with closed forms (including summations) I've solved myself or read elsewhere.

Plugging various $m,n$ into wolfram shows the antiderivative always has a combination of trig functions and $\tanh^{-1}$. Nothing I've tried has worked or even simplified it.

• For specific $m,n$ I might try the $u=\tan(x/2)$ substitution, using $\cos nx = T_n(\cos x)$ where $T_n$ is a Chebyshev polynomial. Not sure how to do that generally, however. – Thomas Andrews Apr 18 '17 at 13:41
• Maybe there is some sort of recursive solution? Not really sure how else to approach this unless you break it into cases for $m,n$. – Will Craig Apr 18 '17 at 13:48
• Well. Even wolfram gives up. – The Dead Legend Apr 18 '17 at 13:51
• Wolframalpha which based on the Gradshteyn-Rytzhik tables and the computer logic cannot find a combination of special functions to express the result. – DanielC Apr 18 '17 at 13:52
• Wasn't this question asked a week ago or so? I cannot find it, but I think it should be there for the one who is better to search. – mickep Apr 18 '17 at 14:43

HINT

Let $y=\cos(x),$ then $$\frac{\cos^m x}{\cos nx} = \frac{(\cos x)^m}{T_n(\cos x)} = f(\cos x),$$ where $T_n(y)$ are the Chebyshev's polynomials of the first kind.

If $m\ge n$ it is necessary to single out an integer part of the ratio of polynomials.
Let $$g_{n-1}(y) = y^m\bmod T_n(y),\quad h(y) = f(y) - g_{n-1}(y),$$ then $$f(y) = r(y) + h(y),$$ where $$r(y) = \frac{g_{n-1}(y)}{T_n(y)},$$ $h(y)$ are polynomial of $y$ or zero, and $g_{n-1}(y)$ is polynomial of order $(n-1)$ or less.

Then, $$T_n(y) = 2^n\prod_{k=1}^n (y-y_{n,k}),$$ where $$y_{n,k} = \cos\left|\frac{2k-1}{2n}\right|.$$ So $$r(y) = \frac {g_{n-1}(y)}{2^n \prod_{k=1}^n (y-y_{n,k})} = \sum_\limits{k=1}^n \frac{a_k}{y-y_{n,k}},$$ and $$a_k = \lim_{y\to y_{n,k}}r(y)(y-y_{n,k}).$$ In this way, $$\int\frac{\cos^m(x)}{\cos nx}\,dx = \sum_{k=1}^n a_k\int\frac{dx}{\cos x - y_{n,k}} + \int h(\cos x)\,dx,$$ where $h(y)$ is the polynomial, and the integrals under the sum can be calculated using the universal trig substitution.

Let's note first of all, that the integrand function $f(x)=\cos ^{\,m} x/\cos nx$ is periodic with period $2\pi$ for $n$ integer, and that it has simple poles in $x_{\,p} = (2k+1)/(2n) \pi$ (for $n \neq 0$), of which only those at $(2k+1)/2 \pi$ are cancelled if $1 \leqslant m$.
That means that at the non-vanishing poles the integral will presents log-order spikes.

In the complex field $f(z)$ is a meromorphic function, so its series expansion will converge in every circle not including the poles. Moreover $\cos{z}$ is an even function and so is $f(z)$.
Let's take $m$ and $n$ to be integers, which simplifies the handling of complex exponentiation ($\exp(z)^m = \exp(mz)$ ).
Since $\cos(nx)=\cos(-nz)$, $n$ can be taken to have non-negative values.

That premised, let's rewrite the integrand as \eqalign{ & {{\cos ^{\,m} z} \over {\cos n\,z}}\quad \left| \matrix{ \,{\rm integers}\,m,n \hfill \cr \;z \in \mathbf{C}\; \hfill \cr} \right.\quad = {{\cos ^{\,m} \left( { \pm z} \right)} \over {\cos \left( { \pm n\,z} \right)}} = \cr & = {{\left( {e^{\,i\,z} + e^{\, - \,i\,z} } \right)^{\,m} } \over {2^{\,m - 1} \left( {e^{\,i\,n\,z} + e^{\, - \,i\,n\,z} } \right)}} = {{\left( {1 + e^{\,i\,2\,\,z} } \right)^{\,m} } \over {2^{\,m - 1} e^{\,\,i\,\left( {m - n} \right)\,z} \left( {1 + e^{\,\,i\,2n\,z} } \right)}} = \cr & = {{e^{\,\,i\,\left( {n - m} \right)\,z} \left( {1 + e^{\,i\,2\,\,z} } \right)^{\,m} } \over {2^{\,m - 1} \left( {1 + e^{\,\,i\,2n\,z} } \right)}} = \cr & {\rm (with}\,{\rm the}\,{\rm premised}\,{\rm conditions}\,{\rm for}\,{\rm convergence)} = \cr & = {{e^{\,\,i\,\left( {n - m} \right)\,z} } \over {2^{\,m - 1} \left( {1 + e^{\,\,i\,2n\,z} } \right)}}\sum\limits_{0\, \le \,k\,\left( { \le \,m} \right)} {\left( \matrix{ m \cr k \cr} \right)e^{\,i\,2\,k\,z} } = \cr & = {{e^{\,\,i\,\left( {n - m} \right)\,z} } \over {2^{\,m - 1} }}\sum\limits_{0\, \le \,j\,} {\left( { - 1} \right)^j e^{\,i\,2\,j\,n\,z} \sum\limits_{0\, \le \,k\,\left( { \le \,m} \right)} {\left( \matrix{ m \cr k \cr} \right)e^{\,i\,2\,k\,z} } } \cr} Therefore: \bbox[lightyellow] { \eqalign{ & \int {{{\cos ^{\,m} z} \over {\cos n\,z}}dz} \quad \left| \matrix{ \,{\rm integers}\,m,n \hfill \cr \;z \in \mathbf{C}\;\backslash \left\{ {{{\left( {2k + 1} \right)} \over {2n}}\pi ,0} \right\} \hfill \cr} \right.\quad = \cr & = {{e^{\,\,i\,\left( {n - m} \right)\,z} } \over {i\,2^{\,m - 1} }}\sum\limits_{0\, \le \,k\,\left( { \le \,m} \right)} {\left( \matrix{ m \cr k \cr} \right)e^{\,i\,2\,k\,z} \sum\limits_{0\, \le \,j\,} {{{\left( { - 1} \right)^j } \over {\left( {2k + 2j\,n + n - m} \right)}}e^{\,i\,2\,j\,n\,z} } } = \cr & = {{e^{\,\,i\,\left( {n - m} \right)\,z} } \over {i\,2^{\,m - 1} }}\sum\limits_{0\, \le \,k\,\left( { \le \,m} \right)} {\left( \matrix{ m \cr k \cr} \right){{e^{\,i\,2\,k\,z} } \over {\left( {2k + n - m} \right)}}{}_2F_{\,1} \left( {1,{{2k + n - m} \over {2\,n}};\;{{2k + n - m} \over {2\,n}} + 1;\; - e^{\,i\,2\,n\,z} } \right)} \cr} } where the replacement of the sum in $j$ with the Gaussian hypergeometric function comes from the fact that the ratio of two consecutive summands gives: $${{{{\left( { - 1} \right)^{\left( {j + 1} \right)} } \over {\left( {2k + 2\left( {j + 1} \right)\,n + n - m} \right)}}e^{\,i\,2\,\left( {j + 1} \right)\,n\,z} } \over {{{\left( { - 1} \right)^j } \over {\left( {2k + 2j\,n + n - m} \right)}}e^{\,i\,2\,j\,n\,z} }} = {{j + \left( {{{2k + n - m} \over {2\,n}}} \right)} \over {j + \left( {{{2k + n - m} \over {2\,n}} + 1} \right)}}\left( { - e^{\,i\,2\,n\,z} } \right)$$

You may wanna check out Liouville's theorem (Hamiltonian); I guess it can't be integrated.

• Certainly for any $m,n\$ the equation can be integrated. Testing a few cases in Mathematica implies this. I don't understand what you're saying – user436585 Apr 18 '17 at 19:11