Issue solving an integral I'm having issues solving the following integral:
$$ \int{\frac{e^x}{e^{2x}-e^x-2}}dx $$
From what I can tell, I should substitute $u = e^x$ and $du = e^xdx$ and end up with
$$ \int{\frac{1}{u^2 - u - 2}}du $$
where I can then use partial fraction decomposition to simplify the integrand as follows
$$ \frac{1}{u^2 - u - 2} = \frac{A}{u-2} + \frac{B}{u+1} $$
$$ A(u+1) + B(u-2) = 1 $$
$$ Au + A + Bu -2B = 1 $$
$$\begin{pmatrix}1 & 1 & 0\\1 & -2 & 1\end{pmatrix} \to \begin{pmatrix} 1 & 0 & \frac{1}{3} \\ 0 & 1 & -\frac{1}{3} \end{pmatrix} \to A=\frac{1}{3}, B=-\frac{1}{3} $$
So I have
$$ \int{ \left( \frac{ \frac{1}{3} }{u-2} - \frac{ \frac{1}{3} }{u + 1} \right) } du = \frac{1}{3} \int{\frac{1}{u - 2}du} - \frac{1}{3}\int{\frac{1}{u+1}}du $$
which gives me
$$ \frac{1}{3}\ln(u-2) - \frac{1}{3}\ln(u + 1) + C, \textrm{ where } u =e^x $$
so my final answer is
$$ \frac{1}{3}( \ln(e^x-2) - \ln(e^x + 1) ) + C $$
However, wolframalpha is telling me that the answer is
$$ \frac{2}{3}\tanh^{-1}\left(\frac{1}{3} - \frac{2e^x}{3}\right) + C $$
I really have no idea how the inverse tangent hyperbolic function would even get there. We haven't even covered any integrals that give $\tanh^{-1}$ in class.
 A: It turns out that$$\operatorname{arctanh}'(x)=\frac1{1-x^2}.$$But\begin{align}\frac1{u^2-u-2}&=\frac1{\left(u-\frac12\right)^2-\frac94}\\&=-\frac49\frac1{1-\left(\frac13-\frac{2u}3\right)^2},\end{align}and therefore\begin{align}\left(\frac23\operatorname{arctanh}\left(\frac13-\frac{2u}3\right)\right)'&=-\frac49\frac1{1-\left(\frac13-\frac{2u}3\right)^2}\\&=\frac1{u^2-u-2}.\end{align}
A: Answer in the Question
Your answer
$$
\frac13\log\left(\frac{e^x-2}{e^x+1}\right)+C\tag1
$$
is partially correct; another possibility is
$$
\frac13\log\left(\frac{2-e^x}{1+e^x}\right)+C\tag2
$$
Which one is applicable depends on the initial value of $x$. If $x\gt\log(2)$, use $(1)$; if $x\lt\log(2)$, use $(2)$.

WolframAlpha's Answer
Since
$$\newcommand{\arctanh}{\operatorname{arctanh}}
\arctanh(u)=\frac12\log\left(\frac{1+u}{1-u}\right)\tag3
$$
we have that
$$
\begin{align}
\frac23\arctanh\left(\frac3{1-2e^x}\right)
&=\frac23\cdot\frac12\log\left(\frac{1+\frac3{1-2e^x}}{1-\frac3{1-2e^x}}\right)\\
&=\frac13\log\left(\frac{e^x-2}{e^x+1}\right)\tag4
\end{align}
$$
and
$$
\begin{align}
\frac23\arctanh\left(\frac{1-2e^x}3\right)
&=\frac23\cdot\frac12\log\left(\frac{1+\frac{1-2e^x}3}{1-\frac{1-2e^x}3}\right)\\
&=\frac13\log\left(\frac{2-e^x}{1+e^x}\right)\tag5
\end{align}
$$
However, the answer WA gave you was for $x\lt\log(2)$, whereas the answer in your question is for $x\gt\log(2)$.
