Integral of polynomial times rational function of trig function over multiple periods. $$\int_0^{12\pi} \frac{x}{6+\cos 8x} dx$$ 
I tried all kinds of stuff but end up with $\arctan\frac{5^{1/2} \tan(x/2)}{7^{1/2}}$
Please help :)
 A: It looks like the OP is trying to compute the antiderivative and use the fundamental theorem of calculus.  With multiple periods, that approach is paved with all sorts of difficulty that is really an artifice related to the functional form of the antiderivative.  In truth, there should be no such difficulty.  A better approach involves the residue theorem, which I will outline below.  Note that the presence of the linear term in the numerator provides a slight complication, but one that has been treated before in this site several times.
$$\int_{0}^{12 \pi} dx \frac{x}{6+\cos{8 x}} = \frac1{64} \int_0^{96 \pi} du \frac{u}{6+\cos{u}}$$
$$\int_{n 2 \pi}^{(n+1) 2 \pi} du \frac{u}{6+\cos{u}} = \int_0^{2 \pi} dv \frac{v+2 \pi n}{6+\cos{v}} = \int_0^{2 \pi} dv \frac{v}{6+\cos{v}} + 2 \pi n \int_0^{2 \pi} \frac{dv}{6+\cos{v}}$$
Thus, summing over $n$:
$$\int_{0}^{12 \pi} dx \frac{x}{6+\cos{8 x}} = \frac{48}{64} \int_0^{2 \pi} dv \frac{v}{6+\cos{v}} + \frac{48 (47) \pi}{64} \int_0^{2 \pi} \frac{dv}{6+\cos{v}}$$
We may now compute each of these integrals.  The second integral is straightforward by the residue theorem, i.e., let $z=e^{i v}$, then
$$\int_0^{2 \pi} \frac{dv}{6+\cos{v}} = -i 2 \oint_{|z|=1} \frac{dz}{z^2+12 z+1}$$
The only pole of the integrand inside the unit circle is at $z=-6+\sqrt{35}$.  The integral is then $i 2 \pi$ times the residue of the integrand at this pole, or $2 \pi/\sqrt{35}$.  
To compute the first integral, we consider the complex integral 
$$ \oint_C dz \frac{\log{z}}{z^2+12 z+1} $$
where $C$ is the unit circle with a detour up and back about the positive real axis.  (A circular piece about the origin vanishes.)  This integral is equal to
$$-\frac12 \int_0^{2 \pi} dv \frac{v}{6+\cos{v}} + \int_1^0 dx \frac{\log{x}+i 2 \pi}{x^2+12 x+1} + \int_0^1 dx \frac{\log{x}}{x^2+12 x+1}$$
or, simplifying,
$$-\frac12 \int_0^{2 \pi} dv \frac{v}{6+\cos{v}} - i 2 \pi \int_0^1 \frac{dx}{x^2+12 x+1} $$
The contour integral is also equal to $i 2 \pi$ times the residue at the pole $z=-6+\sqrt{35}$.  Note that the negative sign is taken to be $e^{i \pi}$.  Thus we have
$$-\frac12 \int_0^{2 \pi} dv \frac{v}{6+\cos{v}} = i 2 \pi \int_0^1 \frac{dx}{x^2+12 x+1} + i 2 \pi \frac{-\log{\left ( 6+\sqrt{35} \right )}+i \pi}{2 \sqrt{35}} $$
Now,
$$\frac1{x^2+12 x+1} = \frac1{2 \sqrt{35}} \left (\frac1{x+6-\sqrt{35}} - \frac1{x+6+\sqrt{35}} \right ) $$
so that
$$\int_0^1 \frac{dx}{x^2+12 x+1} = \frac1{2 \sqrt{35}} \log{\left (\frac{7+\sqrt{35}}{7-\sqrt{35}} \right )}  = \frac1{2 \sqrt{35}} \log{\left (6+\sqrt{35}\right )}$$
Note the cancellation with the real part of the residue.  Thus, 
$$\int_0^{2 \pi} dv \frac{v}{6+\cos{v}} = \frac{2 \pi^2}{\sqrt{35}} $$
Putting these results altogether, we have

$$\int_0^{12 \pi} dx \frac{x}{6+\cos{8 x}} = \frac{72 \pi^2}{\sqrt{35}} $$

ADDENDUM
Using the above analysis, we can easily generalize the above result:
$$\int_0^{2 \pi P} dx \frac{x}{a + \cos{N x}} = \frac{2 P^2 \pi^2}{\sqrt{a^2-1}} $$
where $a \gt 1$ and $N$ and $P \in \mathbb{N}$, i.e., other than $N$ being an integer, the result is independent of $N$.
A: $\newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\color{#f00}{\int_{0}^{12\pi}{x \over 6 + \cos\pars{8x}}\,\dd x} =
\int_{-6\pi}^{6\pi}{x + 6\pi \over 6 + \cos\pars{8x + 48\pi}}\,\dd x = 
12\pi\int_{0}^{6\pi}{\dd x \over 6 + \cos\pars{8x}}
\\[5mm] = &\
{3 \over 2}\,\pi\int_{0}^{48\pi}{\dd x \over 6 + \cos\pars{x}} =
36\pi\int_{0}^{2\pi}{\dd x \over 6 + \cos\pars{x}} =
36\pi\int_{-\pi}^{\pi}{\dd x \over 6 - \cos\pars{x}} =
72\pi\int_{0}^{\pi}{\dd x \over 6 - \cos\pars{x}}
\\[5mm] = &\
72\pi\int_{0}^{\pi/2}{\dd x \over 6 - \cos\pars{x}} +
72\pi\int_{\pi/2}^{\pi}{\dd x \over 6 - \cos\pars{x}} =
72\pi\int_{0}^{\pi/2}{\dd x \over 6 - \cos\pars{x}} +
72\pi\int_{-\pi/2}^{0}{\dd x \over 6 + \cos\pars{x}}
\\[5mm] = &\
864\pi\int_{0}^{\pi/2}{\dd x \over 36 - \cos^{2}\pars{x}} =
864\pi\int_{0}^{\pi/2}{\sec^{2}\pars{x} \over 36\sec^{2}\pars{x} - 1}\,\dd x =
864\pi\int_{0}^{\pi/2}{\sec^{2}\pars{x} \over 36\tan^{2}\pars{x} + 35}\,\dd x
\\[5mm] = &\
{144\root{35} \over 35}\,\pi\int_{0}^{\pi/2}
{6\sec^{2}\pars{x}/\root{35} \over \bracks{6\tan\pars{x}/\root{35}}^{2} + 1}
\,\dd x =
{144\root{35} \over 35}\,\pi\,{\pi \over 2} =
\color{#f00}{{72\root{35} \over 35}\,\pi^{2}} \approx 120.1153
\end{align}
A: Use integration by parts with $u=x$ and $dv=\frac{dx}{6+\cos(8x)}$.
