<s>[INST] Challenging Integral [indefinite] Integrate: $$\int \frac{x^2+n(n-1)}{(x\sin x+n\cos x )^2}dx$$
I've been beating my head around this problem for quite some time now, but I've got nowhere. I'd request the person writing the solution to please explain his thought process because I would like to learn how to appraoch such Integrals in the future. 
 [/INST] Using the identities $n^2+x^2=(n\sin x-x\cos x)^2+(n\cos x+x\sin x)^2$ and
$n=\sin x(n\sin x-x\cos x)+\cos x(n\cos x+x\sin x)$, we can rewrite the integral as
$\displaystyle \int\frac{(n\sin x-x\cos x)^2+(n\cos x+x\sin x)^2-[\sin x(n\sin x-x\cos x)+\cos x(n\cos x+x\sin x)]}{(n\cos x+x\sin x)^2} dx$
$\displaystyle=\int\frac{(n\cos x+x\sin x)[n\cos x+x\sin x-\cos x]-(n\sin x-x\cos x)[-n\sin x+x\cos x+\sin x]}{(n\cos x+x\sin x)^2} dx$
$\displaystyle=\int\bigg(\frac{n\sin x-x\cos x}{n\cos x+x\sin x}\bigg)^{\prime} dx$
$\;\;\;\;\displaystyle=\frac{n\sin x-x\cos x}{n\cos x+x\sin x}.$
</s>