Help deriving an function from (Lagrangian?) properties I'm trying to derive a function f(x) that has the following properties:
$$f_x-\frac{f}{x}=g_x$$
(You might call this the Lagrangian?)
where
$$\begin{align*}
f&=f(x)\\
f_x&=\frac{df}{dx}\\
g_x&=\frac{d}{dx}\left(\frac{f}{x}\right)
\end{align*}$$
By rearranging I've gotten to the point where:
$$\frac{f}{f_x}=\frac{x^2-x}{x+1}.$$
But can't figure out what function satisfies this.
Thanks
 A: Your derivation is incorrect (you've got a wrong sign). I'll use $f'$ instead of $f_x$ (too many $x$'s around...)
We have:
$$f' - \frac{f}{x} = \frac{d}{dx}\frac{f}{x}.$$
If $f=0$, we get a solution. So assume that $f$ is not always $0$. Then the above equation
is equivalent to
$$\begin{align*}
f' - \frac{f}{x} &= \frac{xf' - f}{x^2}\\
x^2f' - xf &= xf' - f\\
x^2f' - xf' &= xf - f\\
(x^2-x)f' &= (x-1)f\\
\frac{f'}{f} &= \frac{x-1}{x^2-x} = \frac{x-1}{x(x-1)} = \frac{1}{x}.
\end{align*}$$
(you can see that you had $x+1$ instead of $x-1$).
Now, integrating we have:
$$\begin{align*}
\ln|f| &= \ln|x|+C\\
|f| &= Ax &&A\gt 0\\
f(x) &= Bx &&B\neq 0.
\end{align*}$$
Adding in $B=0$ we get that the solutions are $f(x)=Cx$, with $C$ a constant. Indeed, notice that if $f(x) = Cx$, then
$$f'-\frac{f}{x} = C - C = 0,$$
and
$$\frac{d}{dx}\frac{f}{x} = \frac{d}{dx}C = 0,$$
so they all satisfy your desired equation.
(If you actually had $\frac{f'}{f} = \frac{x+1}{x^2-x}$, then this can be solved by integration as well:
$$\begin{align*}
\ln|f| &= \int\frac{x+1}{x^2-x}\,dx\\
&= \int\left(\frac{-1}{x} + \frac{2}{x-1}\right)\,dx\\
&= -\ln|x| + 2\ln|x-1| + C\\
&= \ln\left|\frac{(x-1)^2}{x}\right| + C,
\end{align*}$$
and from this you can likewise obtain a formula for $f$.)
