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. 
 A: Using $\displaystyle (x\cdot \sin x+n\cdot \cos x) = \sqrt{x^2+n^2}\left\{\frac{x}{\sqrt{x^2+n^2}}\cdot \sin x+\frac{n}{\sqrt{x^2+n^2}}\cdot \cos x\right\}$
$$\displaystyle = \sqrt{x^2+n^2}\cdot \cos\left(x-\phi\right)\;,$$ where $\displaystyle \sin \phi = \frac{x}{\sqrt{x^2+n^2}}$ and $\displaystyle \cos \phi = \frac{n}{\sqrt{x^2+n^2}}$ and $\displaystyle \tan \phi = \frac{x}{n}\Rightarrow \phi = \tan^{-1}\left(\frac{x}{n}\right)$
So Integral is $$\displaystyle = \int \sec^2(x-\phi)\cdot \left(\frac{x^2+n(n-1)}{x^2+n^2}\right)dx$$
Now Let $$\displaystyle (x-\phi) = y\Rightarrow \left(x-\tan^{-1}\left(\frac{x}{n}\right)\right)=y$$. Then $$\displaystyle \left(\frac{x^2+n(n-1)}{x^2+n^2}\right)dx = dy$$
So Integral is $$\displaystyle \int \sec^2(y)dy = \tan y +\mathbb{C} = \tan\left(x-\tan^{-1}\left(\frac{x}{n}\right)\right)+\mathbb{C}$$
So $$\displaystyle \int \frac{x^2+n(n-1)}{(x\cdot \sin x+n\cdot \cos x)^2}dx = \left(\frac{n\cdot \tan x-x}{n+x\cdot \tan x}\right)+\mathcal{C}= \frac{n\sin x-x\cos x}{n\cos x+x\sin x}+\mathcal{C}$$
A: 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}.$
A: Hint: Multiply and Divide the Integrand by $x^{2n-2}$. 
