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.

enter image description here

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?

  • $\begingroup$ Apparently , Wolfram alpha presents a complex antiderivate. It is possibly the problem of "knowing too much" $\endgroup$
    – Peter
    Dec 13, 2017 at 20:24
  • 5
    $\begingroup$ WA misses possible simplifications from time to time, and when it does the result may be really ugly. $\endgroup$
    – Arthur
    Dec 13, 2017 at 20:24
  • $\begingroup$ I think it used the change of variable $t = \tan(x/2)$ that works for all algebraic fractions in $\sin(x)$ and $\cos(x)$. $\endgroup$ Dec 13, 2017 at 20:26
  • 2
    $\begingroup$ 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. $\endgroup$
    – user65203
    Dec 13, 2017 at 20:35
  • 2
    $\begingroup$ Wait, WA understands $LaTeX$?!? Why was I not told sooner! $\endgroup$ Dec 13, 2017 at 20:46

1 Answer 1


Wolfram Alpha did a perfect job, as usual.

Looking just below the answer, there is a plot clearly showing that the complex version is considered.

And looking a little more below, alternate forms are given, the first of which doesn't have the complex constants.

If you worry about the hyperbolic function, you have to know that WA's answer and yours are equivalent, and the reference to a well-known function is probably a good idea.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .