Finding the integral $\int\frac{e^{x}}{e^{2x}+1}$ 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!

One of the best thing you can do with indefinite integrals is take the derivative of your result and check if it is the integrand function:
$$\frac{\text{d}}{\text{d}x} \left[-\arctan \left (\frac{1}{e^x}\right)+c\right]=\frac{\text{d}}{\text{d}x} \left[-\arctan \left (e^{-x}\right)+c\right]=-\frac{1}{1+e^{-2x}}({-e^{-x}})=\frac{e^{-x}}{1+e^{-2x}}=$$
$$=\frac{\frac{1}{e^x}}{1+\frac{1}{e^{2x}}}=\frac{\frac{1}{e^x}}{\frac{e^{2x}+1}{e^{2x}}}=\frac{1}{\frac{e^{2x}+1}{\frac{1}{e^x}}}=\frac{e^{x}}{e^{2x}+1}$$
So your result is absolutely correct, no matter what (except for calculation mistakes).
Of course it is not always this simple, maybe you'll need some identities to have back the integrand function; but this is for sure better than thinking you're wrong without checking.
