Integral of $(x^2 + 4 x + 2)/(x^2 + 2 x)$ with respect to x As the integral of $f(x)=\frac{x^2 + 4 x + 2}{x^2 + 2 x}$ with respect to $x \in {\rm I\!R}$, both my solution sheet as well as Mathematica provide $x+ln(x)+ln(2+x)$ as the solution. 
However, using integration via substitution, I ended at $x+ln[x(2+x)]$ and felt afraid to disentangle the logarithm. $f(x)$ is defined over the negative realm of ${\rm I\!R}$, too. Hence, using the solution from by sheet and Mathematica, I could not calculate area under the curve for $x<0$. For $x \in [-2,0]$, I am still screwed, but ... it is something?
Presumably, this is a fatuous question about "what is the solution to an integral", as I picked this randomly from the internet just for fun, having no profound mathematical knowledge whatsoever and in terms of being the antiderivative, both functions "$+~C$" seem to do the job. But how does one tackle this kind of problem?
 A: $$
\int\frac{x^2+4x+2}{x^2+2x}\,dx=
\int\frac{x^2+2x+2x+2}{x^2+2x}\,dx=
\int\left(\frac{x^2+2x}{x^2+2x}+\frac{2x+2}{x^2+2x}\right)\,dx=\\
\int\left(1+\frac{2x+2}{x^2+2x}\right)\,dx.
$$
Use the substitution $u=x^2+2x$ and remember that $\int\frac{1}{x}\,dx=\ln{|x|}+C$ (take a look at this Khan Academy video if you want to know why we should be using the absolute value sign):
$$
\int\,dx+\int\frac{1}{x^2+2x}\frac{d}{dx}(x^2+2x)\,dx=
x+\int\frac{1}{u}\,du=\\
x+\ln{|u|}+C=
x+\ln{|x^2+2x|}+C=\\
x+\ln{|x(x+2)|}+C=
x+\ln{(|x|\cdot|x+2|)}+C=\\
x+\ln{|x|}+\ln{|x+2|}+C.
$$
So, there should be absolute value bars inside the logarithms.
A: The function $f(x) = \frac {x^2 + 4x + 2} {x^2 + 2x}$ is defined on $\mathbb R \smallsetminus \{ -2, 0 \}$.
The function
$$F(x) = x + \ln x + \ln (x + 2) + c \tag 1$$
is indeed an antiderivative of $f$, but it is only defined on an interval $I$ contained in $(0, \infty)$, because you must have $x > 0$ in order for $\ln x$ to be defined. Therefore this expression doesn't represent all the possible antiderivatives of $F$.
On the other hand, the function
$$F(x) = x + \ln {\lvert x \rvert} + \ln \lvert {x + 2} \rvert + c \tag {2a}$$
is defined precisely on $\mathbb R \smallsetminus \{ -2, 0 \}$. By the logarithmic property, this is exactly the same as
$$F(x) = x + \ln {\lvert x(x + 2) \rvert} + c \tag {2b}$$
but it's not the same as
$$F(x) = x + \ln {x (x + 2)} + c \tag 3$$
because this expression is defined only if $x < -2 \lor x > 0$.
Therefore, in order to compute the definite integral $\int_a^b f(x) \, dx$, you can use the expression $(1)$ if $[a, b] \subseteq (0, \infty)$ and you can use the expression $(3)$ if $[a, b] \subseteq (-\infty, -2 ) \cup (0, \infty)$, but the expressions $(2a)$ and $(2b)$ work more generally for any $I \subseteq \mathbb R \smallsetminus \{ -2, 0 \}$.
