# How to calculate $\int_{-a}^{a} \sqrt{a^2-x^2}\ln(\sqrt{a^2-x^2})\mathrm{dx}$

Well,this is a homework problem.

I need to calculate the differential entropy of random variable

$X\sim f(x)=\sqrt{a^2-x^2},\quad -a<x<a$ and $0$ otherwise. Just how to calculate $$\int_{-a}^a \sqrt{a^2-x^2}\ln(\sqrt{a^2-x^2})\,\mathrm{d}x$$ I can get the result with Mathematica,but failed to calculate it by hand.Please give me some idea.

-
Looks gross. Have you tried IBP? –  Adam Rubinson Jul 9 '12 at 16:43
Don't think there is an analytic way of doing this. Will give it a try anyway and see. –  Kasun Fernando Jul 9 '12 at 17:23
I was trying to integrate by parts. After that everything is divergent. –  Norbert Jul 9 '12 at 17:27
Try then integrating from $-R$ to $R$ and make $R \to a^-$... BTW, WA cannot find the antiderivative of your function.... –  N. S. Jul 9 '12 at 17:56
A fair bit of manipulation yields the equivalent expression $$2a^2\left(\log\,a \int_0^{\pi/2} \cos^2 u\;\mathrm du+\int_0^{\pi/2}\cos^2 u\log (\cos\,u)\mathrm du\right)$$ though the second integral is a bit tougher to handle... –  J. M. is back. Jul 9 '12 at 18:14

\begin{align} \int_{-a}^a\sqrt{a^2-x^2}\log(\sqrt{a^2-x^2})\,\mathrm{d}x &=a^2\int_{-1}^1\sqrt{1-x^2}\log(\sqrt{1-x^2})\,\mathrm{d}x\\ &+a^2\log(a)\int_{-1}^1\sqrt{1-x^2}\,\mathrm{d}x\\ &=a^2\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\cos^2(t)\log(\cos(t))\,\mathrm{d}t\\ &+a^2\log(a)\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\cos^2(t)\,\mathrm{d}t\tag{1} \end{align} The standard trick is to note that $$\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\cos^2(t)\,\mathrm{d}t=\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\sin^2(t)\,\mathrm{d}t\tag{2}$$ and add the left side to both sides and divide by $2$: $$\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\cos^2(t)\,\mathrm{d}t=\frac\pi2\tag{3}$$ Now it gets just a bit trickier, but not so bad. Integration by parts yields \begin{align} \int_{-\Large\frac\pi2}^{\Large\frac\pi2}\cos^2(t)\log(\cos(t))\,\mathrm{d}t &=\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\cos(t)\log(\cos(t))\,\mathrm{d}\sin(t)\\ &=\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\sin^2(t)\log(\cos(t))+\sin^2(t)\,\mathrm{d}t\tag{4} \end{align} Now adding the left hand side of $(4)$ to both sides and dividing by $2$ after applying $(2)$ and $(3)$ gives $$\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\cos^2(t)\log(\cos(t))\,\mathrm{d}t =\frac12\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\log(\cos(t))\,\mathrm{d}t+\frac\pi4\tag{5}$$ Next, note that \begin{align} \int_{-\Large\frac\pi2}^{\Large\frac\pi2}\log(\cos(t))\,\mathrm{d}t &=\frac12\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\log(\cos^2(t))\,\mathrm{d}t\\ &=\frac12\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\log(\sin^2(t))\,\mathrm{d}t\tag{6} \end{align} Adding the last two parts of $(6)$ and dividing by $2$ yields \begin{align} \int_{-\Large\frac\pi2}^{\Large\frac\pi2}\log(\cos(t))\,\mathrm{d}t &=\frac14\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\log(\tfrac14\sin^2(2t))\,\mathrm{d}t\\ &=\frac18\int_{-\pi}^{\pi}\log(\tfrac14\sin^2(t))\,\mathrm{d}t\\ &=\frac14\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\log(\tfrac14\sin^2(t))\,\mathrm{d}t\tag{7} \end{align} Equating $(6)$ and $(7)$ and subtracting half of $(6)$ from both and multiplying by $2$ gives us $$\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\log(\cos(t))\,\mathrm{d}t =-\pi\log(2)\tag{8}$$ Now it's all substituting back. Plug $(8)$ into $(5)$ to get $$\int_{-\Large\frac\pi2}^{\Large\frac\pi2}\cos^2(t)\log(\cos(t))\,\mathrm{d}t =\frac\pi4-\frac\pi2\log(2)\tag{9}$$ To finish off, plug $(3)$ and $(9)$ into $(1)$: \begin{align} \int_{-a}^a\sqrt{a^2-x^2}\log(\sqrt{a^2-x^2})\,\mathrm{d}x &=a^2\left(\frac\pi4-\frac\pi2\log(2)+\frac\pi2\log(a)\right)\\ &=\pi\frac{a^2}{4}\log\left(e\frac{a^2}{4}\right)\tag{10} \end{align}

