# Extremely ugly integral $\int_{-\pi}^{\pi} \frac{\operatorname{sign}(x)\arctan(x^2)-|x|}{\sin^2(x)+|\cos(x)|}\,dx$

Evaluate: $\DeclareMathOperator{\sign}{sign}$ $$\int_{-\pi}^{\pi} \dfrac{\sign(x)\arctan(x^2)-|x|}{\sin^2(x)+|\cos(x)|}\,dx$$

My idea:

\begin{align*}I=\int_{-\pi}^{\pi} \frac{\sign(x)\arctan(x^2)-|x|}{\sin^2(x)+|\cos(x)| }\,dx &=\int_{-\pi}^{\pi} \dfrac{\sign(-x)\arctan((-x)^2)-|-x|}{\sin^2(x)+|\cos(x)|}\,dx\\ &=\int_{-\pi}^{\pi} \frac{-\sign(x)\arctan(x^2)-|x|}{ \sin^2(x)+|\cos(x)| }\,dx. \end{align*}

So, it means that the integral $$\int_{-\pi}^{\pi} \frac{\sign(x)\arctan(x^2)}{\sin^2(x)+|\cos(x)| }\,dx=0.$$

Therefore, my integral now looks like

$$I=\int_{-\pi}^{\pi} \frac{-|x|}{\sin^2(x)+|\cos(x)|}\,dx,$$

and since my integrand is even function, I have:

$$I=-2\int_{0}^{\pi} \frac{|x|}{ \sin^2(x)+|\cos(x)| }\,dx=-2\int_{0}^{\pi} \frac{x}{ \sin^2(x)+|\cos(x)| }\,dx.$$

And so, \begin{align*} \frac{I}{2}&=-\int_{0}^{\pi} \frac{x}{ \sin^2(x)+|\cos(x)| }\,dx\\ &=-\int_{0}^{\pi} \frac{\pi-x}{ \sin^2(\pi-x)+|\cos(\pi-x)|}\,dx\\ &=-\pi\int_{0}^{\pi} \frac{dx}{ \sin^2(x)+|\cos(x)|}+\int_{0}^{\pi} \frac{x}{ \sin^2(x)+|\cos(x)| }\,dx\\ &=-\pi\int_{0}^{\pi} \frac{dx}{ \sin^2(x)+|\cos(x)| }-\frac{I}{2}. \end{align*}

Hence, $$I=-\pi\int_{0}^{\pi} \dfrac{dx}{ \sin^2(x)+|\cos(x)| }.$$

That is the end of the road. I tried to eliminate absolute value over the cosine but always get some divergent integral. Is this computation correct and if it is, what next? Bonus question: Where can I find more problems like this?

• I suspect more care may be required as the integrand is not defined at points where $|\cos x| = \sin^2 x$. There are four such points on $[-\pi, \pi]$. – tilper May 1 '17 at 13:51
• What on earth makes you assume this is elementary? Moreover, what makes you think this converges? Your function blows up at infinitely many points. – Brevan Ellefsen May 1 '17 at 14:03
• Shouldn't $$I=\int\limits_{-\pi}^{\pi} \dfrac{-2|x|}{\sin^2(x)-|\cos(x)|}dx?$$ – Shaun May 1 '17 at 14:08
• The integral diverges logarithmically. – Mark Viola May 1 '17 at 14:17
• Symmetry says $\int_0^\pi{dx\over\sin^2x+|\cos x|}=2\int_0^{\pi/2}{dx\over\sin^2x+\cos x}$ – Barry Cipra May 1 '17 at 15:43

I can't take full credit for this, Wolfram can be very helpful when you know how to coax it along.

For the integral

$$\int{dx\over\sin^2x+\cos x},$$

let

\begin{align*} u &= \tan\left(\frac{x}{2}\right)\\ du &= \frac{1}{2}\sec^{2}\left(\frac{x}{2}\right)\,dx. \end{align*}

