<s>[INST] Error in solving $\int \sqrt{1 + e^x} dx$ . I want to solve this integral for $1 + e^x \ge 0$
$$\int \sqrt{1 + e^x} dx$$ 
I start by parts $$\int \sqrt{1 + e^x} dx = x\sqrt{1 + e^x} - \int x \frac{e^x}{2\sqrt{1 + e^x}} dx $$
Substitute $\sqrt{1 + e^x} = t \implies dt = \frac{e^x}{2\sqrt{1 + e^x}} dx$
So I remain with $$x\sqrt{1 + e^x} - \int \ln((t-1)(t+1)) dt =  x\sqrt{1 + e^x}  + 2t +(-t+1)\ln(t-1)+ (-t+1)\ln(t+1) $$
that is
$$(x+2)\sqrt{1 + e^x} + (-\sqrt{1 + e^x} + 1) \ln(+\sqrt{1 + e^x} - 1) + (-\sqrt{1 + e^x} + 1) \ln(+\sqrt{1 + e^x} + 1) + C  $$
But the solution should be $$2\sqrt{1 + e^x} + \ln(+\sqrt{1 + e^x} - 1) - \ln(+\sqrt{1 + e^x} + 1) $$
Where is the mistake hidden?
 [/INST] Let $x = \ln t$.  Then $dx = dt/t$ and we have
$$\int \sqrt{1 + e^x} \, dx = \int \frac{\sqrt{1 + t}}t \, dt.$$
Now let $u = t + 1$.  Then $du = dt$ and we have
$$\int \frac{\sqrt{1+t}}t \, dt = \int\frac{\sqrt{u}}{u-1} \, du.$$
Now let $v = \sqrt{u}$.  Then $u = v^2$ and so $du = 2v \, dv$, and we have
$$\int\frac{\sqrt{u}}{u-1} \, du = 2\int\frac{v^2}{v^2 - 1} \, dv.$$
Consider then:
\begin{align*}
  2\int\frac{v^2}{v^2 - 1} \, dv
    &= 2\int\frac{v^2 \color{red}{-1+1}}{v^2 - 1} \, dv \\[0.3cm]
    &= 2\int\frac{v^2-1}{v^2-1} \, dv + 2\int\frac{dv}{v^2-1}\\[0.3cm]
    &= 2v + \ln(v-1) - \ln(v+1) + C
\end{align*}
Back substitute:
$$
  2v + \ln(v-1) - \ln(v+1) + C = 
  2\sqrt{u} + \ln(\sqrt{u}-1) - \ln(\sqrt{u}+1) + C
$$
Back substitute:
$$
  2\sqrt{u} + \ln(\sqrt{u}-1) - \ln(\sqrt{u}+1) + C =
  2\sqrt{t+1} + \ln(\sqrt{t+1}-1) - \ln(\sqrt{t+1}+1) + C
$$
Back substitute $t = e^x$ to finally get:
$$
  \int \sqrt{1+e^x} \, dx =
  2\sqrt{e^x+1} + \ln(\sqrt{e^x+1}-1) - \ln(\sqrt{e^x+1}+1) + C
$$
</s>