An integration question Suppose that $-1<a<1$ and consider
$$g(a)=\int_0^{π/2}\ln\left(\frac{1+a\cos x}{1-a\cos x}\right)\frac{\mathrm dx}{\cos x}.$$
How can I find the value of $g(a)$? 
I believe the denominator, $\cos x$, may be problematic when it equals $0$. 
How would I deal with it?
 A: Derive with respect to $a$ and get
$$g'(a) = \int \limits _0 ^{\frac \pi 2} \frac {1 - a \cos x} {1 + a \cos x} \frac {\cos x (1 - a \cos x) + \cos x (1 + a \cos x) } {(1 - a \cos x)^2} \frac 1 {\cos x} \Bbb d x = 2 \int \limits _0 ^{\frac \pi 2} \frac 1 {1 - a^2 \cos ^2 x} .$$
Now, make the substitution $t = \tan x$, obtaining $\Bbb d x = \frac 1 {1 + t^2}$ and $\cos ^2 x = \frac 1 {1 + t^2}$, therefore you continue:
$$ g'(a) = 2 \int \limits _0 ^\infty \frac 1 {1 - \frac {a^2} {1+t^2}} \frac 1 {1+t^2} \Bbb d t = 2 \int \limits _0 ^\infty \frac 1 {(1-a^2) + t^2} = \frac 2 {\sqrt {1-a^2} } \arctan \frac t {\sqrt {1-a^2} } \Big| _0 ^\infty = \frac \pi {\sqrt {1-a^2} } .$$
Integrating now back with respect to $a$ you get:
$$g(a) = \pi \int \frac 1 {\sqrt {1-a^2}} \Bbb d a = \pi \arcsin a + C ,$$
with $C$ an integration constant.
Look back at the formula defining $g$ and note that $g(0) = 0$; on the other hand, according to our calculations, $g(0) = C$, so $C=0$ and finally
$$g(a) = \pi \arcsin a .$$
(Here $\log$ is the natural logarithm and we have used that $\log 1 = 0$.)
Edit:
The integral above is improper of the second type, apparently having a singularity in $\frac \pi 2$. In reality, the integrand is bounded and the integral converges because, applying l'Hospital's theorem,
$$\lim \limits _{x \to \frac \pi 2} \frac {\log \frac {1 + a \cos x} {1 - a \cos x}} {\cos x} = \lim \limits _{x \to \frac \pi 2} \frac {\frac {1 - a \cos x} {1 + a \cos x} \frac {- a \sin x (1 - a \cos x) - (1 + a\cos x) a \sin x} {(1-a \cos x)^2}} {- \sin x} = 2a .$$
A: Let $I(a)$ be the function 
$$I(a)=\int_0^{\pi/2}\log\left(\frac{1+a\cos x}{1-a\cos x}\right)\frac{dx}{\cos x}$$
Then, $I'(a)$ is given by
$$\begin{align}
I'(a)&=\int_0^{\pi/2}\frac{dx}{1+a\cos x}dx+\int_0^{\pi/2}\frac{dx}{1-a\cos x}dx\\\\
&=\frac{2}{\sqrt{1-a^2}}\left(\arctan \left(\sqrt{\frac{1-a}{1+a}}\right)+\arctan\left(\sqrt{\frac{1+a}{1-a}}\right)\right) \tag 1\\\\
&=\pi{\sqrt{1-a^2}}\tag 2
\end{align}$$
where we used the Wierstrauss substitution to obtain $(1)$ and made use of the identity $\arctan x+\arctan (1/x)=\pi/2$ to obtain $(2)$.
Now, integrating $I'(a)$ from $(3)$ reveals that 
$$I(a)= \pi \arcsin (a)+C$$
whereupon using $I(0)=0$ implies that
$$I(a)= \pi \arcsin (a)$$
A: The denominator diverges for $x\to\frac\pi2$. Let $\epsilon=\frac\pi2-x$. We have for $\epsilon\to0$, $\cos x=\sin\epsilon\approx\epsilon$, whereas $\ln(1+a\cos x)\approx a\epsilon$ and $\ln(1-a\cos x)\approx-a\epsilon$. Therefore, in $x=\frac\pi2$ the limit is $2a$ and the integral converges.
To compute $g(a)$ I suggest to keep in mind that $g(0)=0$ and derivate with respect to $a$.
A: Unless I made a mistake
$$
g'(a) = 2\int_0^{\pi/2}\frac{1}{1-a^2\cos^2 x}dx 
$$
Which may or may not be easier to integrate with respect to $x$ and then by $a$.
