<s>[INST] Solving integral $\int \frac{\sqrt{x^2 + x}}{x}dx$ (problem 36 in section $6.25$ in Tom Apostol's calculus) Integrals which involve $\sqrt{(cx + d)^2 - a^2}$ could often be simplified if we do a substitution $cx + d = a \sec t$. If we take a concrete example, $\int \frac{\sqrt{x^2 + x}}{x}dx$, then the substitution would be
$$
x + \frac{1}{2} = \frac{1}{2}\sec t \\
dx = \frac{1}{2} \sec t \tan t dt \\
t = arcsec (2x+1)
$$
If I carry on that substitution, I get to
$$
\frac{1}{2} \int \frac{\sqrt{\tan ^ 2t}}{\sec t - 1} \sec t \tan t dt
$$
As far as I understand, that is
$$
\frac{1}{2} \int \frac{|\tan t|}{\sec t - 1} \sec t \tan t dt
$$
Now, there are two cases, $\tan t \ge 0$ and $\tan t < 0$.
$\tan t \ge 0$ case leads me to the solution also written in the book (and here):
$$
\frac{1}{2} \int \frac{1 + \cos t}{\cos ^ 2 t} dt = \\
\frac{1}{2} \tan t + \frac{1}{2} \log{\frac{1 + \tan \frac{t}{2}}{1 - \tan \frac{t}{2}}} + C = \\
\sqrt{x^2 + x} - \frac{1}{2}\log{|2\sqrt{x^2 + x} + 2x + 1|} + C
$$
But if I try the second case (i.e. $\tan t < 0$), I get to the negation of the previous case, so I wonder where did I go wrong? Should I maybe not even consider the negative case?
Thanks!
 [/INST] You may avoid worrying about square-roots or absolute signs by integrating as follows
\begin{align}
\int \frac{\sqrt{x^2 + x}}{x}dx
=& \int \frac{x+\frac12}{\sqrt{x^2 + x}}\>dx+ 
\int \frac{\frac12}{\sqrt{x^2 + x}}dx\\
=&\>\sqrt{x^2+x}+\frac12\tanh^{-1}\frac{\sqrt{x^2+x}}{x+\frac12}+C
\end{align}
which is valid for all domain $x$.
</s>