Evaluate $\int {\frac{{dx}}{{{{(\sin \frac{x}{2} + \cos \frac{x}{2})}^2}}}} $ My first solution was:
$$\begin{array}{l}
\int {\dfrac{{dx}}{{{{(\sin \dfrac{x}{2} + \cos \dfrac{x}{2})}^2}}}} \\
 = \int {\dfrac{{dx}}{{{{\sin }^2}\dfrac{x}{2} + 2\sin \dfrac{x}{2}\cos \dfrac{x}{2} + {{\cos }^2}\dfrac{x}{2}}}} \\
 = \int {\dfrac{{dx}}{{1 + \sin x}}} \\
 = \int {\dfrac{{1 - \sin x}}{{1 - {{\sin }^2}x}}dx} \\
 = \int {\dfrac{1}{{1 - {{\sin }^2}x}}dx - \int {\dfrac{{\sin x}}{{1 - {{\sin }^2}x}}dx} } \\
 = \int {\dfrac{{dx}}{{{{\cos }^2}x}}}  - \int {\dfrac{{d(\cos x)}}{{{{\cos }^2}x}}} \\
 = \tan x - \dfrac{1}{{\cos x}} + C
\end{array}$$
However, the answer from Wolfram Alpha is: $\dfrac{{ - 2}}{{\tan \dfrac{x}{2} + 1}} + C$, it tells me that the step:  
$$\int {\dfrac{{1 - \sin x}}{{1 - {{\sin }^2}x}}dx} \\
 = \int {\dfrac{1}{{1 - {{\sin }^2}x}}dx - \int {\dfrac{{\sin x}}{{1 - {{\sin }^2}x}}dx} }$$ is false.
What is the problem with that step? If it is correct then where is the error in my solution?

$$\tan x-\frac{1}{\cos x}=\frac{2t}{1-t^2}-\frac{1+t^2}{1-t^2}-\frac{(1-t)^2}{(1+t)(1-t)}--\frac{1-t}{1+t}=1-\frac{2}{1+t}$$
where $t=\tan\frac12x$
so the answers are the same, modulo a constant
