TITLE: Find the following integral: $\int {{{(\ln x)}^2}} dx$ by using the method of integration by parts
QUESTION [7 upvotes]: Find $\int {{{(\ln x)}^2}} dx$ by using the method of integration by parts.

My attempt:
$$\eqalign{
  & \int {{{(\ln x)}^2}} dx = \int {2\ln x} dx  \cr 
  & u = \ln x,{\rm{ }}{{du} \over {dx}} = {1 \over x}  \cr 
  & {{dv} \over {dx}} = 2,{\rm{ }}v = 2x  \cr 
  & so:  \cr 
  & \int {{{(\ln x)}^2}} dx = 2x\ln x - \int {2x \times {1 \over x}} dx  \cr 
  &  = 2x\ln x - 2x + C \cr} $$

This is the wrong answer, the right answer is:
$$x{(\ln x)^2} - 2x\ln x + 2x + C$$
What have I missed?

REPLY [2 votes]: $$\int {{{(\log x)}^2}} dx $$
(To remind that $(\log x)^2\ne \log x^2; (\log x)^2=(\log x)\cdot(\log x)$ while $\log x^2=2\log x$)
$$\int {{{(\log x)}.(\log x)}} dx $$
$$(\log x)\cdot\int {{(\log x)}} dx -\int [{d/dx(\log x)}{\int {\log x}dx} ]dx$$
since $$\int {\log x}dx=x\log x-x$$
so
$$(\log x)\cdot(x\log x - x) -\int [\frac {1}{x}(x\log x - x)]dx$$
$$(\log x)\cdot(x\log x - x) -\int {(\log x - 1)} dx$$
$$x(\log x)^2 - x\log x -(x\log x - x)+x$$
$$x(\log x)^2 - 2x\log x +2x+C$$