Find $\int \frac{\ln\left(\frac{{e^x}}{x}\right)}{{x}}dx$ 
Find $\displaystyle\int \frac{\ln\left(\frac{{e^x}}{x}\right)}{{x}}dx$.

So, here is what I did:
\begin{align}
I & := \int \frac{\ln(e^x)-\ln(x)}{{x}}dx
= \int \frac{x-\ln(x)}{{x}}dx
= \int 1 - \frac{\ln(x)}{x}dx \\
& = \int 1 - \int\frac{\ln(x)}{x}dx
=x - \int\frac{\ln(x)}{x}dx.
\end{align}
Now, let $u = \ln(x)$.
Then we have $du = 1/x dx$ and $dx = x du$ therefore
\begin{align}
I
= x - \int\frac{u}{x}x\ du
= x - \int\frac{u}du
= x - \frac{u^2}{2}
= x - \frac{\ln^2(x)}{2}
= x - \ln(x)
\end{align}
However, when I checked on Symbolab it gives me
$ x - \frac{\ln^2(x)}{2} - \frac{1}{2} + C$.
I couldn't quite get where I go wrong. If you can explain it to me it would be great. Thanks.
 A: There's only a small mistake:
$$
x - \frac{\ln^2(x)}{2}
\ne x- \ln(x).
$$
As pointed out in the other answer, you were probably thinking
$$\ln(x)^2 \overset{(\ddagger)}{=} \ln(x^2) \overset{(\star)}{=} 2 \ln(x).$$
The step $(\star)$ is correct in general, but ($\ddagger$) is not.
Up until that step everything is correct.
When evaluating a indefinite integral you have to add the arbitrary constant $+C$, which you forgot. 
Since
$$
x -  \frac{\ln^2(x)}{2} - \frac{1}{2} + C
= x -  \frac{\ln^2(x)}{2} + \tilde{C} 
$$
for some other constant $\tilde{C}$, the result is correct.
Also notice that SymboLab also has a $+C$ in their solution.
A: $\dfrac{(\ln x)^2}2$ will be $=\dfrac{\ln(x^2)}2$
if $(\ln x)^2=2\ln x\iff \ln x=0,2$
So, in general they are not same
and we know $\ln(x^m)=m\ln x$
A: How did you get from $\frac{\ln^2{x}}{2}$ to $\ln{x}$? The 2 is on the logarithm: $\ln^2{x}=(\ln{x})^2$. It's not on the $x$. So, you can't bring the $2$ out front like that. Your answer one step back looked fine. Just add a constant of integration to it and it's the same answer as that of Symbolab's:
$$
x-\frac{\ln^2{x}}{2}+K=x-\frac{\ln^2{x}}{2}-\frac{1}{2}+C.
$$
Never forget that there always must be a constant of integration at the end of your answer.
Think about what happens if you differentiate both results. $K$ and $-\frac{1}{2}+C$ are both numbers and numbers, as you must know, always differentiate to zero. So, in both cases, you end up differentiating exactly the same function.
