This question has been puzzling me for a bit and I'd like an explanation for what I'm doing wrong as my answer doesn't coincide with the correct one.
Let's say we're asked to find:
$$\int \frac{e^{x}}{e^{2x}+1}\mathrm{d}x$$
The way I chose to solve this was factor out an $e^{2x}$ from the denominator and work my way from there. So what I get is:
$$\int \frac{e^{x}}{e^{2x}(1+1/e^{2x})}dx$$
This could be rewritten as:
$$\int \frac{1}{e^{x}(1+(1/e^{x})^2)}dx$$
If we let:
$$u = \frac{1}{e^x}$$ $$du = -e^{-x} dx$$ $$dx = -e^xdu$$
So, now we're at:
$$\int \frac{1}{e^{x}(1+u^2)}(-e^x)du$$
Cancelling out the $e^x$ and removing the minus sign outside of the integral gives us:
$$-\int \frac{1}{1+u^2}du$$
This leaves us with:
$$-\int \frac{1}{1+u^2}du = -\tan^{-1}(\frac{1}{e^x})+c$$
However, I know the answer is wrong because the correct one is $\tan^{-1}(e^x) + c$. Can someone please tell me where I screwed up? Many thanks in advance!
As Jean-Claude Arbaut said, you didn't screw up. We have the identity $$\tan^{-1}(\frac{1}{y})=\frac{\pi}{2}-\tan^{-1}(y).$$ So it follows that $$ -\tan^{-1}(1/e^x)=\tan^{-1}(e^x)-\pi/2=\tan^{-1}(e^x)+c. $$