Evaluate the integral $\int_{0}^{\pi}\frac{\log(1+a\cos x)}{\cos x}\,dx$ Please help me to evaluate the integral $\int_{0}^{\pi}\frac{\log(1 + a\cos x)}{\cos x}\,dx$. In the question they said to use the formula $\frac{d}{dy}\int_{a}^{b}f(x,y)dx=\int_{a}^{b}\frac{\partial }{\partial y}f(x,y)dx$.
 A: Let us assume $|a|<1$ to avoid any inconvenience in the definition of $\log(1+a\cos x)$. A useful pre-processing is to reduce the integration problem to the $(0,\pi/2)$ interval, through:
$$\begin{eqnarray*} I(a) &=& \int_{0}^{\pi}\frac{\log(1+a\cos x)}{\cos x}\,dx \\&=& \int_{0}^{\pi/2}\frac{\log(1+a\cos x)}{\cos x}\,dx - \int_{0}^{\pi/2}\frac{\log(1-a\cos x)}{\cos x}\,dx\\&=& \int_{0}^{\pi/2}\frac{dx}{\cos x}\,\log\left(\frac{1+a\cos x}{1-a\cos x}\right)\\(\text{Taylor series})\qquad&=&2\sum_{n\geq 0}\frac{a^{2n+1}}{2n+1}\int_{0}^{\pi/2}\cos(x)^{2n}\,dx\end{eqnarray*}\tag{1}$$
And since $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$, due to the extended binomial theorem and the Taylor series of $\frac{1}{\sqrt{1-x^2}}$
$$ I(a) = \pi a\sum_{n\geq 0}\frac{(a/2)^{2n}}{2n+1}\binom{2n}{n}=\color{red}{\pi\arcsin(a)}.\tag{2}$$
A: Well, we have:
$$\frac{\text{d}}{\text{d}\text{a}}\left\{\int_0^\pi\frac{\ln\left(1+\text{a}\cos\left(x\right)\right)}{\cos\left(x\right)}\space\text{d}x\right\}=\int_0^\pi\frac{\frac{1}{\text{a}+\sec\left(x\right)}}{\cos\left(x\right)}\space\text{d}x=$$
$$\int_0^\pi\frac{1}{1+\text{a}\cos\left(x\right)}\space\text{d}x=\frac{\pi}{\sqrt{1-\text{a}^2}}\tag1$$

EDIT: substitute $\text{u}=\tan\left(\frac{x}{2}\right)$:
$$\int\frac{1}{1+\text{a}\cos\left(x\right)}\space\text{d}x=\frac{2}{1+\text{a}}\int\frac{1}{1+\text{u}^2\cdot\frac{1-\text{a}}{1+\text{a}}}\space\text{d}\text{u}\tag2$$
Now, substitute $\text{p}=\text{u}\cdot\sqrt{\frac{1-\text{a}}{1+\text{a}}}$:
$$\frac{2}{1+\text{a}}\int\frac{1}{1+\text{u}^2\cdot\frac{1-\text{a}}{1+\text{a}}}\space\text{d}\text{u}=\frac{2}{\sqrt{1+\text{a}}\cdot\sqrt{1-\text{a}}}\int\frac{1}{1+\text{p}^2}\space\text{d}\text{p}=$$
$$\frac{2}{\sqrt{1+\text{a}}\cdot\sqrt{1-\text{a}}}\cdot\arctan\left(\text{p}\right)+\text{C}=$$
$$\frac{2}{\sqrt{1+\text{a}}\cdot\sqrt{1-\text{a}}}\cdot\arctan\left(\tan\left(\frac{x}{2}\right)\cdot\sqrt{\frac{1-\text{a}}{1+\text{a}}}\right)+\text{C}\tag3$$
A: $\newcommand{\bbx}[1]{\,\bbox[8px,border:1px groove navy]{\displaystyle{#1}}\,}
 \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}
&\int_{0}^{\pi}{\ln\pars{1 + a\cos\pars{x}} \over \cos\pars{x}}\,\dd x =
\int_{0}^{\pi}{1 \over \cos\pars{x}}\
\overbrace{\int_{1}^{\infty}
{a\cos\pars{x} \over t\bracks{t + a\cos\pars{x}}}\,\dd t}
^{\ds{\ln\pars{1 + a\cos\pars{x}}}}\ \,\dd x
\\[5mm] = &\
a\int_{1}^{\infty}{1 \over t}\int_{0}^{\pi}{\dd x \over t + a\cos\pars{x}}
\,\dd t =
2a\int_{1}^{\infty}\int_{0}^{\pi/2}{\dd x \over t^{2} - a^{2}\cos^{2}\pars{x}}\,\dd t
\\[5mm] = &\
2a\int_{1}^{\infty}
\int_{0}^{\pi/2}{\sec^{2}\pars{x} \over t^{2}\sec^{2}\pars{x} - a^{2}}
\,\dd x\,\dd t
\\ = &\
2a\int_{1}^{\infty}{1 \over t^{2} - a^{2}}
\,{\root{t^{2} - a^{2}} \over t}\
\overbrace{\int_{0}^{\pi/2}{t\sec^{2}\pars{x}/\root{t^{2} - a^{2}} \over
\bracks{t\tan\pars{x}/\root{t^{2} - a^{2}}}^{2} + 1}\,\dd x}
^{\ds{=\ {\pi \over 2}}}\
\,\dd t
\\[5mm] & =
\pi a\int_{1}^{\infty}\,{\dd t \over t\root{t^{2} - a^{2}}} =
\bbx{\ds{\pi\arcsin\pars{a}}}
\end{align}
