$$\int \frac{(x+7)dx}{x^2+2x+5}$$
completing the square we get:
$$(x^2+2x+1)+5-1$$ $$(x+1)^2+4$$ then: $$U = x + 1$$ $$a = 2$$ hence:
$$\int \frac{(U+6)dU}{U^2+a^2}$$
using trig substitution $U = a\tan\theta$ and $dU = a\sec^2\theta d\theta$:
$$\int a\tan\theta d\theta + 6\int d\theta$$ $$a\ln(\sec\theta) + 6\theta$$ $$a\ln\left(\frac{\sqrt{a^2+U^2}}{a}\right) + 6\tan^{-1}\left(\frac{U}{a}\right)$$ $$2\ln\left(\frac{\sqrt{x^2+2x+5}}{2}\right)+ 6\tan^{-1}\left(\frac{x+1}{2}\right) $$
what did I get wrong?
book answer:
$$\frac{1}{2}\ln(x^2+2x+5)+ 3\tan^{-1}\left(\frac{x+1}{2}\right)$$
The mistake is here
$$\int \frac{(U+6)dU}{U^2+a^2}=\color{red}{\int a\tan\theta d\theta + 6\int d\theta}$$
we should have
$$\int \frac{(U+6)dU}{U^2+a^2}=\int \tan\theta d\theta + \frac 6a\int d\theta$$
since
$$\frac{dU}{U^2+a^2}=\frac{\frac a{\cos^2 \theta}d\theta}{\frac {a^2}{\cos^2 \theta}}=\frac1ad\theta$$
We obtain indeed
$$\ln\left(\frac{\sqrt{x^2+2x+5}}{2}\right)+ 3\tan^{-1}\left(\frac{x+1}{2}\right)$$
with
$$\ln\left(\frac{\sqrt{x^2+2x+5}}{2}\right)=\frac12\ln\left(\frac{x^2+2x+5}{4}\right)=\frac12\ln\left(x^2+2x+5\right)+C$$