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. 
 A: 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$$
A: $$ \dfrac{x+2}{x^2-4x+8}= \dfrac{x-2}{x^2-4x+8}+4\cdot\frac1{(x-2)^2+2^2}$$
Putting $x^2-4x+8=u,2(x-2)dx=du\implies (x-2)dx=\frac{du}2$
So, $$\int \dfrac{x-2}{x^2-4x+8}=\frac12\cdot\int \frac{du}u=\frac12\cdot\ln|u|+C=\frac12\cdot\ln|x^2-4x+8|+C$$
Putting $x-2=2\tan\theta\implies dx=2\sec^2\theta d\theta$ in $\frac1{(x-2)^2+2^2},$
$$\int \frac{dx}{(x-2)^2+2^2}=\int\frac{2\sec^2\theta d\theta}{4\sec^2\theta}=\frac12\cdot\theta+K=\frac12\cdot\arctan\left(\frac{x-2}2\right)+K$$
A: Hint: What happens if you calculate $F'(x)$? Where do the $2$'s come from?
A: $\int$$\frac{1}{\frac{1}{4} (x-2)^2 +1}$=$4$$\int$$\frac{1}{(x-2)^2+4}$=$\frac{4}{2}$$\int$$\frac{2}{(x-2)^2+4}$=$\frac{4}{2}$$\tan^{-1}\frac{x-2}{2}$=...
You can simplify further. I have used the basics for differentiation of inverse trig functions.
