Integration with respect to a parameter $a$ Show that the value of the integral of $$\frac{\log(1+\cos(a)\cos(x))}{\cos(x)}$$ over the interval $[0,\pi]$ is given by $$\pi\left(\frac{\pi}{2} - a\right)$$ for $0\leq\,a\leq\,2.$
 A: Let's start by defining 
$$
I_a = \int_0^\pi\frac{\log(1+\cos(a)\cos(x))}{\cos(x)}\,dx.
$$
Observe that $I_{\pi/2} = 0$, so we would be done if we could prove that $I_{a}' = -\pi$, where the derivative is with respect to $a$.  So taking the derivative under the integral sign, we get
$$
I_a' = -\sin(a) \int_0^\pi \frac{dx}{1+\cos(a)\cos(x)}.
$$
Performing the change of variables $y=\pi-x$, we can also see that 
$$
I_a' = -\sin(a) \int_0^\pi \frac{dx}{1-\cos(a)\cos(x)}.
$$
Taking the average of the two integrals, and summing the fractions we arrive at
$$
I_a' = -\sin(a) \int_0^\pi \frac{dx}{1-\cos^2(a)\cos^2(x)}
 = -2\sin(a)\int_0^{\pi/2} \frac{dx}{1-\cos^2(a)\cos^2(x)}.
$$
In the second step we used the symmetry of the integrand with respect to the swap $x\mapsto \pi-x$.  
To proceed with this integral, we now use the change of coordinates $u=\tan(x)$.  Then $\cos^2(x) = (1+u^2)^{-1}$ and $(1+u^2)^{-1}du = dx$, so
$$
I_a' = -2\sin(a)\int_0^\infty\frac{du}{u^2+1-\cos^2(a)} = -2\sin(a)\int_0^\infty \frac{du}{u^2+\sin^2(a)}.
$$
Now we make another change of variables $u = \sin(a)v$ to simplify further:
$$
I_a' = -2\int_0^\infty \frac{dv}{v^2+1} = -\pi.
$$
where the last equality can be proven using the trigonometric substitution $v = \tan(\theta)$.
