It seems there are two ways to find the integral of this function $f(x) = \frac{1}{1+2e^x}$. In both paths I only do operations that I know are true, but for some reason one of them gives me the right answer and the next gives me a wrong answer. This is how I did it:
$u = 1+2e^x$
$u-1=2e^x$
$du = 2e^x dx \implies dx=\frac{du}{2e^x}$
so $$\int \frac{1}{1+2e^x} dx$$
will become $$\int \frac{1}{u(u-1)} du$$
Using partial fractions, I turned this to
$$\int \frac{-1}{u}+\frac{1}{u-1}du$$ This leads to
$-\ln(u)+\int1/(u-1)du$
and this is where i face that crossroad. This approach leads me to the wrong answer:
$\int1/(u-1)du = \ln(u-1)$
gives me a final answer of
$ln(2e^x)-ln(1+2e^x)$ which is not the right answer.
However if I take this approach: (I unpack $u$ and $du$)
$\int1/(u-1)du \implies \int2e^x/2e^xdx \implies \int 1dx \implies x$
I end with this answer
$x-\ln(1+2e^x)$ which is the right answer.
But i can't see a reason that makes my first approach yield the wrong answer. Can someone please tell me why is this happening? Thanks P.S sorry about the bad formatting i'm not that savvy with MathJax
Both answers are kind of right, but a little wrong. Note that $\ln(2e^x)=\ln 2+x$, so the two answers differ by a constant. Thus their derivatives are the same, they are both antiderivatives of $\frac{1}{1+2e^x}$.
Both answers should have an arbitrary constant of integration.