-
(+1) Finally, I see a new approach. Very nice! –  Norbert Jul 9 '12 at 22:15
@Norbert: and a new final form as well :-) –  robjohn Jul 10 '12 at 0:27
Amazing!Just what I want to find.(6)(7)=>(8) is so tricky,I will never think of it by myself. –  bigeast Jul 10 '12 at 1:53

For the begining $$\int\limits_{-a}^{a}\sqrt{a^2-x^2}\log\sqrt{a^2-x^2}dx= 2\int\limits_{0}^{a}\sqrt{a^2-x^2}\log\sqrt{a^2-x^2}dx=\{x=a\sqrt{1-y^2}\}=$$ $$2\int\limits_{0}^{1}ay\log(ay) \frac{aydy}{\sqrt{1-y^2}}= 2a^2\int\limits_{0}^{1}\frac{y^2}{\sqrt{1-y^2}}(\log a+\log y)dy=$$ $$2a^2\log(a)\int\limits_{0}^{1}\frac{y^2}{\sqrt{1-y^2}}dy+2a^2\int\limits_{0}^{1}\frac{y^2\log y}{\sqrt{1-y^2}}dy= 2a^2\log (a) I(2)+2a^2 J(2)\tag{1}$$ where $$I(p)=\int\limits_{0}^1\frac{y^p}{\sqrt{1-y^2}}dy\qquad J(p)=\int\limits_{0}^1\frac{y^p\log y}{\sqrt{1-y^2}}dy$$ Note that $$I(p)=\int\limits_{0}^1\frac{y^p}{\sqrt{1-y^2}}dy=\{s=y^2\}= \int\limits_{0}^1\frac{s^{p/2}}{\sqrt{1-s}}\frac{ds}{2\sqrt{s}}= \frac{1}{2}\int\limits_{0}^1 s^{(p+1)/2-1}(1-s)^{1/2-1}ds=$$ $$\frac{1}{2}B\left(\frac{1}{2},\frac{p+1}{2}\right)= \frac{1}{2}\frac{\Gamma\left(\frac{1}{2}\right)\Gamma\left(\frac{p+1}{2}\right)}{\Gamma\left(\frac{p+2}{2}\right)}= \frac{\sqrt{\pi}}{2}\frac{\Gamma\left(\frac{p+1}{2}\right)}{\Gamma\left(\frac{p+2}{2}\right)}$$ Now take $p=2$, then $$I(2)=\frac{\sqrt{\pi}}{2}\frac{\Gamma\left(\frac{3}{2}\right)}{\Gamma(2)}= \frac{\sqrt{\pi}}{2}\frac{\sqrt{\pi}/2}{1}=\frac{\pi}{4}\tag{2}$$ Now we proceed to the second integral $$J(p)=\int\limits_{0}^1\frac{y^p\log y}{\sqrt{1-y^2}}dt= \frac{dI}{dp}= \frac{\sqrt{\pi}}{2}\frac{d}{dp}\left(\frac{\Gamma\left(\frac{p+1}{2}\right)}{\Gamma\left(\frac{p+2}{2}\right)}\right)= \frac{\sqrt{\pi}}{4}\frac{\Gamma'\left(\frac{p+1}{2}\right)\Gamma\left(\frac{p+2}{2}\right)-\Gamma\left(\frac{p+1}{2}\right)\Gamma'\left(\frac{p+2}{2}\right)}{\Gamma\left(\frac{p+2}{2}\right)^2}$$ $$\frac{\sqrt{\pi}}{4}\left(\frac{\Gamma\left(\frac{p+1}{2}\right)\psi^{(0)}\left(\frac{p+1}{2}\right)}{\Gamma\left(\frac{p+2}{2}\right)}-\frac{\Gamma\left(\frac{p+1}{2}\right)\psi^{(0)}\left(\frac{p+2}{2}\right)}{\Gamma\left(\frac{p+2}{2}\right)}\right)=$$ $$\frac{\sqrt{\pi}}{4}\frac{\Gamma\left(\frac{p+1}{2}\right)}{\Gamma\left(\frac{p+2}{2}\right)}\left(\psi^{(0)}\left(\frac{p+1}{2}\right)-\psi^{(0)}\left(\frac{p+2}{2}\right)\right)$$ Now take $p=2$, then $$J(2)=\int\limits_{0}^1\frac{y^2\log y}{\sqrt{1-y^2}}dt= \frac{\sqrt{\pi}}{4}\frac{\Gamma\left(\frac{3}{2}\right)}{\Gamma(2)}\left(\psi^{(0)}(1)-\psi^{(0)}\left(\frac{3}{2}\right)\right)= \frac{\sqrt{\pi}}{4}\frac{\sqrt{\pi}/2}{1}\left(\psi^{(0)}\left(\frac{3}{2}\right)-\psi^{(0)}(2)\right)= \frac{\pi}{2}\left(\psi^{(0)}\left(\frac{3}{2}\right)-\psi^{(0)}(2)\right)$$ Well now we need values for polygamma function. We use the following two results given in wikipedia $$\psi^{(m)}(z)=(-1)^{m+1}m!\sum\limits_{k=0}^\infty\frac{1}{(z+k)^{m+1}}\tag{3}$$ $$n\psi^{(0)}(n z)-n\log n=\sum\limits_{k=0}^{n-1}\psi^{(0)}\left(z+\frac{k}{n}\right)\tag{4}$$ From $(3)$ we get $$\psi^{(0)}(1)=-\sum\limits_{k=0}^\infty\frac{1}{1+k}=-\gamma$$ $$\psi^{(0)}(2)=-\sum\limits_{k=0}^\infty\frac{1}{2+k}=1-\sum\limits_{k=0}^\infty\frac{1}{2+k}=1-\gamma$$ From $(4)$ with $n=2$ and $z=1$ we get $$2\psi^{(0)}(2)-2\log 2=\psi^{(0)}(1)+\psi^{(0)}\left(\frac{3}{2}\right)$$ hence $$\psi^{(0)}\left(\frac{3}{2}\right)=2\psi^{(0)}(2)-2\log 2-\psi^{(0)}(1)$$ Thus, $$J(2)=\frac{\pi}{8}(2\psi^{(0)}(2)-2\log 2-\psi^{(0)}(1)-\psi^{(0)}(2))= \frac{\pi}{8}(\psi^{(0)}(2)-2\log 2-\psi^{(0)}(1))= \frac{\pi}{8}(1-\gamma-2\log 2+\gamma)= \frac{\pi}{8}(1-\log 4)=$$ Finally!!! $$\int\limits_{-a}^{a}\sqrt{a^2-x^2}\log\sqrt{a^2-x^2}dx= 2a^2\log (a) I(2)+2a^2 J(2)= 2a^2\log (a) \frac{\pi}{4}+2a^2 \frac{\pi}{8}(1-\log 4)= \frac{\pi a^2}{4}\left(\log \frac{a^2}{4}+1\right)$$

