TITLE: Alternative way to do this indefinite integral?
QUESTION [15 upvotes]: Problem : 
Solve $\displaystyle \int \frac{e^{3x}+1}{e^x+1}dx$.
Attempt :
Since we have 
\begin{align}
\int\frac{e^{3x}+1}{e^{x}+1}dx & =\int\frac{e^{3x}}{e^{x}+1}dx+\int\frac{1}{e^{x}+1}dx
\end{align}
and let $u=e^{x}+1$, then $e^{x}=u-1$ and $du=e^{x}dx$ 
\begin{align}
\int\frac{e^{3x}}{e^{x}+1}dx & =\int\frac{e^{2x}}{e^{x}+1}e^{x}dx\\
 & =\int\frac{\left(u-1\right)^{2}}{u}du\\
 & =\int u-2+\frac{1}{u}du\\
 & =\frac{1}{2}u^{2}-2u+\ln\left(u\right)\\
 & =\frac{1}{2}\left(e^{x}+1\right)^{2}-2\left(e^{x}+1\right)+\ln\left(e^{x}+1\right)+C_{1}
\end{align}
On the other hand, for the other part of the integral, let $v=e^{x}$,
then $dv=e^{x}dx$ and we have 
\begin{align}
\int\frac{1}{e^{x}+1}dx & =\int\frac{1}{e^{x}\left(e^{x}+1\right)}e^{x}dx\\
 & =\int\frac{1}{v\left(v+1\right)}dv\\
 & =\int\frac{1}{v}dv-\int\frac{1}{v+1}dv\\
 & =\ln\left(v\right)-\ln\left(v+1\right)\\
 & =x-\ln\left(e^{x}+1\right)+C_{2}
\end{align}
Hence we have 
\begin{align}
\int\frac{e^{3x}}{e^{x}+1}dx & =\frac{1}{2}\left(e^{x}+1\right)^{2}-2\left(e^{x}+1\right)+\ln\left(e^{x}+1\right)+C_{1}+x-\ln\left(e^{x}+1\right)+C_{2}\\
 & =\frac{1}{2}e^{x}-e^{x}+x+C
\end{align}
Question
I think I have solved it correctly but I am wondering if this method is too complicated computationally. I am looking for a better way to attack this integral.

REPLY [41 votes]: Hint: you can use the formula for sum of 2 cubes, since $e^{3x}=(e^x)^3$
$$e^{3x}+1=(e^{2x}-e^x+1)(e^x+1)$$
so you can cancel the denominator and have an easy integral left over.