# Integral: I vs. CAS

Evaluate $\displaystyle\int\frac{\sqrt{1+p^2}}{p}\;dp$

Let

$u = \sqrt{1+p^2},\quad\quad\quad(1)$

we have

$u^2=1+p^2 \implies p^2=u^2-1 \implies p =\pm\sqrt{u^2-1} \quad\quad\quad(2)$

and

$\frac{dp}{du}= \pm\frac{1}{2}\cdot\frac{2u}{\sqrt{u^2-1}} =\pm \frac{u}{\sqrt{u^2-1}}.\quad\quad\quad(3)$

Consequently,

$\int\frac{\sqrt{1+p^2}}{p}\;dp$

$\overset{(1), (2)}{=} \int \frac{u}{\pm\sqrt{u^2-1}}\cdot\frac{dp}{du}\;du$

$\overset{(3)}{=}\int \frac{u}{\pm\sqrt{u^2-1}}\cdot(\pm\frac{u}{\sqrt{u^2-1}})\;du$

$= \int\frac{u^2}{u^2-1}\;du$

$= \int \frac{u^2-1+1}{u^2-1}\;du$

$= \int du + \int \frac{1}{u^2-1}\;du$

$= u +\int \frac{1}{2}\left(\frac{1}{u-1}-\frac{1}{u+1}\right)\;du$

$= u+\frac{1}{2}\log\frac{u-1}{u+1}$

$= u + \frac{1}{2}\log\frac{(u-1)^2}{u^2-1}$

$= \sqrt{1+p^2} + \frac{1}{2}\log\frac{\sqrt{p^2+1}-1)^2}{p^2+1-1}$

$=\sqrt{1+p^2}+\frac{1}{2}\log\frac{(\sqrt{p^2+1}-1)^2}{p^2}$

$=\sqrt{1+p^2}+\log\frac{\sqrt{|p|^2+1}-1}{|p|}$

$= \sqrt{1+p^2} +\log\frac{(\sqrt{p^2+1}-1)(\sqrt{p^2+1}+1)}{|p|(\sqrt{p^2+1}+1)}$

$= \sqrt{1+p^2} + \log\frac{p^2+1-1}{|p|(\sqrt{p^2+1}+1)}$

$= \sqrt{1+p^2} + \log\frac{p^2}{|p|(\sqrt{1+p^2}+1)}$

$\overset{p^2=|p|^2}{=} \sqrt{1+p^2} + \log\frac{|p|}{\sqrt{p^2+1}+1}$

$= \sqrt{1+p^2} + \log\left(\frac{\sqrt{1+p^2}+1}{|p|}\right)^{-1}$

$= \sqrt{1+p^2} - \log\frac{\sqrt{1+p^2}+1}{|p|}$

$=\sqrt{1+p^2}-\log(\sqrt{\frac{1}{|p|^2} + \frac{p^2}{|p|^2}} +\frac{1}{|p|})$

$\overset{|p|^2=p^2}{=}\sqrt{1+p^2} - \log(\sqrt{(\frac{1}{|p|})^2 + 1} + \frac{1}{|p|})$

From “Deriving Two Inverse Functions“:

$\mathrm{arcsinh}(x) = \log(\sqrt{x^2+1} + x), x\in (-\infty, \infty).$

Therefore,

$\int\frac{\sqrt{1+p^2}}{p}\;dp = \sqrt{1+p^2} - \mathrm{arcsinh}\left(\frac{1}{|p|}\right).\quad\quad\quad(*)$

Had we written $\int\frac{1}{u^2-1}\;du$ as $\int-\frac{1}{2}(\frac{1}{u+1}-\frac{1}{u-1})\;du,$ we would have

$\int du + \int\frac{1}{u^2-1}\;du$

$= u -\frac{1}{2}\int(\frac{1}{u+1}-\frac{1}{u-1})\;du$

$= u-\frac{1}{2}(\log(u+1)-\log(u-1))$

$= u-\frac{1}{2}\log\frac{u+1}{u-1}$

$= u-\frac{1}{2}\log\frac{(u+1)(u+1)}{(u-1)(u+1)}$

$= u-\frac{1}{2}\log\frac{(u+1)^2}{u^2-1}$

$= \sqrt{1+p^2}-\frac{1}{2}\log\frac{(\sqrt{1+p^2} + 1)^2}{1+p^2-1}$

$= \sqrt{1+p^2}-\frac{1}{2}\log\frac{(\sqrt{1+p^2}+1)^2}{p^2}$

$= \sqrt{1+p^2}-\log\frac{\sqrt{1+p^2}+1}{|p|}$

$= \sqrt{1+p^2}-\log(\sqrt{1+(\frac{1}{|p|})^2}+\frac{1}{|p|})$

$= \sqrt{1+p^2}-\mathrm{arcsinh}(\frac{1}{|p|}),$

the same as (*).