Integrate $\int\frac{\cos^2(x)-x^2\sin(x)}{(x+\cos(x))^2}dx$ I had to integrate the following integral:
\begin{equation}
\int\frac{\cos^2(x)-x^2\sin(x)}{(x+\cos(x))^2}dx
\end{equation}
but I can't find a suitable substitution to find a solution. Nothing I try works out and only seems to make it more complicated. Does anyone have an idea as to how to solve this?
I also tried to get help from WolframAlpha but it just says that there is no step-by-step solution available. 
The sollution by wolfram alpha is:
\begin{equation}
\int\frac{\cos^2(x)-x^2\sin(x)}{(x+\cos(x))^2}dx = \frac{x\cos(x)}{x+\cos(x)} + c
\end{equation}

Note that the derivative of $x + \cos(x)$ in the denominator is $1-\sin(x)$ . We can try to make this term appear in the numerator and then integrate by parts. We have
$$ \frac{\cos^2(x)-x^2\sin(x)}{(x+\cos(x))^2} = \frac{\cos^2(x) - x^2 + x^2(1-\sin(x))}{(x+\cos(x))^2} = \frac{\cos(x) - x}{x+\cos(x)} + x^2 \frac{1-\sin(x)}{(x+\cos(x))^2} \, ,$$
so
\begin{align}
\int \frac{\cos^2(x)-x^2\sin(x)}{(x+\cos(x))^2} \, \mathrm{d}x &= \int \frac{\cos(x) - x}{x+\cos(x)} \, \mathrm{d} x - \frac{x^2}{x+\cos(x)} +   \int \, \frac{2 x}{x+\cos(x)}\mathrm{d} x \\
&= x - \frac{x^2}{x+\cos(x)} = \frac{x \cos(x)}{x+\cos(x)}
\end{align}
as desired.
