I sometimes see integrands in textbooks with a square in the denominator, like this one: $$\int\frac{x^2}{\left(x\sin\left(x\right)+\cos\left(x\right)\right)^2} dx$$ Often, these integrands are actually the derivative of a quotient $P(x)/Q(x)$. Since we have the square in the denominator, we already know $Q(x)$. In the example, $Q(x)=x\sin\left(x\right)+\cos\left(x\right)$.
Now we have to find a suitable $P(x)$ such that the integrand's numerator ($x^2$) equals $P'(x)\cdot Q(x)-P(x)\cdot Q'(x)$, since that's the numerator of the derivative of $P(x)/Q(x)$.
This is basically like Ostrogradsky's method for integrating rational functions, but using polynomials not just in one variable $x$, but in many, e.g. $\{x,\sin(x),\cos(x)\}$. The fact that one might have to apply trigonometric identities to cancel terms (e.g. $\sin^2(x)+\cos^2(x)=1$) makes it more complicated.
So we try different forms that $P(x)$ might have and use the method of undetermined coefficients. We might for example try $P(x)=A\sin(x)+Bx$ and find that there are no $A$ and $B$ that will work.
In the example, the correct form is $P(x)=A\sin(x)+Bx\cos(x)$. The coefficients are $A=1$ and $B=-1$, i.e. we find that $P(x)=\sin(x)-x\cos(x)$ and the antiderivative is:
$$\frac{\sin\left(x\right)-x\cos\left(x\right)}{x\sin\left(x\right)+\cos\left(x\right)}+C$$
Now to the actual question: While a computer can easily try hundreds of different forms for $P(x)$ within a short amount of time, doing this manually is painful. Is there any method to narrow down the possible forms of $P(x)$ that one has to try? E.g. can one make reasonable assumptions on:
- the number of terms that $P(x)$ must have,
- what kind of terms must appear,
- or their powers?
Or is there maybe a more "traditional" approach to solving such integrals?
\begin{align} I=\int\frac{x^2dx}{(x\sin x+\cos x)^2}&=\int\frac{x^2dx}{(1+x^2)(\frac{x}{\sqrt{1+x^2}}\sin x+\frac{1}{\sqrt{1+x^2}}\cos x)^2}\\ &=\int\frac{\left(1-\frac{1}{1+x^2}\right)dx}{\cos ^2(x-\arctan x)}\\ &=\int\frac{d(x-\arctan x)}{\cos ^2(x-\arctan x)}\\ &=\tan (x-\arctan x)+C \end{align}