TITLE: Step by step solution of an Indefinite Integral
QUESTION [6 upvotes]: I had this on my test, I just couldn't get it, after solving it a lot.
$$\int\left\{\frac{\log x-1}{1+(\log x)^2}\right\}^2\,dx=\,?$$
I have tried substituting $\log(x)=t$ and then
$$
\int \frac{(t-1)^{2} e^{t} d t}{\left(t^{2}+1\right)^{2}}=\int\left\{\frac{\left(t^{2}+1\right)}{\left(t^{2}+1\right)^{2}}-\frac{2 t}{\left(t^{2}+1\right)^{2}}\right\} e^{t} d t
$$
and then, applying the by parts rule,
$$
=e^{t}\left(\tan ^{-1} t-\frac{1}{t^{2}+1}\right)-\int e^{t}\left(\tan ^{-1} t-\frac{1}{t^{2}+1}\right) d t
$$
after that I can't get ahead.
P.S.- All Curly brackets used here are normal brackets, not the ones used in fractional part. Thanks to @ParclyTaxel for pointing it out.

REPLY [5 votes]: we have a result $$\int e^x(f(x)+f'(x))=e^x f(x)+c \tag 1$$ this ie very easy to prove by intgration by parts. You have already done the difficult part of splitting the integral to $$\int e^t\left(\frac{1}{t^2+1}-\frac{2t}{{(t^2+1)}^2}\right)dt $$Now if $$f(t)=\frac{1}{t^2+1} \implies f'(t)= \frac{-2t}{{(t^2+1)}^2}$$  which is of form (1).......

REPLY [4 votes]: Since $1+\log^2x$ is squared and appears in the denominator, we might try an antiderivative of something over $1+\log^2x$ because of the quotient rule:
$$\frac d{dx}\frac f{1+\log^2x}=\frac{f'(1+\log^2x)-f((2/x)\log x)}{(1+\log^2x)^2}$$
The numerator contains only $\log$s, so $f$ must cancel the $\frac1x$ of $\frac2x\log x$. So $f$ might be $x$; we check and it works, and the answer is
$$\frac x{1+\log^2x}+K$$