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.
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.