Advice on integrating $\int \frac{x^2 +n(n-1)}{(x \sin x +n \cos x)^2} dx$ Our integral is:
$$\int \frac{x^2 +n(n-1)}{(x \sin x + n\cos x)^2} dx$$
I considered that this can be turned into some sort of quotient differential:
$$ d \frac{u}{v} = \frac{ v du - u dv}{v^2}$$
Now, comparing this with our integral:
$$ v = x \sin x + \cos x$$
And,
$$ dv = \sin x + x \cos x - n \sin x = (1-n) \sin x + x \cos x$$
Now the problem is I can't figure out $u$ / make the numerator of the form $ vdu - u dv$... what do I do next?

$$I=\int \frac{x^2+n(n-1)}{(x\sin x+n \cos x)^2} dx$$
Multiply up and down by $x^{2n-2} \cos x$, then
$$I=\int \frac{(x^2+n(n-1))x^{2n-2} \cos x dx}{(x^n \sin x+n x^{n-1} \cos x)^2 \cos x}$$
Let $$(x^n \sin x+n x^{n-1} \cos x)=t \implies x^{n-2} \cos x(x^2+n(n-1)) dx=dt$$
$$\implies I=\int \frac{(x^2+n(n-1))x^{n-2} \cos x }{(x^n \sin x+n x^{n-1} \cos x)^2} x^n \sec x dx$$
Do integration by part taking $x^n \sec x$ as first and remaining as second function, then
$$I=-\frac{x \sec x}{(x\sin x+n \cos x)}+\int \sec^2 x dx$$
$$I=-\frac{x \sec x}{x \sin x+ n \cos x)}+\tan x+C$$
