Evaluating the $\int \frac{x+2}{x^2-4x+8}$ - a doubt I have to find the antiderivative of $f(x) = \dfrac{x+2}{x^2-4x+8}$ 
I rewrote it to the form $$ \dfrac{x-2}{x^2 -4x + 8} + \dfrac{1}{\frac{1}{4} (x-2)^2 +1}$$
The next step supposedly is $$F(x) = \dfrac{1}{2}\ln|x^2-4x+8| + 2 \arctan\left(\dfrac{1}{2}(x-2)\right) + c$$
But now there is a problem which I've always had: I don't know why the $\dfrac{1}{2}$ in front of the $\ln(x)$ is there, same for the $2$ and the $\dfrac{1}{2}$ for the $\arctan(x)$. For me simplifying the function to standard integrals is easy, however finding the right factors and such is hard. 

When we use substitution, we need to determine $u$ as a function of $x$, and so, as a sort of "reverse" chain rule, we need also two substitute $du$ as a function of $dx$:
$$\int \dfrac{x-2}{x^2 -4x + 8}\,dx$$
Here, $u = x^2 - 4x + 8 \implies \,du = 2x - 4 = 2(x-2)\,dx \iff \frac 12 du = x - 2 \,dx$
This gives our substituted integrand: 
$$\begin{align} \int \dfrac{x-2}{x^2 -4x + 8}\,dx & = \int \frac{\frac 12 \,du}{u} \\ \\ & = \frac 12 \int \frac {du}{u} \\ \\ & = \frac 12 \ln|u| + C =\frac 12 \ln|x^2 - 4x + 8| + C\tag{1}\end{align}$$

For the second term:
$$\int\dfrac{1}{\frac{1}{4} (x-2)^2 +1}\,dx = \int \dfrac{1}{\left(\frac 12(x-2)\right)^2 + 1} \,dx$$
We let $$u = \frac 12(x - 2) \implies du = \frac 12 dx \implies 2 du = dx$$
Substituting we have $$\begin{align} \int\dfrac{1}{\left(\frac 12(x-2)\right)^2 + 1} \,dx & = \int \frac 1{u^2 + 1}\cdot(2\,du)  \\ \\ & = 2 \int \cdot \dfrac{1}{u^2 + 1} \,du \\ \\& = 2\arctan\left(u\right) + C \\ \\ & = 2 \arctan\left(\frac 12(x - 2)\right) + C \tag{2} \end{align}$$

Putting $(1)$ and $(2)$ together:
$$F(x) = \dfrac{1}{2}\ln|x^2-4x+8| + 2 \arctan\left(\dfrac{1}{2}(x-2)\right) + c$$