-
+1 for the work (and sicne "finally" made me smile :)) –  Belgi Jul 9 '12 at 20:16

This integral can be performed via differentiation under the integral sign. First note that for $|x|\leq1$ we have $\ln \sqrt{1-x^2} = \frac12\ln (1-x^2)$. Moreover, simple application of the chain rule yields $$\frac{d}{d\alpha} (1-x^2)^\alpha = (1-x^2)^\alpha \ln(1-x^2) .$$

The remaining integral is a special case of the beta function with $x=1/2$ and $y=\alpha+1$. Thus, we have $$\int_0^1\!dx\,(1-x^2)^\alpha = \frac12\int_0^1\!dy\,y^{1/2} (1-y)^\alpha= \frac{\sqrt{\pi} \Gamma(1+\alpha)}{2 \Gamma(\frac{3}{2} + \alpha)}.$$

The original integral, we obtain by taking the derivative with respect to $\alpha$ and afterwards setting $\alpha=1/2$; \begin{align}\int_{-a}^a\!dx\,\sqrt{a^2-x^2} \ln\sqrt{a^2-x^2} &=a^{2} \int_{0}^1\!dx\,\sqrt{1-x^2} [\ln a^2 + \ln(1-x^2)]\\ &= \frac{a^2 \pi \log a}{2}+ a^{2} \frac{d}{d\alpha} \int_0^1\!dx\,(1-x^2)^\alpha \Big|_{\alpha=1/2}\\ &= \frac{a^2 \pi \log a}{2}+ a^{2} \frac{d}{d\alpha} \frac{\sqrt{\pi} \Gamma(1+\alpha)}{2 \Gamma(\frac{3}{2} + \alpha)} \Big|_{\alpha=1/2} \\ &= \frac{a^2 \pi \log a}{2}+ a^{2} \frac{\Gamma(1+\alpha)}{\Gamma(3/2+\alpha)} [\psi(1+\alpha)-\psi(\tfrac{3}{2}+\alpha)]\Big|_{\alpha=1/2} \\ &=\frac{a^2 \pi \log a}{2}+ \frac{a^{2}\pi}4(1-2 \ln 2). \end{align} Where we used the special values of the $\Gamma$ and the $\psi = (\log \Gamma)'$ at integer and half-integer values.

