# How to calculate $\int_{0}^{\pi/2}x^2\sqrt{\cos (x)}dx$

I've tried everything. I made $x = \pi / 2 - y$. I looked up the questions here on MSE and did not see anything similar.

I thought I'd use complex variables, but I do not even know where to start.

• I don't think that you will be able to find the antiderivative of $x^2\sqrt{\cos(x)}$: wolframAlpha gives that "monster" – Holo Jul 15 '18 at 22:50
• Where is the monster? An result containing the known elementary functions is impossible. – Dr. Sonnhard Graubner Jul 15 '18 at 22:52
• You can use a numerical way to catch this. – Dr. Sonnhard Graubner Jul 15 '18 at 22:53
• I want a certain value of integral. – Mathsource Jul 15 '18 at 22:55
• Here it is $$.71728411711845890580$$ – Dr. Sonnhard Graubner Jul 15 '18 at 23:01

In the question I asked here Integral $$\int_0^{\frac{\pi}{2}} x^2 \sqrt{\sin x} \, dx$$ Frank Wei showed a way to evaluate your integral. I will try to show another method with the approach I started the integral I posted there. $$I=\int_0^{\frac{\pi}{2}} x^2 \sqrt{\cos{x}}dx = \int_0^{\frac{\pi}{2}}x^2 (1+\tan^2 (x))^{-\frac{1}{4}}dx$$ Substituting $$\tan x=y\,$$ and writing the arctangent function in logarithmic form leads to: $$I=\int_0^\infty \arctan^2 (x) (1+x^2)^{-\frac{5}{4}} dx=-\frac{1}{4}\int_0^{\infty}\log^2\left(\frac{1-ix}{1+ix}\right)(1+x^2)^{-\frac{5}{4}} \, dx$$ Also by letting $$\,\displaystyle{\frac{1-ix}{1+ix}=y\Rightarrow x=i\frac{1-y}{1+y}}\,$$ we get the integral to be: $$I=\Re\left(-\frac{i} {8\sqrt 2}\int_{-1}^1 \log^2 (y) \, y^{-\frac54} \sqrt{1+y} \, dy\right)$$ Now we split the integral from $$\int_{-1}^0$$ and $$\int_0^1.\$$Also substituting $$y=-x$$, the second splitted part vanishes being purely imaginary, so we are left with: $$I=\Re \left(\frac{1+i}{16}\int_0^1 x^{-\frac54} \sqrt{1-x} (-\pi^2 +2 i \pi \log x +\log^2 x) dx\right)$$ $$\Rightarrow I=-\frac{\pi^2}{16} \int_0^1 x^{-\frac14-1}(1-x)^{\frac32-1}dx - \frac{\pi} {8}\int_0^1 x^{-\frac14-1}(1-x)^{\frac32-1} \log x\,dx+\frac{1} {16} \int_0^1 x^{-\frac14-1}(1-x)^{\frac32-1}\log^2(x)\,dx$$ We can evaluate these integrals using the beta function, indeed: $$I=-\frac{\pi^2} {16} B\left(-\frac14, \frac32\right) -\frac{\pi} {8}\frac{d}{dz} B\left(z, \frac32\right)\big|_{z=-\frac14}+\frac{1} {16}\frac{d^2 }{dz^2 } B\left(z, \frac32\right)\big|_{z=-\frac14}$$ I let you do the algebra in order to get: $$I=\sqrt {2}\pi^{\frac{3}{2}}\frac{\pi^2+8G-16}{\Gamma^2\left(\frac{1}{4}\right)}$$

• Where $G$ is Catalan's constant, as per @FrankWei's answer – peter a g Jul 16 '18 at 1:11
• This is pure beauty ! Thanks for providing such an answer. Cheers. – Claude Leibovici Jul 16 '18 at 5:19
• Cannot we use some other methods ? What if I split up $x^2$ as $-x\left(\dfrac{\pi}{2} -x \right) + \dfrac{\pi x}{2}$ ? I am wondering if that'll lead to a simple solution. Your solution is too advanced for me to understand. – DarkKnight Jul 16 '18 at 6:12

Just for the fun of it !

Since Dahaka provided a splendid and exact solution, I have been wondering what would give the approximation $$\cos(x) \simeq\frac{\pi ^2-4x^2}{\pi ^2+x^2}\qquad (-\frac \pi 2 \leq x\leq\frac \pi 2)$$ So, considering $$I=\int_0^{\frac \pi 2}x^2 \sqrt{\frac{\pi ^2-4 x^2}{x^2+\pi ^2}}\,dx$$ the antiderivative expresses in terms of elliptic integrals but, using bounds, we get the simple $$I=\frac{ \pi ^3}{6} \left(9 E\left(-\frac{1}{4}\right)-10 K\left(-\frac{1}{4}\right)\right)\approx 0.71832$$ which is in error by $0.14$%.

To find a primitive is arduous with the usual methods.

We could provide a rough approximation with the midpoint formula. Let $f(x)=x^2\sqrt\cos x$ $$\int_0^{\pi/2}f(x)\approx \frac{\pi}{2}f\bigg(\frac{\pi}{4}\bigg)=0.8148.$$

If you want a more accurate approximation, a simple way is through the Legendre polynomials. The Legendre polynomias are given by $$P_n(x)=\frac{1}{2^nn!}\frac{d^n}{dx^n}(x^2-1)^n.$$ We place $n=2$, $P_2(x)=\frac{1}{2}(3x^2-1)$. The quadrature formula, in this case, is $$\int_{-1}^1f(x)\;dx\approx\sum_{i=1}^2 A_if(x_i),$$ where $$A_i=\int_{-1}^1\frac{P_2(x)}{(x-x_i)P'_2(x_i)}\;dx$$ and $x_i$ for $i=1,2$ are $P_2(x)$ roots. Now, $A_1=A_2=1$ and $x_1=-\frac{1}{\sqrt{3}}$, $x_2=\frac{1}{\sqrt{3}}$.

Therefore $$\int_a^{b} f(x)\;dx=\frac{b-a}{2}\int_{-1}^{1} f\bigg(\frac{a+b}{2}+t\frac{b-a}{2}\bigg)\;dt\approx \frac{b-a}{2}\bigg[1\cdot f(y_1)+1\cdot f(y_2)\bigg],$$ where

$$y_1=\frac{a+b}{2}-\frac{1}{\sqrt{3}}\frac{b-a}{2}\quad \text{and}\quad y_2=\frac{a+b}{2}+\frac{1}{\sqrt{3}}\frac{b-a}{2}.$$

Then

$$\int_0^{\pi/2} f(x)\;dx\approx 0.77$$