Show that $f(x)={1+\ln x\over x}, x>0$ 
Let $f:(0,+\infty)\to\mathbb R$ be a function with $f(1)=1$ which is differentiable and for which it applies:
$$xf(x)=1-x^2f'(x), \forall x>0$$
Show that $f(x)={1+\ln x\over x}, x>0$

Personal work:
$$xf(x)=1-x^2f'(x)\iff_{x\neq0} f(x)={1-x^2f'(x)\over x}$$
We know that $f(1)=1$, so:
$$f(1)=1\iff{1-x^2f'(x)\over x}=1\iff1-x^2f'(x)=x\iff-x^2f'(x)=x-1\iff f'(x)={x-1\over -x^2}$$
That's what I got. What's the problem? The actual derivative of $f(x)$ is ${-\ln x\over x^2}$ and not $$\color{red}{x-1\over -x^2}$$
 A: Put $y = f(x)$ then $y' +\dfrac{1}{x}y= \dfrac{1}{x^2}\implies xy'+y= \dfrac{1}{x}\implies (xy)' = \dfrac{1}{x}\implies xy = \ln x + C$. Since $x = 1, y = 1\implies C = 1$. Thus $f(x) = \dfrac{\ln x + 1}{x}$ .
A: The homogeneous equation is
$$\frac {f'}{f}=-\frac {1}{x} $$
its solution is
$$f (x)=\frac {\lambda}{x} $$
the variation of the constant gives
$$\lambda'(x)=\frac {1}{x} $$
thus $$\lambda (x)=\ln (x) $$
the general solution is
$$f (x)=\frac {\lambda}{x}+\frac {\ln (x)}{x} =\frac {\lambda+\ln (x)}{x}.$$
$f (1)=1\implies \lambda=1$.
A: This line is not correct you cant keep f(x) once you asign a value to x
$$f(1)=1\iff{1-x^2f'(x)\over x}=1$$
$$f(1)=1\iff{1-1f'(1)\over 1}=1 \implies f'(1)=0$$
Another hint
$$xf(x)=1-x^2f'(x), \forall x>0$$
$$x^2f'=1-xf$$
$$x^2f'+xf=1$$
$$xf'+f=\frac 1x$$
$$(xf)'=\frac 1x$$
Integrate
$$xf=\int \frac {dx}{x}+K$$
$$f(x)= \frac {\ln|x|+K}x$$
$$f(1)=1 \implies K=1$$
$$\boxed{f(x)= \frac {\ln(x)+ 1}x \quad ; x>0}$$
A: Actually it is $$x\left(\frac{1+\ln(x)}{x}\right)=1-x^2\left(\frac{-\ln(x)}{x^2}\right)$$
A: Let me try to explain where you went wrong. You start with 
$$
f(x) = \frac{1-x^2f'(x)}x,\qquad f(1)=1
$$
You then plugged $x=1$ into the left equation, and arrived at 
$$
1 = \frac{1-\color{red}{x}^2f'(\color{red}x)}{\color{red}x}
$$
This is where you made your mistake. When you substitute $x=1$ in an equation, you need to substitute it everywhere. You failed to replace the red $\color{red}x$'s with $1$s. 
Going correctly, all you would get would be
$$
1 = \frac{1-1^2f'(1)}{1}\implies f'(1)=0
$$
