# Integrate: $\int \frac{x}{\left(x^2-4x-13\right)^2}dx$.

Integrate: $$\int \frac{x}{\left(x^2-4x-13\right)^2}dx$$

Here's my attempt:

I first completed the squares for the denominator: $$\left(x^2-4x-13\right)^2=(x-2)^2-17 \implies \int \frac{x}{\left(\left(x-2\right)^2-17\right)^2}dx$$

I then used $$u$$-subsituition: $$u=x-2 \implies \int \frac{u+2}{\left(u^2-17\right)^2}du = \int \frac{u}{\left(u^2-17\right)^2}du+\int \frac{2}{\left(u^2-17\right)^2}du$$

The first part of the new integral is quite simple: $$\int \frac{u}{\left(u^2-17\right)^2}du=\frac{-1}{2(u^2-17)}$$ Then I did the second part: $$\int \frac{2}{\left(u^2-17\right)^2}du = -\frac{1}{2\left(u^2-17\right)}+2\left(\frac{1}{68\sqrt{17}}\ln \left|u+\sqrt{17}\right|-\frac{1}{68\left(u+\sqrt{17}\right)}-\frac{1}{68\sqrt{17}}\ln \left|u-\sqrt{17}\right|-\frac{1}{68\left(u-\sqrt{17}\right)}\right) = -\frac{1}{2\left(\left(x-2\right)^2-17\right)}+2\left(\frac{1}{68\sqrt{17}}\ln \left|x-2+\sqrt{17}\right|-\frac{1}{68\left(x-2+\sqrt{17}\right)}-\frac{1}{68\sqrt{17}}\ln \left|x-2-\sqrt{17}\right|-\frac{1}{68\left(x-2-\sqrt{17}\right)}\right) = -\frac{1}{2\left(x^2-4x-13\right)}+2\left(\frac{1}{68\sqrt{17}}\ln \left|x-2+\sqrt{17}\right|-\frac{1}{68\left(x-2+\sqrt{17}\right)}-\frac{1}{68\sqrt{17}}\ln \left|x-2-\sqrt{17}\right|-\frac{1}{68\left(x-2-\sqrt{17}\right)}\right) + C, C \in \mathbb{R}$$

Is this working out correct? I'm not really sure how WolframAlpha works, so I didn't check it on there.

Here is an alternative method to integrate as follows $$\int \frac{x}{\left(x^2-4x-13\right)^2}dx$$ $$=\int\frac12 \frac{(2x-4)+4}{\left(x^2-4x-13\right)^2}dx$$ $$=\frac12\int \frac{2x-4}{\left(x^2-4x-13\right)^2}dx+\frac12\int\frac{4}{\left(x^2-4x-13\right)^2}dx$$ $$=\frac12\int \frac{d(x^2-4x-13)}{\left(x^2-4x-13\right)^2}+2\int\frac{d(x-2)}{\left((x-2\right)^2-17)^2}$$ using reduction formula: $$\color{blue}{\int \frac{dt}{(t^2+a)^n}=\frac{t}{2(n-1)a(t^2+a)^{n-1}}+\frac{2n-3}{2(n-1)a}\int\frac{dt}{(t^2+a)^{n-1}}}$$, $$=\frac12 \frac{-1}{\left(x^2-4x-13\right)}+2\left(\frac{(x-2)}{2(-17)((x-2)^2-17)}+\frac{1}{2(-17)}\int \frac{d(x-2)}{(x-2)^2-17}\right)$$ using standard formula: $$\color{blue}{\int \frac{dt}{t^2-a^2}=\frac{1}{2a}\ln\left|\frac{t-a}{t+a}\right|}$$, $$=-\frac{1}{2\left(x^2-4x-13\right)}-\frac{(x-2)}{17(x^2-4x-13)}-\frac{1}{34\sqrt{17}}\ln\left|\frac{x-2-\sqrt{17}}{x-2+\sqrt{17}}\right|+C$$ $$=-\frac{2x+13}{34(x^2-4x-13)}-\frac{1}{34\sqrt{17}}\ln\left|\frac{x-2-\sqrt{17}}{x-2+\sqrt{17}}\right|+C$$

Hint:

Observe that

$$\left(-\frac u{u^2-a^2}\right)'=\frac{u^2+a^2}{(u^2-a^2)^2}=\frac1{u^2-a^2}+\frac{2a^2}{(u^2-a^2)^2}.$$

Hence

$$\int\dfrac{du}{(u^2-a^2)^2}=-\frac u{2a^2(u^2-a^2)}-\frac1{2a^2}\int\dfrac{du}{u^2-a^2}.$$

The last integral by $$\text{artanh}$$.

Making the problem more general $$I=\int \frac x {(x^2+ax+b)^2}\,dx \qquad \text{with} \qquad a^2-4b \neq 0$$ Let $$r$$ and $$s$$ be the roots of the quadratic (whatever they could be - real or complex) to make $$\frac x {(x^2+ax+b)^2}= \frac x {(x-r)^2 \, (x-s)^2}$$ Using partial fraction decomposition $$\frac x {(x-r)^2 \, (x-s)^2}=\frac{r+s}{(r-s)^3}\left(\frac 1{x-s}-\frac 1{x-r} \right)+\frac 1{(r-s)^2 }\left(\frac{r}{(x-r)^2}+\frac{s}{(x-s)^2}\right)$$ The first part is simple. For the second piece, you have two integrals $$J_k=\int \frac k {(x-k)^2}\,dx=\int \frac {dy}{(y-1)^2}=-\frac 1{y-1}=-\frac{k}{x-k}$$ Just combine all the pieces and, at the end, replace $$r$$ and $$s$$ by their values.

Express the second integral as

\begin{align} \int \frac{2}{\left(u^2-17\right)^2}du &= -\frac2{17}\int \frac{du}{u^2-17} +\frac2{17}\int \frac{u^2du}{(u^2-17)^2} \end{align}

with

\begin{align} \int \frac{u^2du}{(u^2-17)^2} = -\frac12\int u d\left(\frac1{u^2-17} \right) = -\frac u{2(u^2-17)}+\frac12\int \frac {ud u}{u^2-17} \end{align}

Then, combining with the first integral to get

\begin{align} \int \frac{(u+2)du}{\left(u^2-17\right)^2}= \frac {-u}{17(u^2-17)} -\frac2{17}\int \frac{du}{u^2-17} & +\frac1{17}\int \frac {ud u}{u^2-17} + \int \frac{udu }{\left(u^2-17\right)^2} \end{align}

where each piece can be integrated steadily.