<s>[INST] Integrate $\int \frac{2x}{x^2 +2x+1}$ Here is my attempt:
$$ \frac{2x}{x^2 +2x+1}= \frac{2x}{(x+1)^2 } = \frac{2}{x+1}-\frac{2}{(x+1)^2 }$$
Then I tried to integrate it,I got $2\ln(x+1)+\frac{2}{x+1}+C$ as my answer. Am I right? please correct me if I'm wrong.
 [/INST] Your answer is almost correct, but you should put modulus sign in your log's argument as it must be positive i.e your answer should be;
$$2\ln|x+1|+\frac{2}{x+1}+C$$
You can try one more method too.
$$\int \frac{2x}{x^2+2x+1}dx$$
Try to create derivative of denominator in numerator
$$\int \frac{2x+2-2}{x^2+2x+1}dx$$
$$\int \frac{2x+2}{x^2+2x+1}dx-2\int \frac{1}{x^2+2x+1}dx$$
$$\int \frac{2x+2}{x^2+2x+1}dx-2\int \frac{1}{(x+1)^2}dx$$
For first integral simply take $x^2+2x+1=t$, then $(2x+2)dx=dt$, hence you will get:
$$\ln(x^2+2x+1)+\frac{2}{x+1}+C$$
$$\ln(x+1)^2+\frac{2}{x+1}+C$$
$$2\ln|x+1|+\frac{2}{x+1}+C$$
</s>