# Limits of the use of trigonometric substitution in integration

I'm trying to understand exactly when trigonometric substitution can be used. Here's the whole detailed process and the approach I'm currently taking. I'm mainly curious about whether the trigonometric substitution in step 4 is correct. It appears so to me, but when I use a CAS or graphing system to integrate, its giving me nothing close.

I have this integral:

$\int{\frac{x+4}{x^{2}+2x+5}dx}$

My steps for approaching this are the following:

1. Complete the square:

$\int{\frac{x+4}{\left(x^{2}+2x+1\right)+5-1}dx} = \int{\frac{x+4}{\left(x+1\right)^{2}+4}dx} = \int{\left(x+4\right)\frac{1}{\left(x+1\right)^{2}+4}dx}$

1. Assume a triangle of the following sides:

base = $2$, height = $x+1$, hypotenuse = $\sqrt{\left(x+1\right)^{2}+4}$

1. Use the following for substitutions:

$\cos \left(\theta\right)=\frac{2}{\sqrt{\left( x+1 \right)^{2}+4}}\; so\; \frac{\cos ^{2}\left( \theta \right)}{4}=\frac{1}{\left( x+1 \right)^{2}+4}$

$\tan \left(\theta\right)=\frac{x+1}{2}\; so\; 2\tan\left(\theta\right)-1=x$

...and

$2\sec^{2}\left(\theta\right)d\theta=dx$

1. Substituting to get the following:

$\int{\left( \left( 2\tan \left( \theta \right)-1 \right)+4 \right)\frac{\cos ^{2}\left( \theta \right)}{4}2\sec ^{2}\left(\theta\right) d\theta }$

1. Simplifying, I get:

$\int{\left( \tan \left( \theta \right)+\frac{3}{2} \right)d\theta } = \int{\left( \frac{\sin \left( \theta \right)}{\cos\left( \theta \right)}+\frac{3}{2} \right)d\theta }$

1. Substituting $u=\cos\left(\theta\right)$, and $-du=\sin\left(\theta\right)d\theta$ and integrating, I get...

$-\int{\frac{1}{u}}du+\frac{3}{2}\int{d\theta}$ = $-\ln{\left|u\right|}+\frac{3\theta}{2}+C$

1. Converting back to $\theta$ I get...

$-\ln{\left|\cos\left(\theta\right)\right|}+\frac{3\theta}{2}+C$

1. Converting back to x I get the final result:

$\frac{3\arctan\left(\frac{x+1}{2}\right)}{2}-\ln{\left| \frac{2}{\sqrt{x^{2}+2x+5}} \right|}+C$

Your step 4 and your global approach are correct, and your answer written as $$\frac{3}{2} \arctan\left(\frac{1+x}{2}\right)+\frac{1}{2} \log\left(5+2 x+x^2\right)+C$$ is correct too, since you can easily check that $$\left(\frac{3}{2} \arctan\left(\frac{1+x}{2}\right)+\frac{1}{2} \log\left(5+2 x+x^2\right)+C\right)'=\frac{x+4}{x^{2}+2x+5}.$$