Integral of $$$\frac{x + 4}{x^{2} + 4 x + 4}$$$
Related calculator: Definite and Improper Integral Calculator
Your Input
Find $$$\int \frac{x + 4}{x^{2} + 4 x + 4}\, dx$$$.
Solution
Rewrite the linear term as $$$x + 4=x\color{red}{+2-2}+4=x+2+2$$$ and split the expression:
$${\color{red}{\int{\frac{x + 4}{x^{2} + 4 x + 4} d x}}} = {\color{red}{\int{\left(\frac{x + 2}{x^{2} + 4 x + 4} + \frac{2}{x^{2} + 4 x + 4}\right)d x}}}$$
Integrate term by term:
$${\color{red}{\int{\left(\frac{x + 2}{x^{2} + 4 x + 4} + \frac{2}{x^{2} + 4 x + 4}\right)d x}}} = {\color{red}{\left(\int{\frac{x + 2}{x^{2} + 4 x + 4} d x} + \int{\frac{2}{x^{2} + 4 x + 4} d x}\right)}}$$
Let $$$u=x^{2} + 4 x + 4$$$.
Then $$$du=\left(x^{2} + 4 x + 4\right)^{\prime }dx = \left(2 x + 4\right) dx$$$ (steps can be seen »), and we have that $$$\left(2 x + 4\right) dx = du$$$.
The integral can be rewritten as
$$\int{\frac{2}{x^{2} + 4 x + 4} d x} + {\color{red}{\int{\frac{x + 2}{x^{2} + 4 x + 4} d x}}} = \int{\frac{2}{x^{2} + 4 x + 4} d x} + {\color{red}{\int{\frac{1}{2 u} d u}}}$$
Apply the constant multiple rule $$$\int c f{\left(u \right)}\, du = c \int f{\left(u \right)}\, du$$$ with $$$c=\frac{1}{2}$$$ and $$$f{\left(u \right)} = \frac{1}{u}$$$:
$$\int{\frac{2}{x^{2} + 4 x + 4} d x} + {\color{red}{\int{\frac{1}{2 u} d u}}} = \int{\frac{2}{x^{2} + 4 x + 4} d x} + {\color{red}{\left(\frac{\int{\frac{1}{u} d u}}{2}\right)}}$$
The integral of $$$\frac{1}{u}$$$ is $$$\int{\frac{1}{u} d u} = \ln{\left(\left|{u}\right| \right)}$$$:
$$\int{\frac{2}{x^{2} + 4 x + 4} d x} + \frac{{\color{red}{\int{\frac{1}{u} d u}}}}{2} = \int{\frac{2}{x^{2} + 4 x + 4} d x} + \frac{{\color{red}{\ln{\left(\left|{u}\right| \right)}}}}{2}$$
Recall that $$$u=x^{2} + 4 x + 4$$$:
$$\frac{\ln{\left(\left|{{\color{red}{u}}}\right| \right)}}{2} + \int{\frac{2}{x^{2} + 4 x + 4} d x} = \frac{\ln{\left(\left|{{\color{red}{\left(x^{2} + 4 x + 4\right)}}}\right| \right)}}{2} + \int{\frac{2}{x^{2} + 4 x + 4} d x}$$
Apply the constant multiple rule $$$\int c f{\left(x \right)}\, dx = c \int f{\left(x \right)}\, dx$$$ with $$$c=2$$$ and $$$f{\left(x \right)} = \frac{1}{x^{2} + 4 x + 4}$$$:
$$\frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + {\color{red}{\int{\frac{2}{x^{2} + 4 x + 4} d x}}} = \frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + {\color{red}{\left(2 \int{\frac{1}{x^{2} + 4 x + 4} d x}\right)}}$$
Complete the square (steps can be seen »): $$$x^{2} + 4 x + 4 = \left(x + 2\right)^{2}$$$:
$$\frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + 2 {\color{red}{\int{\frac{1}{x^{2} + 4 x + 4} d x}}} = \frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + 2 {\color{red}{\int{\frac{1}{\left(x + 2\right)^{2}} d x}}}$$
Let $$$u=x + 2$$$.
Then $$$du=\left(x + 2\right)^{\prime }dx = 1 dx$$$ (steps can be seen »), and we have that $$$dx = du$$$.
The integral becomes
$$\frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + 2 {\color{red}{\int{\frac{1}{\left(x + 2\right)^{2}} d x}}} = \frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + 2 {\color{red}{\int{\frac{1}{u^{2}} d u}}}$$
Apply the power rule $$$\int u^{n}\, du = \frac{u^{n + 1}}{n + 1}$$$ $$$\left(n \neq -1 \right)$$$ with $$$n=-2$$$:
$$\frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + 2 {\color{red}{\int{\frac{1}{u^{2}} d u}}}=\frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + 2 {\color{red}{\int{u^{-2} d u}}}=\frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + 2 {\color{red}{\frac{u^{-2 + 1}}{-2 + 1}}}=\frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + 2 {\color{red}{\left(- u^{-1}\right)}}=\frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} + 2 {\color{red}{\left(- \frac{1}{u}\right)}}$$
Recall that $$$u=x + 2$$$:
$$\frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} - 2 {\color{red}{u}}^{-1} = \frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} - 2 {\color{red}{\left(x + 2\right)}}^{-1}$$
Therefore,
$$\int{\frac{x + 4}{x^{2} + 4 x + 4} d x} = \frac{\ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)}}{2} - \frac{2}{x + 2}$$
Simplify:
$$\int{\frac{x + 4}{x^{2} + 4 x + 4} d x} = \frac{\left(x + 2\right) \ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)} - 4}{2 \left(x + 2\right)}$$
Add the constant of integration:
$$\int{\frac{x + 4}{x^{2} + 4 x + 4} d x} = \frac{\left(x + 2\right) \ln{\left(\left|{x^{2} + 4 x + 4}\right| \right)} - 4}{2 \left(x + 2\right)}+C$$
Answer
$$$\int \frac{x + 4}{x^{2} + 4 x + 4}\, dx = \frac{\left(x + 2\right) \ln\left(\left|{x^{2} + 4 x + 4}\right|\right) - 4}{2 \left(x + 2\right)} + C$$$A