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.
 A: Hint. You can calculate the integral of any rational function of $e^x$ by making the substitution $u = e^x$.
A: \begin{align}
u & = e^x \\
du & = e^x\,dx = u\,dx \\
du/u & = dx
\end{align}
$$
\int \frac{dx}{e^{2x}+e^x+1} = \int\frac{du/u}{u^2+u+1}
$$
\begin{align}
u^2+u+1 & = \left(u^2 + u + \frac14\right) + \frac34\quad \text{(completing the square)} \\[10pt]
& = \left(u+\frac12\right)^2+\frac34 \\[10pt]
& = \frac34\left(\frac43\left(u+\frac12\right)^2 + 1\right) \\[10pt]
& = \frac32\left(w^2+1\right) \text{ where } w = \frac{2}{\sqrt{3}}\left(u+\frac12\right) = \frac{1}{\sqrt{3}} (2u+1) \\[10pt]
& {}\qquad\qquad\qquad\text{ and }u = \frac{\sqrt{3}\ w - 1}{2}.
\end{align}
So the integral is
$$
\int\frac{2\,dw}{(\sqrt{3}\ w-1)(w^2+1)} = \int \left(\frac{A\,dw}{\sqrt{3}\ w+1} + \frac{B\,dw}{w^2+1} \right).
$$
So you get a logarithm and an arctangent.  Of course, you have to do a bit of algebra to figure out what $A$ and $B$ are.
A: 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}$$
A: Substitute $u=e^x,$ then use partial fractions.
A: $\newcommand{\+}{^{\dagger}}%
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
 \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}%
 \newcommand{\dd}{{\rm d}}%
 \newcommand{\down}{\downarrow}%
 \newcommand{\ds}[1]{\displaystyle{#1}}%
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}%
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}%
 \newcommand{\fermi}{\,{\rm f}}%
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}%
 \newcommand{\half}{{1 \over 2}}%
 \newcommand{\ic}{{\rm i}}%
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}%
 \newcommand{\isdiv}{\,\left.\right\vert\,}%
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}%
 \newcommand{\ol}[1]{\overline{#1}}%
 \newcommand{\pars}[1]{\left( #1 \right)}%
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}%
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}%
 \newcommand{\sech}{\,{\rm sech}}%
 \newcommand{\sgn}{\,{\rm sgn}}%
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}%
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
\begin{align}
\color{#00f}{\large\int{\dd x \over \expo{2x} + \expo{x} + 1}}&=
-\int{\overbrace{\expo{-x}}^{\ds{\equiv\ t}}\pars{-\expo{-x}\,\dd x} \over 1 + \expo{-x} + \expo{-2x}}
=-\int{t\,\dd t \over t^{2} + t + 1}
=-\int{t\,\dd t \over \pars{\overbrace{t + 1/2}^{\ds{\equiv\ y}}}^{2} + 3/4}
\\[3mm]&=-\int{y\,\dd y \over y^{2} + 3/4}
+ \half\int{\dd t \over y^{2} + \pars{\root{3}/2}^{2}}
\\[3mm]&=-\,\half\,\ln\pars{y^{2} + {3 \over 4}}
+ {\root{3} \over 3}\,\arctan\pars{{2\root{3} \over 3}\,y}
\\[3mm]&=-\,\half\,\ln\pars{\bracks{t + \half}^{2} + {3 \over 4}}
+ {\root{3} \over 3}\,\arctan\pars{{2\root{3} \over 3}\,\bracks{t + \half}}
\\[3mm]&\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!=\color{#00f}{\large -\,\half\,\ln\pars{\expo{-2x} + \expo{-x} + 1}
+ {\root{3} \over 3}\,\arctan\pars{{2\root{3} \over 3}\,\bracks{\expo{-x} + \half}}}
\\[3mm]&+\ \mbox{a constant}
\end{align}
A: Letting $t=e^{-x}$ yields
$$
\begin{aligned}
\int \frac{d x}{e^{2 x}+e^{x}+1}&=-\int \frac{t d t}{t^{2}+t+1} \\
&=-\frac{1}{2} \int \frac{2 t+1-1}{t^{2} t t+1} d t \\
&=-\frac{1}{2} \int \frac{d\left(t^{2}+t+1\right)}{t^{2}+t+1}+2 \int \frac{d t}{(2 t+1)^{2}+3} \\
&=-\frac{1}{2} \ln \left(t^{2}+t+1\right)+\frac{1}{\sqrt{3}} \tan ^{-1}\left(\frac{2 t+1}{\sqrt{3}}\right)+c \\
&=-\frac{1}{2} \ln \left(e^{-2 x}+e^{-x}+1\right)+\frac{1}{\sqrt{3}} \tan ^{-1}\left(\frac{2 e^{- x}+1}{\sqrt{3}}\right)+C
\end{aligned}
$$
