<s>[INST] Integral: $\int \dfrac{dx}{(x^2-4x+13)^2}$? 
How can I integrate $$\int \dfrac{dx}{(x^2-4x+13)^2}?$$

Here is my attempt:
$$\int \dfrac{dx}{(x^2-4x+13)^2}=\int \dfrac{dx}{((x-2)^2+9)^2}$$
Substitute $x-2=3\tan\theta$, $\ dx=3\sec^2\theta d\theta$
\begin{align*}
&=\int \dfrac{3\sec^2\theta d\theta}{(9\tan^2\theta+9)^2}\\
&=\int \dfrac{3\sec^2\theta d\theta}{81\sec^4\theta}\\
&=\dfrac{1}{27}\int \cos^2\theta d\theta\\
&=\dfrac{1}{27}\int \frac{1+\cos2\theta}{2} d\theta\\
&=\dfrac{1}{54}\left(\theta+\frac{\sin2\theta}{2}\right)+C
\end{align*}
This is where I got stuck. How can I get the answer in terms of $x$?
Can I solve it by other methods?
 [/INST] Since you selected $$x - 2 = 3 \tan \theta$$ as your substitution, it follows that $$\tan \theta = \frac{x-2}{3},$$ and by considering a right triangle with legs $3$ and $x-2$ with hypotenuse $\sqrt{3^2 + (x-2)^2}$ via the Pythagorean theorem, we obtain $$\sin \theta = \frac{x-2}{\sqrt{3^2 + (x-2)^2}}, \\ \cos \theta = \frac{3}{\sqrt{3^2 + (x-2)^2}}.$$  Therefore, $$\frac{1}{2} \sin 2\theta = \sin \theta \cos \theta = \frac{3(x-2)}{3^2 + (x-2)^2} = \frac{3(x-2)}{x^2 - 4x + 13}.$$  We also easily have $$\theta = \tan^{-1} \frac{x-2}{3}.$$  Therefore $$\frac{1}{54}\left( \theta + \frac{1}{2} \sin 2\theta \right) = \frac{1}{54} \left( \tan^{-1} \frac{x-2}{3} + \frac{3(x-2)}{x^2 - 4x + 13} \right).$$
</s>