When given $\frac{1}{(x+1)^2}$, I tried to integrate it as so:
Knowing that $\int\frac{1}{u}dx$ such that $u$ is an expression of $x$, then
$$\int \frac{1}{u} \, dx = \ln u \div \frac{du}{dx} + c$$
Applying this same idea,
$$\begin{align} \int \frac{1}{(x+1)^2} \, dx & = \ln((x+1)^2) \div (2x+2) + c \\ & = \frac{2\ln(x+1)}{2x+2} + c\\ & = \frac{\ln(x+1)}{x+1} + c \end{align}$$
But this isn't right, because if I integrate it using the "proper" way,
$$\begin{align} \int \frac{1}{(x+1)^2} \, dx & = -\frac{1}{x+1} + c \end{align}$$
Which is odd. I know the second answer is correct, but why is the first one incorrect?
EDIT How I got the following
$$\int \frac{1}{u} \, dx = \ln u \div \frac{du}{dx} + c$$
is as follows:
$$\begin{align} \frac{d}{dx}(\ln(x)) & = \frac{1}{x} \\ \\ \text{Let }u\text{ be an expression of }x \\ \\ \frac{d}{dx}(\ln(u)) & = \frac{d}{du}(\ln(u)) \cdot \frac{du}{dx} \\ & = \frac{1}{u} \cdot \frac{du}{dx} \end{align}$$ So, conversely,
$$\begin{align} \int \frac{1}{u} \, dx & = \int \frac{1}{u} \, du \div \frac{du}{dx} \\ & = \ln u \div \frac{du}{dx} + c \end{align}$$
The correct rule is $$\int \frac{u'}{u} \, dx = \ln u + c$$ So if you dont have the $u'$ term you multiply and divide by $u'$ So you'll get $$\int \frac{1}{u} \, dx =\frac{u'}{u'} ×\int \frac{1}{u} \, dx$$ And you enter the term $u'$ in the numerator inside the integral if possible and you complete as above to get $$\int \frac{1}{u} \, dx =\frac{1}{u'} .\int \frac{u'}{u} \, dx =\frac{dx}{du}.ln u +c$$
But here it is NOT possible since $u'=2(x+1)$ i.e. $u'$ contains the variable $x$ that cannot be entered inside the integral.
So, your rule is valid when $u'$ does not contain the variable we are integrating about, here $x$.