# Evaluate $\int_0^{\pi/2} \ln \left(a^2\cos^2\theta +b^2\sin^2\theta\right) \,d\theta$ where $a,b$ are finite natural numbers

Evaluate $$\int_0^{\pi/2} \ln \left(a^2\cos^2\theta +b^2\sin^2\theta\right) \,d\theta$$ where $a,b$ are finite natural numbers

I have spent about a day thinking over this problem. I tried integration by parts, differentiating under integral sign (Feynman's trick, with respect to $a, b$), using some trigonometric and logarithmic properties like changing $\cos^2\theta$ to $\cos2\theta$ and hereafter some logarithmic properties, etc., but failed miserably.

Also tried to use the property that $$\int_a^b f(x)\,dx=\int_a^b f(a+b-x)\,dx$$ in-between, but still to no avail. I also tried to find similar questions on MSE but did not get a related one.

Edit

My try (Feynman's trick) :

Let $$I(a)=\int_0^{\pi/2} \ln \left(a^2\cos^2\theta +b^2\sin^2\theta\right) d\theta$$

Hence $$I'(a) =\frac 1a \int_0^{\pi/2} \frac {2a^2\cos^2\theta d\theta}{a^2\cos^2\theta +b^2\sin^2\theta}$$ $$=\frac 1a\left[ \frac {\pi}{2}+\int_0^{\pi/2} \frac {a^2\cos^2\theta -b^2\sin^2\theta}{a^2\cos^2\theta +b^2\sin^2\theta}\right]$$

Wherein between I broke $2a^2\cos^2\theta=a^2\cos^2\theta +b^2\sin^2\theta+a^2\cos^2\theta -b^2\sin^2\theta$

But now how do I continue further

• Feynman's trick works like a charm here, can you show your attempt in full detail? Jun 12, 2018 at 17:06
• I agree with Jack. Feynman's trick works here. Jun 12, 2018 at 17:06
• "finite natural numbers" ? You can omit the "finite". Jun 12, 2018 at 17:08
• @Jack D'Aurizio I have edited my try accordingly. Can you please provide some hints further or any different parameter of differentiation in the same method Jun 12, 2018 at 17:15
• The integral $$\int_{0}^{\pi/2}\frac{a^2\cos^2\theta-b^2\sin^2\theta}{a^2\cos^2\theta+b^2\sin^2\theta}\,d\theta$$ can be simply computed through the substitution $\theta=\arctan u$ and partial fraction decomposition. It equals $\frac{\pi}{2}\cdot\frac{a-b}{a+b}$, assuming that $a$ and $b$ have the same sign. Jun 12, 2018 at 17:15

Let $I(a,b)=\int_0^{\pi/2} \log(a^2\cos^2(\theta)+b^2\sin^2(\theta))\,d\theta$. Differentiating under the integral with respect to $a^2$ reveals

\begin{align} \frac{\partial I(a,b)}{\partial (a^2)}&=\int_0^{\pi/2}\frac{1}{a^2+b^2\tan^2(\theta)}\,d\theta\\\\ &=\frac{\pi/2}{a(a+b)}\tag1 \end{align}

Integrating $(1)$ with respect to $a^2$, we obtain

$$I(a,b)=\pi \log(a+b)+C$$

For $a=b$, $I(a,a)=\pi \log(a)$ from which we find that $C=-\pi\log(2)$.

Putting it all together yields

$$I(a,b)=\pi \log\left(\frac{a+b}2\right)$$

NOTE:

We see from symmetry that $I(a,b)=\pi \log\left(\frac{|a|+|b|}2\right)$ $\forall (a,b)\in \mathbb{R}^2\setminus (0,0)$.

• Now both of you( Mark and Jack) have put in trouble. Both of your answers are marvelous in its own way. So which one to accept. Jun 12, 2018 at 17:28
• Nope. Correction here. It is also applicable for $ab=0$ except for the case $a=b=0$ Jun 12, 2018 at 17:37
• @Manthanein Good catch. I'll edit. Jun 12, 2018 at 17:41
• Try $b=0$ and $a$ be some finite number. Now the integrals changes to $$\int_0^{\pi/2} \ln(a^2\cos^2\theta )d\theta=2\int_0^{\pi/2} \ln(a\cos\theta )d\theta=2\left[\frac {\pi}{2}\ln a-\frac {\pi}{2}\ln 2\right]=\pi\ln (a/2)$$ which matches with the general form you derived Jun 12, 2018 at 17:44
• @Manthanein It should match, should it not? Jun 12, 2018 at 17:45

If we assume $a,b>0$ and set $$I(a,b)=\int_{0}^{\pi/2}\log(a^2\cos^2\theta+b^2\sin^2\theta)\,d\theta$$ we have $I(a,b)=I(b,a)$ from the substitution $\theta\mapsto\frac{\pi}{2}-\theta$. On the other hand $I(a,a)=\pi\log(a)$ is trivial, so $I(a,b)=\pi\log\left(\frac{a+b}{2}\right)$ is a very reasonable conjecture. Indeed, it can be proved by computing $$\frac{\partial I}{\partial a} = \int_{0}^{\pi/2}\frac{2a\cos^2\theta}{a^2\cos^2\theta+b^2\sin^2\theta}\,d\theta$$ as suggested in the comments, i.e. via $\theta\mapsto\arctan u$ and partial fraction decomposition.

An alternative approach is to notice that $$\begin{eqnarray*} I(a,b) &=& 2\,\text{Re}\int_{0}^{\pi/2}\log\left(a\cos\theta+ib\sin\theta\right)\\&=&\pi\log\left(\frac{a+b}{2}\right)+\text{Re}\int_{0}^{\pi}\log\left(e^{i\theta}+\frac{a-b}{a+b}\right)\,d\theta\end{eqnarray*}$$ where the last integral is a purely imaginary number by the residue theorem.

• Now both of you( Mark and Jack) have put in trouble. Both of your answers are marvelous in its own way. So which one to accept. Jun 12, 2018 at 17:28
• And by the way no need to assume $a, b\gt 0$, it's already provided in in question that they are natural numbers Jun 12, 2018 at 17:30
• @Manthanein We need not assume that $a$ and $b$ are positive. Note that since the integral depends on $a^2$ and $b^2$, then the answer depends on $|a|$ and $|b|$ only. Jun 12, 2018 at 17:32
• @Mark Viola That is what I said. Morever the modulus will be removed since they are natural and always positive Jun 12, 2018 at 17:34

Integrate by parts, then substitute $$u=\tan\theta$$ :

\begin{align*} I &= \int_0^{\tfrac\pi2} \ln\left(a^2\cos^2\theta + b^2\sin^2\theta\right) \, d\theta \\ &= \pi\ln a + \int_0^{\tfrac\pi2} \ln\left(1 + \left(\frac{b^2}{a^2}-1\right) \sin^2\theta\right) \, d\theta \\ &= \pi \ln b - 2\left(\frac{b^2}{a^2}-1\right) \int_0^{\tfrac\pi2} \frac{\theta \sin\theta \cos\theta}{1 + \left(\frac{b^2}{a^2}-1\right) \sin^2\theta} \, d\theta \\ &= \pi \ln b - 2\left(\frac{b^2}{a^2}-1\right) \int_0^\infty \frac{u \arctan u}{\left(u^2+1\right) \left(\frac{b^2}{a^2} u^2 + 1\right)} \, du \end{align*}

Now, for some real $$\beta\neq0$$, let

$$J(\alpha) = \int_0^\infty \frac{u \arctan(\alpha u)}{\left(u^2+1\right) \left(\beta^2u^2+1\right)} \, du \quad [I(0)=0]$$

Differentiate w.r.t. $$\alpha$$ and evaluate the subsequent integral. Partial fractions are our friend.

$$\frac{\partial J}{\partial \alpha} = \int_0^\infty \frac{u^2}{\left(u^2+1\right) \left(\beta^2u^2+1\right) \left(\alpha^2u^2+1\right)} = \frac\pi{2\left(\beta^2-1\right)} \left[\frac1{\alpha+1} - \frac1{\alpha+\beta}\right]$$

Integrate w.r.t. $$\alpha$$:

$$J(\alpha) = \frac\pi{2\left(\beta^2-1\right)} \int_0^\alpha \left(\frac1{t+1} - \frac1{t+\beta}\right) \, dt = \frac\pi{2\left(\beta^2-1\right)} \ln \frac{\beta(\alpha+1)}{\alpha+\beta}$$

Finally, replace $$\beta=\dfrac ba$$ and let $$\alpha\to1$$ to recover $$I$$:

$$J(1) = \frac{\pi a^2}{2\left(b^2-a^2\right)} \ln \frac{2b}{a+b} \implies \boxed{I = \pi \ln \frac{a+b}2}$$

• That is quite a tedious way forward. But it does work. ;-) So (+1) Oct 19, 2023 at 21:21
• If one really wants to get one's hands dirty, $J(1)$ can be written in terms of $J(a,b,c)$ as defined in this answer Mar 22 at 1:00

Let $$r= \frac{a-b}{a+b}$$ \begin{align} & \int^{{\pi}/{2}}_{0}\ln{\left(a^2\sin^2t+b^2\cos^2t\right)}dt\\ = & \int^{\pi/2}_{0} \bigg[2\ln\frac{a+b}2+ \ln(1+r^2 -2r\cos 2t)\bigg] dt = \pi\ln\frac{a+b}2 \end{align} where \begin{align} & \int^{{\pi}/{2}}_{0} \ln(1+r^2 -2r\cos 2t) dt\\ = & \int^{\pi/2}_{0} \int_0^{r} \frac{2s-2\cos2t}{1+s^2 -2s\cos 2t}ds \ dt\\ = &\ \int_0^{r} \left(\frac1s\tan^{-1} \frac{s\sin2t}{s\cos 2t-1}\right)_{t=0}^{t=\frac\pi2}ds = \int_0^r 0 \ ds=0 \end{align}