Indefinite integral of a rational function problem... Edit: Corrected my question.
If we have a rational function in general case:
$$f(x)=\frac{1}{(x^2+a^2)^n}$$
And we denote its integral as:
$$I_n=\int \frac{dx}{(x^2+a^2)^n}$$
For $n=1$ we have the integral in the lists:
$$\int \frac{dx}{x^2+a^2}=\frac{1}{a}\arctan\frac{x}{a}+C$$
For $n>1$ my professor used integration by parts:
$$u=\frac{1}{(x^2+a^2)^n} \to du=-n\frac{2x}{(x^2+a^2)^{n+1}}dx$$
$$dv=dx \to v=x$$
Then, we have:
$$I_n=uv-\int vdu=\frac{x}{(x^2+a^2)^n}+\int \frac{2nx^2}{(x^2+a^2)^{n+1}}dx=$$
$$=\frac{x}{(x^2+a^2)^n}+2n\int \frac{x^2+a^2-a^2}{(x^2+a^2)^{n+1}}dx=$$
$$\frac{x}{(x^2+a^2)^n}+2n\int \frac{dx}{(x^2+a^2)^n}-2na^2 \int \frac{dx}{(x^2+a^2)^{n+1}}dx=$$
$$\frac{x}{(x^2+a^2)^n}+2nI_n-2na^2I_{n+1}$$
And he got a recursive formula:
$$I_{n+1}=\frac{2n-1}{2na^2}I_n+\frac{1}{2na^2}\cdot\frac{x}{(x^2+a^2)^n}$$
where $n=1,2,3,...$
The procedure seems completely fine to me, I couldn't find a mistake anywhere, but, that recursive formula doesn't give the correct result of the integral of function in that form.
For example, lets say we want to integrate the function:
$$f(x)=\frac{1}{(x^2+4x+5)^2}$$
The correct result would be (using WA):
$$\frac{1}{2}\bigg(\frac{x+2}{x^2+4x+5}+\arctan(x+2)\bigg)+C$$
But if we use the recursive formula for $n=1$ we get:
$$I_2=\frac{3}{4}I_1+\frac{1}{4}\cdot\frac{x+2}{(x^2+4x+5)^2}$$
And since $I_1=\arctan(x+2)+C$ we get:
$$I_2=\frac{3}{4}\arctan(x+2)+\frac{1}{4}\cdot\frac{x+2}{(x^2+4x+5)^2}+C$$
Which is not correct according to WA.
Thank you for your time.

You obviously made a mistake of putting n=2 in the formula, when you are actually trying to calculate I_2, so n+1=2 and n=1. 
Putting n=1, you will get the result you got from Wolfram Alpha.  
