Evaluate integral: $\int_0^{\frac{\pi}{2}}\ln(a^2\cos^2 x +b^2\sin^2x)dx$?
Solution 1:
Let
$$ I(a)=\int_{0}^{\frac{\pi}{2}} \ln(a^2 \cos^2 x+b^2 \sin^2 x) dx $$
Thus
$$ I(b)=\int_{0}^{\frac{\pi}{2}} \ln(b^2 \cos^2 x+b^2 \sin^2 x) dx=\pi \ln b $$
\begin{align} I'(a)&=\int_{0}^{\frac{\pi}{2}} \frac{2a\cos^2 x}{a^2 \cos^2 x+b^2 \sin^2 x}dx \\ &=2a \int_{0}^{\frac{\pi}{2}} \frac{d(\tan x)}{(a^2+b^2 \tan^2 x)(1+\tan^2 x)} \\ &=\frac{\pi}{a+b} \\ \end{align}
Thus
$$ \int_b^a I'(a) da=\int_b^a \frac{\pi}{a+b} da $$
$$ I(a)-I(b)=\pi (\ln(a+b)-\ln(2b)) $$
$$ I(a)=\pi \ln \frac{a+b}{2} $$
Solution 2:
I thought it might be instructive to present an approach that relies on contour integration in the complex plane. To that end, we proceed.
MODIFYING THE INTEGRAL
Let $I(a,b)$ be defined by the integral
$$I(a,b)=\int_0^{\pi/2}\log(a^2\cos^2(x)+b^2\sin^2(x))\,dx\tag1$$
Using the double angle formulas, $\sin^2(x)=\frac{1-\cos(2x)}{2}$ and $\cos^2(x)=\frac{1+\cos(2x)}{2}$, in $(1)$ we obtain
$$\begin{align} I(a,b)&=\int_0^{\pi/2}\log\left(\frac{a^2+b^2}2+\frac{a^2-b^2}{2}\cos(2x)\right)\,dx\tag2\\\\ &=\frac\pi2 \log\left(\frac{a^2+b^2}{2}\right)+\frac14 \int_{-\pi}^{\pi} \log\left(1+\alpha\cos(x)\right)\,dx\tag3 \end{align}$$
In going from $(2)$ to $(3)$ we enforced the substitution $x\mapsto x/2$ and exploited the evenness of the integrand.
From here, we could use Feynman's trick, differentiate under the integral (tangent half-angle or contour integration), evaluate the integral of the derivative, and finish by integrating. Instead, we will apply contour integration to directly evaluate the integral.
MOVING TO THE COMPLEX PLANE
Next, we transform the integration on the right-hand side of $(3)$ to the complex plane through the substitution $z=e^{ix}$ to obtain
$$\begin{align}
\int_{-\pi}^{\pi} \log\left(1+\alpha\cos(x)\right)\,dx&=\oint_{|z|=1}\log\left(\frac{\alpha(z^2+2z/\alpha+1)}{2z}\right)\,\frac1{iz}\,dz\tag4
\end{align}$$
where $-1<\alpha =\frac{a^2-b^2}{a^2+b^2}<1$.
We select the principal branch of the logarithm with branch cuts emanating from branch points, extending along the negative real axis, and terminating at $z=-\infty$.
Denote the roots of $z^2+2z/\alpha+1=0$ by $r_1$ and $r_2$.
We will assume that $a<b$ so that $-1<r_1=\frac{a-b}{a+b}<0$ lies inside the unit circle $|z|=1$ while $r_2=\frac{a+b}{a-b}<-1$ lies outside the unit circle.
Then, we have from $(4)$
$$\begin{align} \oint_{|z|=1}\log\left(\frac{\alpha(z^2+2z/\alpha+1)}{2z}\right)\,\frac1{iz}\,dz&=\oint_{|z|=1} \frac{\log\left(-\alpha/2\right)}{iz}\,dz-\oint_{|z|=1} \frac{\log\left(z\right)}{iz}\,dz\\\\ &+\oint_{|z|=1} \frac{\log\left(z-r_1\right)}{iz}\,dz+\oint_{|z|=1} \frac{\log\left(z-r_2\right)}{iz}\,dz\tag5 \end{align}$$
where the negative sign on $\alpha$ is required to ensure that the sum of the arguments of the logarithms is $0$ on the unit circle.
EVALUATING THE INTEGRALS IN $(5)$
From the residue theorem, we see that
$$\oint_{|z|=1} \frac{\log\left(\alpha/2\right)}{iz}\,dz=2\pi \log\left(\alpha/2\right)\tag6$$
From Cauchy's Integral Theorem, we have
$$\begin{align}\oint_{|z|=1}\frac{\log(z)}{z}\,dz&=\lim_{\varepsilon\to0}\left(\int_{-1}^{-\varepsilon}\frac{(\log(-x)-i\pi)-(\log(-x)+i\pi)}{ix}\,dx+\int_{-\pi}^\pi \frac{\log(\varepsilon e^{i\phi})}{i\varepsilon e^{i\phi}}\,d\phi\right)\\\\ &=0\tag7 \end{align}$$
From the residue theorem, we find that
$$\begin{align} \oint_{|z|=1}\frac{\log(z-r_2)}{iz}\,dz&=2\pi \log(-r_2)\tag8 \end{align}$$
Finally, from Cauchy's Integral Theorem, we have
$$\begin{align} \oint_{|z|=1}\frac{\log(z-r_1)}{iz}\,dz&=2\pi \log(-r_1)\\\\ &+\lim_{\varepsilon\to0}\left(\int_{-1}^{r_1-\varepsilon}\frac{(\log(-(x-r_1)) -i\pi)-(\log(-(x-r_1))+i\pi)}{ix}\,dx\\\\+\int_{-\pi}^{\pi} \frac{\log(\varepsilon e^{i\phi})}{i(r_1+\varepsilon e^{i\phi})}\,i\varepsilon e^{i\phi}\,d\phi\right)\\\\ &=0\tag9 \end{align}$$
PUTTING IT ALL TOGETHER
Using $(6)-(9)$, we find that
$$\begin{align} I(a,b)&=\frac\pi2 \log\left(\frac{a^2+b^2}{2}\right)+\frac\pi2 \log(-\alpha/2)+\frac\pi2\log(-r_2)\\\\ &=\pi\log\left(\frac{a+b}{2}\right) \end{align}$$
which agrees with the expected result!