I was solving a differential equation by reduction of order, and was required to evaluate the indefinite integral
$$I=\int \frac{xe^x}{(x+1)^2}dx.$$
The only method that came to mind was inspection, i.e. recognizing that
$$ \frac{d}{dx} \frac{e^x}{x+1} = \frac{xe^x}{(x+1)^2}.$$
I would not trust myself to recognize this under the pressure of a test or exam, so is it possible to evaluate $I$ by substitution, parts, or some other method?
A nice trick is to write $\frac{x}{(1+x)^2}$ as $\frac{(x+1)-1}{(x+1)^2}=\frac{1}{(x+1)}-\frac{1}{(x+1)^2}$, then apply integration by parts:
$$ \int \frac{e^x}{(1+x)^2}\,dx = -\frac{e^x}{1+x}+\int \frac{e^x}{(1+x)}\,dx.$$