# Substitution theorem for integrals, a "trick"

In Spivak's calculus, he shows the following example: $\displaystyle \int \dfrac{1+e^x}{1-e^x} dx$ and states that setting $u=e^x$and $du=e^x dx$ would work, even though $e^x$ is not there....yet.

He makes $\displaystyle \int \dfrac{1+e^x}{1-e^x}\cdot \dfrac{e^x}{e^x} dx$ and he's considering $f(u)=\dfrac{1+u}{1-u} \cdot \dfrac{1}{u}$, which is easy to integrate.

He then states that it is not the best way to proceed. I agree, since if I replace $e^x$ in the example by, I don't know, $\log^2(x^2)$, its derivative is $4x \log(x^2)$, and dividing and multiplying by it does affect the denominator and changes the original function.

So he states that by "writing": $e^x=u$, then $x=\log u$ and then $dx=\dfrac {1}{u} du$, we obtain the same than before, and that this always works because: if we have $\displaystyle \int f(g(x)) dx$, when we make $u=g(x)$, $x=g^{-1}(u)$ and $dx=(g^{-1})'(u)$, we get $\displaystyle \int f(u)(g^{-1})'(u) du$(all this is the artificial mode, with no grounds for me), whereas doing the direct substitution(this is the method that has sense for me) $u=g(x)$, $du=g'(x) dx$ to the same integral, we get $\displaystyle \int f(g(x)) dx=\displaystyle \int f(g(x))\cdot g'(x)\cdot \dfrac{1}{g'(x)} dx=\displaystyle \int f(u)\cdot \dfrac{1}{g'(g^{-1}(u))} du$, which is the same than the other because of the inverse function theorem.

So I should now "Believe" the artificial method....but I don't, since in the last equality, he is not considering that dividing by $g'(x)$ "changes" $f(x)$, so its derivative may not be $g'(x)$ and so can't apply substitution theorem. What am I misunderstanding?

$$\displaystyle I=\int \dfrac{1+e^x}{1-e^x} dx=\int \dfrac{1-e^x+2e^x}{1-e^x} dx$$
$$I=\displaystyle \int \dfrac{1-e^x}{1-e^x} dx+2\int \dfrac{e^x}{1-e^x} dx$$
$$I=\int 1 dx-2\int \dfrac{-e^x}{1-e^x}dx=x-2\ln (1-e^x)+c$$