<s>[INST] 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?
 [/INST] If $f(x) = \tan x - \sec x + C $
Then $f'(x) = \sec^2 x - \sec \tan x = \sec x ( \sec x - \tan x ) $
Multiplying top and bottom by $(\sec x + \tan x ) $
$f'(x) = \dfrac{\sec x}{\sec x + \tan x } $
Multiplying top and bottom by $\cos x $
$f'(x) = \dfrac{1}{1 + \sin x }$
So, your answer is correct.
</s>