Evaluate $\int \frac{e^{2x}-1}{e^{2x}+1}dx$ using partial fractions 
Integrate the function $\frac{e^{2x}-1}{e^{2x}+1}$ using partial fractions.

My Attempt
$$
\int\frac{e^{2x}-1}{e^{2x}+1}dx=\frac{1}{2}\int\frac{2.e^{2x}}{e^{2x}+1}dx-\int\frac{dx}{e^{2x}+1}=\frac{1}{2}\log|e^{2x}+1|-\int\frac{dx}{e^{2x}+1}
$$
Put $t=e^x\implies dt=e^xdx=tdx\implies dx=\frac{dt}{t}$
$$
\int\frac{dx}{e^{2x}+1}=\int\frac{dt}{t(t^2+1)}
$$
Using partial fractions,
\begin{equation}
\frac{1}{t(t^2+1)}=\frac{A}{t}+\frac{Bt+C}{t^2+1}\implies 1=A(t^2+1)+t(Bt+C)
\end{equation}
$$
\begin{multline}
\begin{aligned}
&t=0\implies \boxed{A=1}\\
&1=t^2+1+t(Bt+C)\implies -t^2=t(Bt+C)\\
&\implies-t=Bt+C\text{ if } t\neq 0\\
&t=0\implies \boxed{C=0}\implies \boxed{B=-1}
\end{aligned}
\end{multline}
$$
$$
\begin{multline}
\begin{aligned}
\int\frac{dt}{t(t^2+1)}&=\int\frac{dt}{t}-\frac{1}{2}\int\frac{2t.dt}{t^2+1}=\log|t|-\frac{1}{2}\log|t^2+1|\\
&=\log|e^x|-\frac{1}{2}\log|e^{2x}+1|+C_1
\end{aligned}
\end{multline}
$$
$$
\int\frac{e^{2x}-1}{e^{2x}+1}dx=\frac{1}{2}\log|e^{2x}+1|-\log|e^x|+\frac{1}{2}\log|e^{2x}+1|+C=\log|e^x+e^{-x}|+C
$$
Doubt
While doing partial fractions, first i have assumed $t=0$ but $t=e^x\neq{0}$ and even if I accept that, in the second step the equation is transformed into a new form assuming $t\neq{0}$. But, in the next step I need to again assume $t=0$ to get $B$ and $C$. How can I jusify this and why am I getting the right answer after all ?
 A: What you're really doing is requiring two expressions to have the same $t\to 0^+$ (i.e. $x\to -\infty$) limiting behaviour, which is legitimate.
A: $$\int \frac{e^{2x}-1}{e^{2x}+1}dx=\ln \left|e^{2x}+1\right|-x+k,\quad k\in \mathbb{R}$$
In fact
$$\int \frac{e^{2x}-1}{e^{2x}+1}dx=\int \left[\frac{2e^{2x}}{e^{2x}+1}-1\right]dx=*$$
being
$$\frac{e^{2x}-1}{e^{2x}+1}=\frac{e^{2x}-1+\left(e^{2x}+1\right)}{e^{2x}+1}-1=\frac{2e^{2x}}{e^{2x}+1}-1$$
After we have:
$$*=\int \left[\frac{2e^{2x}}{e^{2x}+1}-1\right]dx=**$$
Using integration for substitution $t=e^{2x}+1$ (with $\int f'/g dx=\ln |g|+\mathrm{const.}$) we have:
$$**=\ln \left|e^{2x}+1\right|-x+k,\quad k\in \mathbb{R}$$
A: $$\begin{equation}
\frac{1}{t(t^2+1)}=\frac{A}{t}+\frac{Bt+C}{t^2+1}\implies 1=A(t^2+1)+t(Bt+C)
\end{equation}$$
This is for all t you get that
$$1=t^2(A+B)+Ct+A \quad \color{red}{\forall t}$$
$$A+B=0, A=1, C=0$$
$$(A,B,C)=(1,-1,0)$$
Note that you just integrate $\tanh(x)$
$$\int \frac{e^{2x}-1}{e^{2x}+1} dx= \int \tanh(x)dx= \ln|\cosh(x)|+K$$