Then we have \begin{align*} \sin x &= \frac{2\sin x}{1 +\cos x}\cdot \frac{1+\cos x}{2} = \frac{2\tan^{2}\left(\frac{x}{2}\right)}{\sec^{2}\left(\frac{x}{2}\right)} = \frac{2\tan^{2}\left(\frac{x}{2}\right)}{\tan^{2}\left(\frac{x}{2}\right)+1}=\frac{2u^{2}}{u^{2}+1}\\ \cos x&= \frac{2\cos x}{1+\cos x}\cdot\frac{1+\cos x}{2}=\frac{1+\cos x - 1 + \cos x}{(1+\cos x)\sec^{2}\left(\frac{x}{2}\right)}=\frac{1-\frac{1-\cos x}{1+\cos x}}{\sec^{2} \left(\frac{x}{2}\right)}= \frac{1-u^{2}}{u^{2}+1}\\ dx &= \frac{2\,du}{u^{2}+1}. \end{align*}

The integral then becomes \begin{align*} 2\int \frac{du}{(u^{2}+1)\left[\frac{4u^{2}}{(u^{2}+1)^{2}}+\frac{1-u^{2}}{u^{2}+1}\right]} &=-2\int\frac{u^{2}+1}{u^{4}-4u^{2}-1}\,du\\ &=-2\int\frac{u^{2}+1}{\left(u^{2}-\sqrt{5}-2\right)\left(u^{2}+\sqrt{5}-2\right)}\,du. \end{align*}

We can then use a partial fraction decomposition, which I will omit, to change the integral to \begin{align*} -\int\frac{\sqrt{5}-3}{\sqrt{5}\left(u^{2}+\sqrt{5}-2\right)}\,du -\int\frac{-3-\sqrt{5}}{\sqrt{5}\left(-u^{2}+\sqrt{5}+2\right)}\,du, \end{align*}

which becomes \begin{align*}\frac{3-\sqrt{5}}{\sqrt{5}}\int\frac{du}{u^{2}+\sqrt{5}-2} + \frac{3+\sqrt{5}}{\sqrt{5}}\int\frac{du}{-u^{2} + \sqrt{5} +2}. \end{align*}

We can rewrite this as $$\frac{3-\sqrt{5}}{\sqrt{5}(\sqrt{5}-2)}\int\frac{du}{1+\left(\frac{u}{\sqrt{\sqrt{5}-2}}\right)^{2}}+\frac{3+\sqrt{5}}{\sqrt{5}(\sqrt{5}+2)}\int\frac{du}{1-\left(\frac{u}{\sqrt{\sqrt{5}+2}}\right)^{2}}.$$

This then becomes

$$\frac{3-\sqrt{5}}{\sqrt{5}\sqrt{\sqrt{5}-2}}\tan^{-1}\left(\frac{u}{\sqrt{\sqrt{5}-2}}\right)+\frac{3+\sqrt{5}}{\sqrt{5}\sqrt{\sqrt{5}+2}}\tanh^{-1}\left(\frac{u}{\sqrt{\sqrt{5}+2}}\right)+C,$$

or substituting back

$$\frac{3-\sqrt{5}}{\sqrt{5}\sqrt{\sqrt{5}-2}}\tan^{-1}\left(\frac{\tan\left(\frac{x}{2}\right)}{\sqrt{\sqrt{5}-2}}\right)+\frac{3+\sqrt{5}}{\sqrt{5}\sqrt{\sqrt{5}+2}}\tanh^{-1}\left(\frac{\tan\left(\frac{x}{2}\right)}{\sqrt{\sqrt{5}+2}}\right)+C.$$

Since this expression vanishes at $x=0$, your integral is given by

$$-2\pi\left(\frac{3-\sqrt{5}}{\sqrt{5}\sqrt{\sqrt{5}-2}}\tan^{-1}\left(\frac{\tan\left(\frac{\pi}{4}\right)}{\sqrt{\sqrt{5}-2}}\right)+\frac{3+\sqrt{5}}{\sqrt{5}\sqrt{\sqrt{5}+2}}\tanh^{-1}\left(\frac{\tan\left(\frac{\pi}{4}\right)}{\sqrt{\sqrt{5}+2}}\right)\right)\approx -8.734.$$

