Evaluate $\int \frac{x^2 + x+3}{x^2+2x+5}\ dx$ How can we evaluate $$\displaystyle\int \frac{x^2 + x+3}{x^2+2x+5} dx$$  
To be honest, I'm embarrassed. I decomposed it and know what the answer should be but
I can't get the right answer. 

$$I=\int \frac{x^2 + x+3}{x^2+2x+5} dx=\int \frac{x(x+1)+3}{(x+1)^2+2^2} dx$$ 
Putting $x+1=2\tan\theta,dx=2\sec^2\theta d\theta,$
$$I= \frac{2\tan\theta(2\tan\theta-1)+3}{4\sec^2\theta d\theta}2\sec^2\theta d\theta$$
$$2\tan\theta(2\tan\theta-1)+3=4\tan^2\theta-2\tan\theta+3=4\sec^2\theta-2\tan\theta-1$$
$$\text{So,} I=\frac12\int(4\sec^2\theta-2\tan\theta-1)d\theta=2\tan\theta-\log|\sec\theta+\tan\theta|-\theta+C $$ where $C$ is an arbitrary constant for indefinite integration.
As $\tan\theta=\frac{x+1}2,$
$\sec^2\theta =1+\left(\frac{x+1}2\right)^2=\frac{x^2+2x+5}4$
$\theta=\arctan \left(\frac{x+1}2\right)$
