<s>[INST] Help evaluating $\int \frac{dx}{(x^2 + a^2)^2}$ I have following integral and it should be simple, however whatever substitution I use and no matter how many times I integrate it by parts (or combine both) I never get the correct solution (or any alternative solution):
$$\int \frac{dx}{(x^2 + a^2)^2}$$
I'm looking for what is on the Wolfram|Alpha in the alternative solutions section:
$$\frac{\arctan(\frac{x}{a})}{2a^3} + \frac{x}{2a^2(a^2 + x^2)} $$
 [/INST] We will use integration by parts. Assume that $a$ is positive. We first make the preliminary substitution $x=at$. Then $dx=a\,dt$, and when we go through the substitution process, we end up with $\int \frac{1}{a^3}\frac{dt}{(1+t^2)^2}$.
Let's not bother to carry the constant $\frac{1}{a^3}$ around, it can be inserted at the end. So we go after $\int \frac{dt}{(1+t^2)^2}$.
We use a little trick that has a number of uses.  Let $I=\int \frac{dt}{1+t^2}$. (This is not a typo!)  We recognize this integral instantly, since we know that the derivative of $\arctan t$ is $\frac{1}{1+t^2}$. But let's begin to evaluate the integral by using integration by parts. 
Let $u=\frac{1}{1+t^2}$ and $dv=dt$. Then $du= -\frac{2t}{(1+t^2)^2}$ and we can take $v=t$. Thus 
$$I=\int \frac{dt}{1+t^2}=\frac{t}{1+t^2}- \int-\frac{2t^2\,dt}{(1+t^2)^2}.$$
Get rid of the doubled minus signs, and rewrite $2t^2$ as $2+2t^2 -2$. We end up with 
$$I=\frac{t}{1+t^2} +\int \frac{2(1+t^2)}{(1+t^2)^2}-\int \frac{2\,dt}{(1+t^2)^2},$$ and therefore
$$I=\frac{t}{1+t^2}+2I-2\int\frac{dt}{(1+t^2)^2}.$$
Thus 
$$2\int\frac{dt}{(1+t^2)^2}=\frac{t}{1+t^2}+I=\frac{t}{1+t^2}+\arctan t.$$
So to find $\int \frac{dt}{(1+t^2)^2}$, divide the right-hand side by $2$. And don't forget to add the arbitrary constant $C$ of integration at the end.
</s>