Evaluating the integral $\int \frac{x^2+x}{(e^x+x+1)^2}dx$
Solution 1:
One may observe that $$ \begin{align} \left(\frac{x+1}{e^x+x+1}\right)'&=\frac{1 \times(e^x+x+1)-(x+1)(e^x+1)}{(e^x+x+1)^2} \\\\&=\frac{(e^x+x+1)-(x+1)(e^x+x+1)+x(x+1)}{(e^x+x+1)^2} \\\\&=\frac{-x(e^x+x+1)}{(e^x+x+1)^2}+\frac{x^2+x}{(e^x+x+1)^2} \\\\&=\frac{\left((e^x+x+1)'-(e^x+x+1)\right)(e^x+x+1)}{(e^x+x+1)^2}+\frac{x^2+x}{(e^x+x+1)^2} \\\\&=\frac{(e^x+x+1)'}{(e^x+x+1)}-1+\frac{x^2+x}{(e^x+x+1)^2} \end{align} $$ giving
$$ \int \frac{x^2+x}{(e^x+x+1)^2}dx=x-\ln\left|e^x+x+1\right|+\frac{x+1}{e^x+x+1}+C $$
for any constant $C$.
Solution 2:
Let $\displaystyle u=\frac{x^2+x}{xe^x}=(x+1)e^{-x}$ and $\displaystyle dv=\frac{xe^x}{(e^x+x+1)^2}dx,\;$ so $\displaystyle du=-xe^{-x}dx$ and $\displaystyle v=\frac{e^x}{e^x+x+1}$.
Then $\displaystyle\int\frac{x^2+x}{(e^x+x+1)^2}dx=(x+1)e^{-x}\cdot\frac{e^x}{e^x+x+1}-\int-\frac{x}{e^x+x+1}dx=\frac{x+1}{e^x+x+1}+\int\frac{x}{e^x+x+1}dx$
$\displaystyle\hspace{.2 in}=\frac{x+1}{e^x+x+1}+\int\frac{e^x+x+1}{e^x+x+1}dx-\int\frac{e^x+1}{e^x+x+1}dx=\frac{x+1}{e^x+x+1}+x-\ln\big|e^x+x+1\big|+C$