Integrating $\ln^2 x$ by parts Guys I even tried looking at the solution, yet I still can't figure it out. Would love some help here.
$$\int\ln^2 x\,dx$$
I know the Int. by parts formula is

$f(x)g'(x)=f(x)g(x)-\int\ f'(x)g(x)$

Now we are supposed to assign $f(x)$ to the part that gets easier when we differentiate it, and $g'(x)$ to something that gets easier once we integrate it.
So I think setting $\ln^2(x)$ to be $f(x)$ would be easier, since differentiating it would get us $\frac{2\ln x}{x}$. Now setting $x$ up to be $g'(x)$ would be a little bit hairy, since integrating it would result in $\frac {x^2}{2}$.

$f(x)=\ln^2(x)$
$f'(x)=\frac{2\ln(x)}{x}$
$g(x)=\frac{x^2}{x}$
$g'(x)=x$
$\ln^2(x)\frac{x^2}{x}-\int\ \frac{2\ln(x)}{x}\frac{x^2}{x}$
Simplifying a little: $\ln^2(x){x}-2\int\ \frac{\ln(x)x^2}{x}$

So it doesn't really seem to work unless I'm doing something wrong, how are we supposed to integrate these?
Any help is appreciated!
 A: Hint:$$\int\ln^2x\,\mathrm dx=\int1\times\ln^2x\,\mathrm dx=x\ln^2x-2\int x\ln(x)\frac1x\,\mathrm dx=x\ln^2x-2\int\ln x\,\mathrm dx.$$
A: Let us first tackle
$$\int \log x\,dx$$ wich can also be addressed by parts (introducing a factor $1$) with
$$\int 1\cdot\log x\,dx=x\log x-\int\frac xxdx=x(\log x-1).$$
Now we have
$$\int\log^2x\,dx=\int\log x\cdot\log x\,dx=x(\log x-1)\log x-\int(\log x-1)\frac xx\,dx\\
=x(\log x-1)\log x-x(\log x-1)+x.$$
A: You're doing good: now observe that
$$
\frac{2\ln x}{x}\frac{x^2}{x}=2\ln x
$$
(you did a wrong simplification) and go on with another integration by parts.
Alternative method: substitute $x=e^t$, with $dx=e^t\,dt$, so you have
$$
\int t^2e^t\,dt
$$
Now it is obvious what is the differential factor to use:
$$
\int t^2e^t\,dt=
t^2e^t-\int 2te^t\,dt=
t^2e^t-2\left(te^t-\int e^t\,dt\right)=
t^2e^t-2te^t+2e^t+c
$$
and back substitution gives
$$
x\ln^2x-2x\ln x+2x+c
$$
One can avoid multiple integrations by parts by observing that
$$
\int t^2e^t\,dt=(t^2+at+b)e^t+c
$$
and differentiating both sides yields
$$
t^2e^t=(2t+a+t^2+at+b)e^t
$$
whence $a+2=0$ and $a+b=0$, so $a=-2$ and $b=2$.
A: If you change: $\ln x=t \Rightarrow x=e^t \Rightarrow dx=e^tdt$, then:
$$\int\ln^2 x\,dx=\int t^2 e^t\,dt=t^2e^t-\int e^t\cdot 2tdt=t^2e^t-\left(2te^t-\int 2e^tdt\right)=\\
t^2e^t-2te^t+2e^t+C=x\ln^2 x-2x\ln x+2x+C.$$
A: $$\int \ln^2(x)dx$$
Apply Integration By parts: $u=\ln^2(x),v^{\prime}=1$
$$=\ln^2(x)x-\int\frac{2\ln(x)}{x}dx$$
$$=x\ln^2(x)-\int2\ln(x)dx$$
Note that, $\int2\ln(x)dx=2(x\ln(x)-x)$
$$=x\ln^2(x)-2(x\ln(x)-x)$$
$$\int \ln^2(x)dx=x\ln^2(x)-2(x\ln(x)-x)+C$$