You've done most part of the problem. I can't solve the last integral, but I believe I can provide an approximate solution. Let us take $f(x) = \sin^2 x + |cos x|$. The graphs of $|\cos x|$ and $\cos^2 x$ are pretty close. So $f(x)$ will always be quite close to $1$. Now, to find the maxima and minima values of the function, we need only look at one part where $\cos x$ is positive. To find the maxima and minima, then,

$2\sin x\cos x - \sin x = 0 \implies \sin x = 0 \text{ or } \cos x = \frac12.$

Hence, $\min f = 1$ and $\max f = \frac54$. We're interested in the integral of $g(x) = \frac{1}{f(x)}$. Clearly $g$ oscillates between $\frac45$ and $1$. The values being pretty close, let us approximate $g(x)$ as a constant function $g(x) = \frac12 \left( \frac45 + 1\right) = \frac9{10}$.

Thus, $I \approx -\pi \int_0^\pi \frac9{10} dx = -\frac{9}{10}\pi^2$.

• Thank you, it is an interesting point of view and I like it, but my professor is not interested in approximation. Do you know any books with problems like this? – Peđa Pilipović May 1 '17 at 16:00

Noting $$\int_0^{\pi/2}\frac{1}{\sin^2x+\cos x}dx=\int_0^{\pi/2}\frac{1}{\cos^2x+\sin x}dx=\int_0^{\pi/2}\frac{1}{1-\sin^2x+\sin x}dx$$ and using $u=\tan(\frac{x}{2})$, one has \begin{eqnarray} \int_0^{\pi/2}\frac{1}{1-\sin^2x+\sin x}dx&=&\int_0^{\pi/2}\frac{1}{1-(\frac{2\tan(\frac{x}{2})}{1+\tan^2(\frac{x}{2})})^2+\frac{2\tan(\frac{x}{2})}{1+\tan^2(\frac{x}{2})}}dx\\ &=&\int_0^1\frac{1}{1-(\frac{2u}{1+u^2})^2+\frac{2u}{1+u^2}}\frac{2du}{1+u^2}\\ &=&\int_0^1\frac{u^2+1}{u^4+2u^3-2u^2+2u+1}du\\ &=&\int_0^1\frac{u^2+1}{[(u-\phi)^2+\phi][(u+\frac1\phi)^2-\frac1\phi]}du \end{eqnarray} Here $\phi=\frac{-1+\sqrt5}{2}$. Noting $$\frac{u^2+1}{[(u-\phi)^2+\phi][(u+1/\phi)^2-1/\phi]}=-\frac{\phi}{\sqrt5}\frac{1}{(u-\phi)^2+\phi}+\frac{1}{\sqrt5\phi}\frac{1}{(u+\frac1\phi)^2-\frac1\phi}$$ one has \begin{eqnarray} \int_0^{\pi/2}\frac{1}{1-\sin^2x+\sin x}dx &=&\int_0^1\frac{u^2+1}{[(u-\phi)^2+\phi][(u+\frac1\phi)^2-\frac1\phi]}du\\ &=&-\frac{\phi}{\sqrt5}\int_0^1\frac{1}{(u-\phi)^2+\phi}du+\frac{1}{\sqrt5\phi}\int_0^1\frac{1}{(u+\frac1\phi)^2-\frac1\phi}du\\ &=&-\frac{\sqrt\phi}{\sqrt5}\bigg[\arctan(\frac{u-\phi}{\sqrt\phi})-\text{arctanh}(\frac{1+u\phi}{\sqrt\phi})\bigg]\bigg|_0^1\\ &=&-\frac{\sqrt\phi}{\sqrt5}\bigg[\arctan(\frac{1-\phi}{\sqrt\phi})+\arctan\sqrt\phi-\text{arctanh}(\frac{1}{\phi\sqrt\phi})+\text{arctanh}\sqrt\phi\bigg]. \end{eqnarray}