-
Nice, concise use of the Beta function (+1). –  robjohn Jul 9 '12 at 22:06
Short and sweet. (+1) –  user26872 Jul 9 '12 at 22:27

[Some ideas] You can rewrite it as follows: $$\int_{-a}^a \sqrt{a^2-x^2} f(x) dx$$ where $f(x)$ is the logarithm.

Note that the integral, sans $f(x)$, is simply a semicircle of radius $a$. In other words, we can write, $$\int_{-a}^a \int_0^{\sqrt{a^2-x^2}} f(x) dy dx=\int_{-a}^a \int_0^{\sqrt{a^2-x^2}} \ln{\sqrt{a^2-x^2}} dy dx$$

Edit: Found a mistake. Thinking it through. :-)

-

If you let $x = a\sin(\theta)$, your integral becomes $$a^2\int_{-{\pi \over 2}}^{\pi \over 2} \ln(a\cos(\theta))\cos^2(\theta)\,d\theta$$ $$= 2a^2\int_0^{\pi \over 2} \ln(a\cos(\theta))\cos^2(\theta)\,d\theta$$ $$= 2a^2\ln(a)\int_0^{\pi \over 2}\cos^2(\theta)\,d\theta + 2a^2\int_0^{\pi \over 2} \ln(\cos(\theta))\cos^2(\theta)\,d\theta$$ The first integral is standard, and we get $$={\pi a^2 \ln(a)\over 2} + 2a^2\int_0^{\pi \over 2} \ln(\cos(\theta))\cos^2(\theta)\,d\theta$$ The integral here is ${\displaystyle {d \over dn}\bigg|_{n = 2} \int_0^{\pi \over 2} \cos^n(\theta)\,d\theta}$. According to Wolfram Alpha, $$\int_0^{\pi \over 2} \cos^n(\theta)\,d\theta = {\sqrt{\pi} \over 2}{\Gamma({n +1 \over 2}) \over \Gamma({n \over 2} + 1)}$$ Taking the derivative of this and setting $n = 2$ works out to $(\sqrt{\pi}/4)(\Gamma'({3/2}) - \Gamma'(2)\Gamma(3/2))= (\sqrt{\pi}/4)(\Gamma'({3/2}) - \Gamma'(2)(\sqrt{\pi}/2))$. So plugging this in gives as your answer: $$={\pi a^2 \ln(a)\over 2} + {\sqrt{\pi}a^2 \over 2}(\Gamma'({3/2}) - \Gamma'(2){\sqrt{\pi} \over 2})$$ Using $\Gamma'(3/2) = {\sqrt{\pi} \over 2}(2 - \gamma - \ln 4)$ and $\Gamma'(2) = 1 - \gamma$, where $\gamma$ is the Euler-Mascheroni constant, this becomes $$={\pi a^2 \ln(a)\over 2} + {\sqrt{\pi}a^2 \over 2}({\sqrt{\pi} \over 2} -{\sqrt{\pi} \ln 4 \over 2})$$ $$= {\pi a^2 \ln(a)\over 2} + {\pi a^2 \over 4} -{\pi a^2 \over 4} \ln 4$$

-