Integrating a composition I'm need to calculate this:
$$\int g'(x) (2g(x) - \frac{1}{g^2(x)}) dx $$
I think i have to integrate by parts, so i put:
$$ dv= g'(x) dx,v=g(x)$$
$$u=2g(x) - g(x)^{-2},du=2g'(x)-(g(x)^{-2})'$$
then i apply:
$$uv-\int vdu $$
and i should integrate:
$$\int g(x)( 2g'(x)-g'(x)^{-2} $$
I'm not sure this is the right way, i think there is an easier way but how? 


I think there is an easier way but how? 

One may directly write
$$
\begin{align}
\int g'(x) \left(2g(x) - \frac{1}{g^2(x)}\right) dx&=2\int g'(x) g(x) dx- \int\frac{g'(x)}{g^2(x)} dx
\\\\&=g^2(x)+\frac1{g(x)}+C,
\end{align}
$$ where we have used that

$$
\left(g^{\alpha}\right)'=\alpha g' g^{\alpha-1},\quad \alpha \in \mathbb{R},
$$ 

by virtue of the chain rule.
