<s>[INST] Evaluating the primitive $\int \frac{\mathrm dx}{e^{2x} + e^x + 1} $ Could someone help me evaluate this?
$$\int \frac{\mathrm dx}{e^{2x} + e^x + 1} $$
I tried to solve it for hours with no success.
I tried Wolframalpha but it's giving a step by step solution that is too long that in an exam I won't even have the time to write the solution.
Thanks in advance.
 [/INST] Let $u = e^x$.  Then, $du = e^x\,dx$, or, equivalently, $dx = \frac{1}{u}du$.  Thus, the integral becomes:
$$
\int\frac{dx}{e^{2x}+e^x+1} = \int\frac{du}{(u^2+u+1)u}$$
Now, hit it with partial fractions:
$$\begin{align}
\frac{1}{(u^2+u+1)u} &= \frac{Au+B}{u^2+u+1} + \frac{D}{u}\\
&=\frac{Au^2+Bu+Du^2+Du+D}{(u^2+u+1)u}\\
&=\frac{(A+D)u^2+(B+D)u+D}{(u^2+u+1)u}
\end{align}$$
Thus:
$$A+D = 0\\
B+D = 0\\
D = 1$$
So, the integral is:
$$\int\frac{du}{(u^2+u+1)u} = \underbrace{\int \frac{-u-1}{u^2+u+1} du}_{\text{integral 1}} + \underbrace{\int \frac{1}{u}du}_{\text{integral 2}}$$
Integral $2$ is trivial, so I won't write it out.  For integral $1$, we apply the substitution $w = u^2+u+1$, so $dw = (2u + 1)du$.
$$\begin{align}
\int \frac{-u-1}{u^2+u+1} du &= \frac{-1}{2}\int \frac{2u+1}{u^2+u+1}du + \frac{-1}{2}\int\frac{1}{u^2+u+1}du\\
&= \frac{-1}{2}\int \frac{1}{w}dw - \frac{1}{2} \int \frac{1}{u^2 + u+1}du\\
&= \frac{-1}{2}\ln|w| - \frac{1}{2} \underbrace{\int \frac{1}{u^2 + u+1}}_{\text{integral 3}}
\end{align}$$
For Integral $3$, we use our knowledge of the derivative of arctangent.  We have:
$$\begin{align}
\int \frac{1}{u^2 + u+1}du &= \int \frac{1}{\left(u+\frac{1}{2}\right)^2 + \frac{3}{4}}du\\
&= \int \frac{1}{\left(\frac{u+\frac{1}{2}}{\sqrt{3}/2}\right)^2 + 1}du\\
&= \int \frac{1}{\left(\frac{2u+1}{\sqrt{3}}\right)^2 + 1}du\\
&= \frac{2}{\sqrt{3}}\arctan\left(\frac{2u+1}{\sqrt{3}}\right) +C
\end{align}$$
Thus, our overall answer is:
$$\begin{align}
\int\frac{dx}{e^{2x}+e^x+1} &= I_1 + \ln|e^x| \\
&= \frac{-1}{2}\ln|e^{2x}+e^x+1| - \frac{1}{\sqrt{3}}\arctan\left(\frac{2e^x+1}{\sqrt{3}}\right) + x + C
\end{align}$$
</s>