I have to find $\int \frac{dx}{\sqrt{x+1}+1}$. This was my attempt, which is wrong and I cannot find where exactly is the mistake.
First I write $\frac{1}{\sqrt{x+1}+1}=\frac{\sqrt{x+1}-1}{x}=\frac{\sqrt{x+1}}{x}-\frac{1}{x}$, therefore $\int \frac{dx}{\sqrt{x+1}+1}=\int \frac{\sqrt{x+1}}{x}dx-\log\left (x\right )$, so I only have to deal with $\int \frac{\sqrt{x+1}}{x}dx$.
Setting $u=\sqrt{x+1}$, we obtain $du=\frac{1}{2\sqrt{x+1}}dx$, therefore $dx=2udu$ and $x=u^2-1$, so
$\int\frac{\sqrt{x+1}}{x}dx=\int\frac{2u^2}{u^2-1}du=\int \left(2+\frac{2}{u^2-1}\right)du=2\sqrt{x+1}+\int \left(\frac{1}{u-1}-\frac{1}{u+1}\right)du=$
$=2\sqrt{x+1}+\log \left (\sqrt{x+1}-1\right )-\log \left (\sqrt{x+1}+1\right )=2\sqrt{x+1}+\log\left ( \frac{\sqrt{x+1}-1}{\sqrt{x+1}+1} \right )$
But then $\int \frac{dx}{\sqrt{x+1}+1}=2\sqrt{x+1}+\log\left ( \frac{\sqrt{x+1}-1}{\sqrt{x+1}+1} \right )-\log\left (x\right )=2\sqrt{x+1}+\log\left ( \frac{x+2-2\sqrt{x+1}}{x^2} \right )$, which is not what I am supposed to obtain. The actual answer is $2\sqrt{x+1}-2\log\left ( 1+\sqrt{x+1} \right )$.
Where is my mistake?
(I already know a correct way to solve it, I just want to know where I am committing a mistake).
But you have been right all along!
Notice that $$\log\frac{\sqrt{x+1}-1}{\sqrt{x+1}+1} - \log x = \log\frac{\sqrt{x+1}-1}{x(\sqrt{x+1}+1)} = \log \frac{1}{(\sqrt{x+1}+1)^2} = -2\log(\sqrt{x+1}+1)$$ by your very first step.
Also, I would suggest that you use $\int\frac{dx}{x} = \log|x|$ (with the absolute value sign, to extend the domain).
What I would also suggest is to use an online function grapher if you are not sure that your solution is correct. If two functions have identical graphs or if they differ by a constant value, then both are correct solutions of the integral.