# How do you integrate  (sqrt (x +1) / x) dx?

The function $f \left(x\right) = \frac{\sqrt{x + 1}}{x}$ is not easy to integrate, as it's not continuous (so one has to be very careful with some troubles that might occur).

First of all, let's study it quickly: the domain is $D = \left[- 1 , 0\right) \cup \left(0 , + \infty\right)$. Just to know what to expect, we can observe that the asymptotic behavior at $x = 0$ is $f \left(x\right) \approx \frac{1}{x}$. This means that the primitive function will be discontinuous at $x = 0$ too. The graph of $f$ is the following
graph{sqrt(x+1)/x [-1.1, 3, -4, 4]}

To get rid of the square root, let's try with the following substitution:
$u \left(x\right) = \sqrt{1 + x}$
We can invert this function if we restrict to $u \ge 0$:
${u}^{2} = 1 + x \Rightarrow x \left(u\right) = {u}^{2} - 1$
And we can express the differential $\mathrm{dx}$ in terms of $\mathrm{du}$:
$\mathrm{dx} = x ' \left(u\right) \mathrm{du} = 2 u \mathrm{du}$

Now we can integrate:
$\int \frac{\sqrt{1 + x}}{x} \mathrm{dx} = \int \frac{u}{{u}^{2} - 1} 2 u \mathrm{du} = 2 \int \frac{{u}^{2}}{{u}^{2} - 1} \mathrm{du}$
Notice that the discontinuity is now at $u = 1$.

Since the integrand is a rational function whose numerator and denominator have equal degree, we try to split it in the following way:
$\frac{{u}^{2}}{{u}^{2} - 1} = \frac{{u}^{2} - 1 + 1}{{u}^{2} - 1} = \frac{{u}^{2} - 1}{{u}^{2} - 1} + \frac{1}{{u}^{2} - 1} = 1 + \frac{1}{{u}^{2} - 1}$
and by linearity of the integral we get
$2 \int \frac{{u}^{2}}{{u}^{2} - 1} \mathrm{du} = 2 \left[\int \mathrm{du} + \int \frac{1}{{u}^{2} - 1} \mathrm{du}\right] = 2 u + \int \frac{2}{{u}^{2} - 1} \mathrm{du}$

Now we can observe that ${u}^{2} - 1$ factorizes as follows:
${u}^{2} - 1 = \left(u - 1\right) \left(u + 1\right)$
so we can write $\frac{2}{{u}^{2} - 1}$ as the following sum
$\frac{2}{\left(u - 1\right) \left(u + 1\right)} = \frac{1}{u - 1} - \frac{1}{u + 1}$
So we get (by linearity of the integral)
$2 \int \frac{1}{{u}^{2} - 1} \mathrm{du} = \int \frac{1}{u - 1} \mathrm{du} - \int \frac{1}{u + 1} \mathrm{du} = \ln | u - 1 | - \ln | u + 1 | = \ln | u - 1 \frac{|}{|} u + 1 | = \ln | \frac{u - 1}{u + 1} | + C$

In the end
$\int \frac{\sqrt{1 + x}}{x} \mathrm{dx} = 2 u + \ln | \frac{u - 1}{u + 1} | + C = 2 \sqrt{1 + x} + \ln | \frac{\sqrt{1 + x} - 1}{\sqrt{1 + x} + 1} | + C$

Notice that this function keeps to be discontinuous at $x = 0$.