# Can I blindly trust WolframAlpha?

Recently, my friend gave me the following indefinite integral to evaluate : $$\int \frac{\sin^2 x }{\sin x +\cos x} \mathrm dx$$

I searched it on WolframAlpha, just to be sure, that whether it has an elementary primitive or not. It turn out to be not a elementary one. Then I asked him, that why did he gave it to me, if it wasn't supposed to be a question for High-schoolers? His reply surprised me! He had solved it. It goes as follows -

\begin{align}\int \frac{\sin^2 x }{\sin x +\cos x}\mathrm dx &=\int \frac 12 \left( \frac{\sin^2 x +\color{blue}{\cos^2 x}}{\sin x +\cos x} + \frac{\sin^2 x -\color{blue}{\cos^2 x}}{\sin x +\cos x} \right)\mathrm dx \\ &=\frac 12 \int \frac{1}{\sin x +\cos x}\mathrm dx +\frac 12 \int (\sin x -\cos x)\mathrm dx\\ \end{align}

Now the first part can be solved using $\sin x +\cos x = \sqrt 2 \cos \left( x -\dfrac {\pi}4 \right)$ and $\int \sec x \mathrm dx = \ln (\sec x+ \tan x )$. Second part is trivial.

Did I get something wrong, or Wolfy is the wrong one here?

• Apparently , Wolfram alpha presents a complex antiderivate. It is possibly the problem of "knowing too much" Dec 13, 2017 at 20:24
• WA misses possible simplifications from time to time, and when it does the result may be really ugly. Dec 13, 2017 at 20:24
• I think it used the change of variable $t = \tan(x/2)$ that works for all algebraic fractions in $\sin(x)$ and $\cos(x)$. Dec 13, 2017 at 20:26
• By default, WA considers complex variables, which can make the answers look uselessly contrived. But as a rule of thumb, WA is always right and I disagree with other negative opinions here. IMO, the factor $(-1)^{3/4}$ is a sign that several branches can be considered.
– user65203
Dec 13, 2017 at 20:35
• Wait, WA understands $LaTeX$?!? Why was I not told sooner! Dec 13, 2017 at 20:46