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?

Instead of looking for a function $u$ such that the integrand is the derivative of the quotient of two functions, I will present a different approach.
\begin{align*}
\int \frac{x^2 +n(n-1)}{(x \sin x + n\cos x)^2} \; \mathrm{d}x &= \int \frac{x^2 +n(n-1)}{\left(\sqrt{x^2+n^2} \cos \left(x-\arctan{\left(\frac{x}{n}\right)}\right)\right)^2} \; \mathrm{d}x \tag{1}\\
&=\underbrace{\int \frac{x^2 +n(n-1)}{\left(x^2+n^2\right) \cos^2 \left(x-\arctan{\left(\frac{x}{n}\right)}\right)} \; \mathrm{d}x}_{t=x-\arctan{\left(\frac{x}{n}\right)}}\\
&= \int \frac{x^2 +n(n-1)}{\left(x^2+n^2\right) \cos^2 \left(t\right)} \; \left(\frac{x^2+n^2}{x^2+n(n-1)}\; \mathrm{d}t\right) \\
&= \int \sec^2{t} \; \mathrm{d}t \\
&= \tan{t}+C \\
&= \tan{\left(x-\arctan{\left(\frac{x}{n}\right)}\right)}+\mathrm{C} \\
&= \frac{n \sin{x}-x\cos{x}}{n\cos{x}+x\sin{x}}+\mathrm{C} \\
\end{align*}

$(1)$: $\mathrm{A}\sin{x}+\mathrm{B}\cos{x}=\sqrt{\mathrm{A}^2+\mathrm{B}^2}\cos{\left(x-\arctan{\left(\frac{\mathrm{A}}{\mathrm{B}}\right)}\right)}$
