<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] Substitute 
$$x=a \hspace{3pt} \tan \theta$$
$$ dx = a\hspace{3pt} \sec^2 \theta \hspace{3pt} d\theta$$
The integral
$$
\begin{align*}
\int \frac{1}{(x^2+a^2)^2} \hspace{3pt}dx &= \int  \frac{\hspace{3pt}a \hspace{3pt}\sec^2 \theta }{a^4 \hspace{3pt} \sec^4 \theta}\hspace{3pt} d\theta\\
&= \frac{1}{a^3} \int  \frac{1}{\sec^2 \theta}\hspace{3pt} d\theta\\
&= \frac{1}{a^3} \int \cos^2 \theta\hspace{3pt} d\theta\\
&= \frac{1}{2a^3} \int 2\hspace{3pt}\cos^2 \theta\hspace{3pt} d\theta\\
&= \frac{1}{2a^3} \int (1+\cos2 \theta)\hspace{3pt} d\theta\\
&= \frac{1}{2a^3} \theta + \frac{1}{2a^3} \frac{\sin 2\theta}{2} + \text{constant} \\
&= \frac{1}{2a^3} \tan^{-1}\frac{x}{a} + \frac{1}{2a^3} \frac{\sin 2\theta}{2} + \text{constant} \\
\tag{A}\\
\end{align*}
$$
But since we substituted $x=a \hspace{3pt} \tan \theta$, which is equivalent to 
$$\sin \theta = \frac{x}{\sqrt{x^2+a^2}}$$ and $$\cos \theta = \frac{a}{\sqrt{x^2+a^2}}$$
$$ \sin2\theta = 2 \sin\theta \cos\theta = \frac{2xa}{x^2+a^2}$$
The integral therefore simplifies to
$$\frac{1}{2a^3} \tan^{-1}\frac{x}{a} + \frac{1}{2a^3} \frac{ax}{x^2+a^2} + \text{constant}$$
</s>