Integration by substitution: $\displaystyle\int\frac{dx}{(1+x^2)^2}$ I came across this solution of a tricky integral using implicit substitution (i.e., manipulating differentials without actually declaring $u=\cdots$).
\begin{align*}
                \int \frac{dx}{(1+x^2)^2} &= \int \frac{1 + x^2 - x^2}{(1+x^2)^2}\,dx\\
                &= \int \frac{dx}{1+x^2} - \int \frac{x^2}{(1+x^2)^2}\,dx\\
                &=\tan^{-1}x - \frac{1}{2}\int \frac{x}{(1+x^2)^2}\,d(x^2+1)\\
                &= \tan^{-1}x+\frac 12\int x\, d\Big(\frac 1{1+x^2}\Big)\\
                &=\tan^{-1}x + \frac12\cdot \frac{x}{1+x^2}- \frac12\int \frac{dx}{1+x^2}\\
                &= \frac12\Big(\tan^{-1}x + \frac{x}{1+x^2}\Big)+c.
            \end{align*}
Can someone help me understand how to go from the third line to the fourth?  It doesn't seem like an obvious step. I'm guessing that it's because
$$d\Big(\frac 1{u(x)}\Big) = -\frac{d(u(x))}{u(x)^2},$$
but it doesn't seem like a natural next step, it's just the way I justified it to myself after already having seen the solution. Why should it be the next step?
 A: Here's something you might like.
Writing the indefinite integral as a definite one and applying Feynman's method
\begin{align}I(a)&=\int_c^x\dfrac{1}{a^2+x^2}\,\mathrm dx=\dfrac1a\arctan\left(\dfrac xa\right)\bigg|_c^x=\dfrac1a\arctan\left(\dfrac xa\right)+C\\I'(a)&=\int_c^x-\dfrac{2a}{(a^2+x^2)^2}\,\mathrm dx=-\dfrac1{a^2}\arctan\left(\dfrac xa\right)-\dfrac x{a^2+x^2}+K\\-\dfrac1{2a}I'(a)&=\int_c^x\dfrac1{(a^2+x^2)^2}\,\mathrm dx=\dfrac1{2a^3}\arctan\left(\dfrac xa\right)+\dfrac1{2a(a^2+x^2)}+K\\-\dfrac12I'(1)&=\int_c^x\dfrac1{(1+x^2)^2}\,\mathrm dx=\dfrac12\arctan x+\dfrac1{2(1+x^2)}+K\end{align}
$$\boxed{\boxed{\int\dfrac1{(1+x^2)^2}\,\mathrm dx=\dfrac12\left[\arctan x+\dfrac1{1+x^2}+K\right]}}$$
where $C=\dfrac1a\arctan\left(\dfrac ca\right)$
A: Observe that $\;d(x^2+1)=2x\,dx\;$, thus
$$x^2\,dx=\frac12\left(x\,d(x^2+1)\right)$$
and in a similar way
$$d\left(\frac1{x^2+1}\right)=-\frac{2x}{(1+x^2)^2}dx$$
Thus, from fourth to fifth line they do integration by parts, as in the fourth one they have $\;\int uv' dx\;$ , with $\;u=x,\,\;\;v'=d\left(\frac1{x^2+1}\right)\;$ ...
Pretty beautiful way...and the way you justified it is the correct one.
A: What's been done is Integration by Substitution. The full form would explicitly perform the substitution $u = x^2 + 1$, calculate $du$ in the form of $dx$, and substitute everything explicitly.
What the source of this working has done is directly plop the $x^2 + 1$ in place without bothering to go through the workings. It looks a bit like showing off to me, deliberately being a smartypants in order to confuse those weaker.
If you go through the work of making that $u = x^2 + 1$ substitution on the RHS of line 2, you will get to the same answer with a little bit more work, and a much more transparent argument.
If you want another way of doing it, substituting $x = \tan \theta$ generates a surprisingly simple integration, but you do need to use a tangent half-angle substitution at the end because you get an expression in $\sin 2 \theta$ which is fiddlesome to substitute back for $x$.
https://proofwiki.org/wiki/Primitive_of_Reciprocal_of_x_squared_plus_a_squared_squared
