<s>[INST] 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. 
 [/INST] $$ \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$$
</s>